From 28eca09a3caffbc069cde4e9d1f33dfa4365b229 Mon Sep 17 00:00:00 2001 From: Felipe Morales Date: Fri, 2 Jan 2015 14:19:36 -0300 Subject: [PATCH] allow expect in expect (expect clauses surrounded by |) --- autoload/tutor.vim | 10 +++++++--- syntax/tutor.vim | 1 + tutorials/tutor.tutor | 9 ++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/autoload/tutor.vim b/autoload/tutor.vim index a8af249..171c570 100644 --- a/autoload/tutor.vim +++ b/autoload/tutor.vim @@ -138,9 +138,13 @@ endfunction function! tutor#CheckText() let l:text = getline('.') if match(l:text, '{expect:NULL}\s*$') == -1 - let l:cur_text = matchstr(l:text, '---> \zs.\{-}\ze {expect:') - let l:expected_text = matchstr(l:text, '{expect:\zs.*\ze}\s*$') - "echom l:cur_text."|".l:expected_text + if match(getline('.'), '|expect:.\+|') == -1 + let l:cur_text = matchstr(l:text, '---> \zs.\{-}\ze {expect:') + let l:expected_text = matchstr(l:text, '{expect:\zs.*\ze}\s*$') + else + let l:cur_text = matchstr(l:text, '---> \zs.\{-}\ze |expect:') + let l:expected_text = matchstr(l:text, '|expect:\zs.*\ze|\s*$') + endif if l:cur_text ==# l:expected_text exe "sign place ".b:tutor_sign_id." line=".line('.')." name=tutorok buffer=".bufnr('%') else diff --git a/syntax/tutor.vim b/syntax/tutor.vim index f2d4b7f..a4169be 100644 --- a/syntax/tutor.vim +++ b/syntax/tutor.vim @@ -17,6 +17,7 @@ syn match tutorTextMark /--->/ conceal cchar=→ syn region tutorSampleText start=/^\(--->\)\@=/ end=/$/ keepend contains=@SPELL syn match tutorSampleTextMark /^--->/ contained containedin=tutorSampleText conceal cchar=→ syn match tutorSampleTextExpect /\}\@ this is not right {expect:---> this is right} ----> ---> this is right {expect:---> this is right} +---> this is not right {expect:---> this is right} |expect:---> this is right {expect:---> this is right}| +---> ---> this is right {expect:---> this is right} |expect:---> this is right {expect:---> this is right}| 14. -TODO: Fix the syntax file and checker to handle this case. - ----> ---> this is some text {expect:NULL} {expect:---> this is some text {expect:NULL}} +---> this is some text |expect:---> this is some text {expect:NULL}| +---> ---> this is some text {expect:NULL} |expect:---> this is some text {expect:NULL}|