Skip to content

Commit

Permalink
Feat: conceal backslash if it is a valid escape code leader
Browse files Browse the repository at this point in the history
This should close preservim#510
  • Loading branch information
flw-cn committed Sep 13, 2020
1 parent 8e5d86f commit 57874cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion syntax/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -177,6 +180,7 @@ HtmlHiLink mkdLinkDef mkdID
HtmlHiLink mkdLinkDefTarget mkdURL
HtmlHiLink mkdLinkTitle htmlString
HtmlHiLink mkdDelimiter Delimiter
HtmlHiLink mkdEscape Special

let b:current_syntax = "mkd"

Expand Down
2 changes: 2 additions & 0 deletions test/escapes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Escapes: \\ \` \* \{ \} \[ \] \( \) \# \+ \- \. \! \_ \< \> \~ \| \" \$ \% \& \' \/ \: \; \= \? \@ \^
Non Escape: \a \b \c \f \n \r \t \v \x \o

0 comments on commit 57874cb

Please sign in to comment.