From 0d3a44116bc9453fb485865873f9f153018c1862 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Tue, 22 Dec 2015 10:31:29 +0900 Subject: [PATCH 1/1] Fix highlighting header title starts with `#` Fix #171 --- syntax/markdown.vim | 12 ++++++------ test/syntax.vader | 13 +++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) 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' -- 2.39.5