diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 0a028507..4ef48fd8 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -86,12 +86,12 @@ syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained "HTML headings -syn region htmlH1 matchgroup=mkdHeading start="^\s*#" end="$" contains=mkdLink,mkdInlineURL,@Spell -syn region htmlH2 matchgroup=mkdHeading start="^\s*##" end="$" contains=mkdLink,mkdInlineURL,@Spell -syn region htmlH3 matchgroup=mkdHeading start="^\s*###" end="$" contains=mkdLink,mkdInlineURL,@Spell -syn region htmlH4 matchgroup=mkdHeading start="^\s*####" end="$" contains=mkdLink,mkdInlineURL,@Spell -syn region htmlH5 matchgroup=mkdHeading start="^\s*#####" end="$" contains=mkdLink,mkdInlineURL,@Spell -syn region htmlH6 matchgroup=mkdHeading start="^\s*######" end="$" contains=mkdLink,mkdInlineURL,@Spell +syn region htmlH1 matchgroup=mkdHeading start="^\s*#" end="$" contains=mkdEscape,mkdLink,mkdInlineURL,@Spell +syn region htmlH2 matchgroup=mkdHeading start="^\s*##" end="$" contains=mkdEscape,mkdLink,mkdInlineURL,@Spell +syn region htmlH3 matchgroup=mkdHeading start="^\s*###" end="$" contains=mkdEscape,mkdLink,mkdInlineURL,@Spell +syn region htmlH4 matchgroup=mkdHeading start="^\s*####" end="$" contains=mkdEscape,mkdLink,mkdInlineURL,@Spell +syn region htmlH5 matchgroup=mkdHeading start="^\s*#####" end="$" contains=mkdEscape,mkdLink,mkdInlineURL,@Spell +syn region htmlH6 matchgroup=mkdHeading start="^\s*######" end="$" contains=mkdEscape,mkdLink,mkdInlineURL,@Spell syn match htmlH1 /^.\+\n=\+$/ contains=mkdLink,mkdInlineURL,@Spell syn match htmlH2 /^.\+\n-\+$/ contains=mkdLink,mkdInlineURL,@Spell @@ -116,6 +116,9 @@ syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*\(\*\|\s\)*$/ syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-\(-\|\s\)*$/ syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_\(_\|\s\)*$/ +syntax region mkdEscape matchgroup=mkdEscape start=/\\\ze[\\\x60*{}\[\]()#+\-,.!_>~|"$%&'\/:;<=?@^]/ end=/.\zs/ keepend contains=mkdEscapeCh contained oneline concealends +syntax match mkdEscapeCh /./ contained + " YAML frontmatter if get(g:, 'vim_markdown_frontmatter', 0) syn include @yamlTop syntax/yaml.vim @@ -155,7 +158,7 @@ if get(g:, 'vim_markdown_strikethrough', 0) HtmlHiLink mkdStrike htmlStrike endif -syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath,mkdStrike +syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath,mkdStrike,mkdEscape "highlighting for Markdown groups HtmlHiLink mkdString String @@ -177,6 +180,7 @@ HtmlHiLink mkdLinkDef mkdID HtmlHiLink mkdLinkDefTarget mkdURL HtmlHiLink mkdLinkTitle htmlString HtmlHiLink mkdDelimiter Delimiter +HtmlHiLink mkdEscape Special let b:current_syntax = "mkd" diff --git a/test/escapes.md b/test/escapes.md new file mode 100644 index 00000000..ccec2a03 --- /dev/null +++ b/test/escapes.md @@ -0,0 +1,7 @@ +Escapes: + +text: \\ \` \* \{ \} \[ \] \( \) \# \+ \- \. \! \_ \< \> \~ \| \" \$ \% \& \' \/ \: \; \= \? \@ \^ + +## Header: \\ \` \* \{ \} \[ \] \( \) \# \+ \- \. \! \_ \< \> \~ \| \" \$ \% \& \' \/ \: \; \= \? \@ \^ + +Non Escapes: \a \b \c \f \n \r \t \v \x \o