From 57b25a55fe71fcd39bc5f2b70c710dd426a687a3 Mon Sep 17 00:00:00 2001 From: Levi Gruspe Date: Wed, 20 Sep 2023 14:16:37 +0800 Subject: [PATCH] Todo highlighting in html comments --- syntax/markdown.vim | 2 ++ test/syntax.vader | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 4d54d3c3..2835e284 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -116,6 +116,7 @@ syn region mkdNonListItemBlock start="\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\( 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\)*$/ +syn keyword mkdTodo TODO FIXME XXX TBD contained containedin=htmlComment,htmlCommentPart " YAML frontmatter if get(g:, 'vim_markdown_frontmatter', 0) @@ -179,6 +180,7 @@ HtmlHiLink mkdLinkDef mkdID HtmlHiLink mkdLinkDefTarget mkdURL HtmlHiLink mkdLinkTitle htmlString HtmlHiLink mkdDelimiter Delimiter +HtmlHiLink mkdTodo Todo let b:current_syntax = 'mkd' diff --git a/test/syntax.vader b/test/syntax.vader index 3d1a9911..2f8e8f39 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -1302,3 +1302,40 @@ Execute (HTML tag in text): AssertEqual SyntaxOf('span'), 'htmlTagName' AssertEqual SyntaxOf(''), 'htmlTag' AssertEqual SyntaxOf(''), 'htmlEndTag' + +Given markdown; + + +Execute (todo inside HTML comment): + AssertEqual SyntaxOf('TODO'), 'mkdTodo' + AssertEqual SyntaxOf('FIXME'), 'mkdTodo' + AssertEqual SyntaxOf('XXX'), 'mkdTodo' + AssertEqual SyntaxOf('TBD'), 'mkdTodo' + AssertNotEqual SyntaxOf('hello'), 'mkdTodo' + +Given markdown; + + +Execute (fake todo inside HTML comment): + AssertNotEqual SyntaxOf('TODO'), 'mkdTodo' + AssertNotEqual SyntaxOf('FIXME'), 'mkdTodo' + AssertNotEqual SyntaxOf('XXX'), 'mkdTodo' + AssertNotEqual SyntaxOf('TBD'), 'mkdTodo' + +Given markdown; +TODO FIXME XXX TBD + +Execute (todo outside HTML comment): + AssertNotEqual SyntaxOf('TODO'), 'mkdTodo' + AssertNotEqual SyntaxOf('FIXME'), 'mkdTodo' + AssertNotEqual SyntaxOf('XXX'), 'mkdTodo' + AssertNotEqual SyntaxOf('TBD'), 'mkdTodo' + +Given markdown; +> TODO FIXME XXX TBD + +Execute (todo inside non-HTML comment): + AssertNotEqual SyntaxOf('TODO'), 'mkdTodo' + AssertNotEqual SyntaxOf('FIXME'), 'mkdTodo' + AssertNotEqual SyntaxOf('XXX'), 'mkdTodo' + AssertNotEqual SyntaxOf('TBD'), 'mkdTodo'