From: Hiroshi Shirosaki Date: Tue, 22 Dec 2015 01:31:29 +0000 (+0900) Subject: Fix highlighting header title starts with `#` X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/0d3a44116bc9453fb485865873f9f153018c1862?ds=inline Fix highlighting header title starts with `#` Fix #171 --- diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 70f7a0d..ebe10f7 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -87,12 +87,12 @@ syn match mkdRule /^\s*-\{3,}$/ syn match mkdRule /^\s*\*\{3,5}$/ "HTML headings -syn region htmlH1 start="^\s*#" end="\($\|#\+\)" contains=@Spell -syn region htmlH2 start="^\s*##" end="\($\|#\+\)" contains=@Spell -syn region htmlH3 start="^\s*###" end="\($\|#\+\)" contains=@Spell -syn region htmlH4 start="^\s*####" end="\($\|#\+\)" contains=@Spell -syn region htmlH5 start="^\s*#####" end="\($\|#\+\)" contains=@Spell -syn region htmlH6 start="^\s*######" end="\($\|#\+\)" contains=@Spell +syn region htmlH1 start="^\s*#" end="$" contains=@Spell +syn region htmlH2 start="^\s*##" end="$" contains=@Spell +syn region htmlH3 start="^\s*###" end="$" contains=@Spell +syn region htmlH4 start="^\s*####" end="$" contains=@Spell +syn region htmlH5 start="^\s*#####" end="$" contains=@Spell +syn region htmlH6 start="^\s*######" end="$" contains=@Spell syn match htmlH1 /^.\+\n=\+$/ contains=@Spell syn match htmlH2 /^.\+\n-\+$/ contains=@Spell diff --git a/test/syntax.vader b/test/syntax.vader index 607a153..4ce40ff 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -235,3 +235,16 @@ Execute (rules are not mistaken by YAML frontmatter delimiters): let g:vim_markdown_frontmatter=1 syn off | syn on AssertEqual SyntaxAt(5, 1), 'mkdRule' + +# Header + +Given markdown; +# #a +ccc + +## #b +ddd + +Execute (header title starts with #): + AssertEqual SyntaxOf('a'), 'htmlH1' + AssertEqual SyntaxOf('b'), 'htmlH2'