Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
allow expect in expect (expect clauses surrounded by |)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoralesc committed Jan 2, 2015
1 parent 7d3f5f1 commit 28eca09
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions autoload/tutor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions syntax/tutor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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 /\}\@<! {expect:.\+}\s*$/ contained containedin=tutorSampleText conceal
syn match tutorSampleTextExpect /|\@<! |expect:.\+|\s*$/ contained containedin=tutorSampleText conceal

syn region tutorCommand matchgroup=Delimiter start=/^\s\{4,}:/ end=/$/ keepend contains=tutorKey
syn match tutorCommandCmd /\(:\||\s\)\@<=\S\+/ contained containedin=tutorCommand
Expand Down
9 changes: 4 additions & 5 deletions tutorials/tutor.tutor
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ the document.

13.

---> 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}|

0 comments on commit 28eca09

Please sign in to comment.