Feature: Syntax: Provide vimwiki language escape sequences -> \token #1044
This commit is contained in:
+12
-3
@@ -308,9 +308,13 @@ function! vimwiki#u#hi_expand_regex(lst) abort
|
||||
let res = []
|
||||
let p = vimwiki#u#get_punctuation_string()
|
||||
for delimiters in a:lst
|
||||
call add(res, [
|
||||
\ delimiters[0] . '\S\@=',
|
||||
\ '\S\@<=' . delimiters[1] . '\%(\_[[:space:]' . p . ']\)\@='])
|
||||
let r_prefix = '\(^\|[[:space:]]\@<=\)'
|
||||
" Regex Start: not preceded by backslash, not ended by space
|
||||
let r_start = r_prefix . delimiters[0] . '\S\@='
|
||||
" Regex End: not preceded by backslash or space, ended by punctuation or space
|
||||
let r_prefix = '\(^\|[^[:space:]\\]\@<=\)'
|
||||
let r_end = r_prefix . delimiters[1] . '\%(\_[[:space:]' . p . ']\)\@='
|
||||
call add(res, [r_start, r_end])
|
||||
endfor
|
||||
return res
|
||||
endfunction
|
||||
@@ -323,14 +327,19 @@ function! vimwiki#u#hi_tag(tag_pre, tag_post, syntax_group, contains, ...) abort
|
||||
" :param: contains <string> coma separated and prefixed, default VimwikiHTMLTag
|
||||
" :param: (1) <boolean> is contained
|
||||
" :param: (2) <string> more param ex:oneline
|
||||
|
||||
" Discriminate parameters
|
||||
let opt_is_contained = a:0 > 0 && a:1 > 0 ? 'contained ' : ''
|
||||
let opt_more = a:0 > 1 ? ' ' . a:2 : ''
|
||||
let opt_contains = ''
|
||||
if a:contains !=# ''
|
||||
let opt_contains = 'contains=' . a:contains . ' '
|
||||
endif
|
||||
|
||||
" Craft command
|
||||
let cmd = 'syn region ' . a:syntax_group . ' matchgroup=VimwikiDelimiter ' .
|
||||
\ opt_is_contained .
|
||||
\ 'skip="\\' . a:tag_pre . '" ' .
|
||||
\ 'start="' . a:tag_pre . '" ' .
|
||||
\ 'end="' . a:tag_post . '" ' .
|
||||
\ 'keepend ' .
|
||||
|
||||
+66
-19
@@ -1,5 +1,52 @@
|
||||
# Syntax and Highlight
|
||||
|
||||
|
||||
# 0 Escape {{{1
|
||||
#################
|
||||
|
||||
Given vimwiki (Markdown typeface with escape sequence #1044: _ __ * ** {{{2):
|
||||
This is 14 | 1
|
||||
__bold from begining__ 2
|
||||
\__not bold even from begin \__ 3
|
||||
and __t \__ is still bold__ Bold 4
|
||||
and _ita\_ alic continues and end_ Italic 5
|
||||
*this\* \* is italic also* Italic 6
|
||||
a ^t\^ is supperscrit^ Sup 7
|
||||
,,sub\,, subscript end,, Sub 8
|
||||
a ~~st\~~ill deleted~~ Del 9
|
||||
$$Eq\$$ uation follows$ Math 10
|
||||
`code \` not finished inline` Code 11
|
||||
|
||||
Execute (Set syntax markdown):
|
||||
call SetSyntax('markdown')
|
||||
|
||||
Execute (Assert Syntax of escape typeface):
|
||||
AssertEqual '1' , SyntaxAt(1, 14) . 1
|
||||
AssertEqual 'VimwikiBold2' , SyntaxAt(2, 14) . 2
|
||||
AssertEqual '3' , SyntaxAt(3, 14) . 3
|
||||
AssertEqual 'VimwikiBold4' , SyntaxAt(4, 14) . 4
|
||||
AssertEqual 'VimwikiItalic5' , SyntaxAt(5, 14) . 5
|
||||
AssertEqual 'VimwikiItalic6' , SyntaxAt(6, 14) . 6
|
||||
AssertEqual 'VimwikiSuperScript7', SyntaxAt(7, 14) . 7
|
||||
AssertEqual 'VimwikiSubScript8' , SyntaxAt(8, 14) . 8
|
||||
AssertEqual 'VimwikiDelText9' , SyntaxAt(9, 14) . 9
|
||||
AssertEqual 'VimwikiMath10' , SyntaxAt(10, 14) . 10
|
||||
AssertEqual 'textSnipTEX11' , SyntaxAt(11, 14) . 11
|
||||
|
||||
Given vimwiki (Markdown pre with escape sequence #1044: _ __ * ** {{{2):
|
||||
```
|
||||
pre
|
||||
\```
|
||||
pre
|
||||
```
|
||||
|
||||
Execute (Assert Syntax of escape pre):
|
||||
AssertEqual 'VimwikiPreDelim1' , SyntaxAt(1, 1) . 1
|
||||
AssertEqual 'VimwikiPre2' , SyntaxAt(2, 1) . 2
|
||||
AssertEqual 'VimwikiPre3' , SyntaxAt(3, 1) . 3
|
||||
AssertEqual 'VimwikiPre4' , SyntaxAt(4, 1) . 4
|
||||
AssertEqual 'VimwikiPreDelim5' , SyntaxAt(5, 1) . 5
|
||||
|
||||
# 1 Typeface {{{1
|
||||
#################
|
||||
|
||||
@@ -15,17 +62,17 @@ Execute (Assert Syntax (alpha)):
|
||||
|
||||
Given vimwiki (Markdown bad __this_not_it__ {{{2):
|
||||
See here 14 |
|
||||
s2n_error
|
||||
s*n*er_r_
|
||||
n4rmal_aaaaaaaaaaaaaaaaaaaa_text_
|
||||
n5t_italiccccccccccccccccccccc_no
|
||||
n6t_italiccccccccccccccccccccccno
|
||||
n7t*italiccccccccccccccccccccc_no
|
||||
n8t*italiccccccccccccccccccccc*no
|
||||
__not_italicccccccccc_but_boldd__
|
||||
_a_asdasda_asdas_asdas_asdasda_a_
|
||||
_jitaliccccccccccccccccccccccccc_
|
||||
n12ormalllllllllllllllllllllllll_
|
||||
s2n_error 2
|
||||
s*n*er_r_ 3
|
||||
n4rmal_aaaaaaaaaaaaaaaaaaaa_text_ 4
|
||||
n5t_italiccccccccccccccccccccc_no 5
|
||||
n6t_italiccccccccccccccccccccccno 6
|
||||
n7t*italiccccccccccccccccccccc_no 7
|
||||
n8t*italiccccccccccccccccccccc*no 8
|
||||
__not_italicccccccccc_but_boldd__ 9
|
||||
_a_asdasda_asdas_asdas_asdasda_a_ 10
|
||||
_jitaliccccccccccccccccccccccccc_ 11
|
||||
n12ormalllllllllllllllllllllllll_ 12
|
||||
_italic if at end of file unfortunately
|
||||
Note: The decision to start a region is only based on a matching start
|
||||
pattern. There is no check for a matching end pattern. This does NOT
|
||||
@@ -63,19 +110,19 @@ Execute (Assert Syntax (charlie)):
|
||||
# Emphasis stricker {{{2
|
||||
# See: https://github.github.com/gfm/#emphasis-and-strong-emphasis
|
||||
Given vimwiki (Emphasis and not):
|
||||
this __bold__ ok
|
||||
this _italic_ ok
|
||||
t__ no bold __ t
|
||||
t_ no ital _ t
|
||||
this __bold__ ok 1
|
||||
this _italic_ ok 2
|
||||
t__ no bold __ t 3
|
||||
t_ no ital _ t 4
|
||||
|
||||
Execute (Set syntax markdown):
|
||||
call SetSyntax('markdown')
|
||||
|
||||
Execute (Assert Syntax (delta)):
|
||||
AssertEqual 'VimwikiBold' , SyntaxAt(1, 9)
|
||||
AssertEqual 'VimwikiItalic' , SyntaxAt(2, 9)
|
||||
AssertEqual '' , SyntaxAt(3, 9)
|
||||
AssertEqual '' , SyntaxAt(4, 9)
|
||||
AssertEqual 'VimwikiBold1' , SyntaxAt(1, 9) . 1
|
||||
AssertEqual 'VimwikiItalic2' , SyntaxAt(2, 9) . 2
|
||||
AssertEqual '3' , SyntaxAt(3, 9) . 3
|
||||
AssertEqual '4' , SyntaxAt(4, 9) . 4
|
||||
|
||||
# With vimwiki_hl_cb_checked {{{2
|
||||
Given vimwiki (task list with code):
|
||||
|
||||
Reference in New Issue
Block a user