]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Use tex syntax for inline math
authorSebastian Klatt <sebastian@markow.io>
Thu, 19 Nov 2015 01:04:30 +0000 (02:04 +0100)
committerHiroshi Shirosaki <h.shirosaki@gmail.com>
Tue, 22 Dec 2015 07:48:45 +0000 (16:48 +0900)
* Fix yaml interference
* Add unittest

syntax/markdown.vim
test/syntax.vader

index ebe10f7d69b01198bb96dbb4576c3f05cba4a309..9041ab17a3c686e26bf4cac7822d8903f3d3e557 100644 (file)
@@ -96,17 +96,18 @@ syn region htmlH6       start="^\s*######"              end="$" contains=@Spell
 syn match  htmlH1       /^.\+\n=\+$/ contains=@Spell
 syn match  htmlH2       /^.\+\n-\+$/ contains=@Spell
 
 syn match  htmlH1       /^.\+\n=\+$/ contains=@Spell
 syn match  htmlH2       /^.\+\n-\+$/ contains=@Spell
 
-if get(g:, 'vim_markdown_math', 0)
-  syn region mkdMath matchgroup=mkdDelimiter start="\\\@<!\$" end="\$"
-  syn region mkdMath matchgroup=mkdDelimiter start="\\\@<!\$\$" end="\$\$"
-endif
-
 " YAML frontmatter
 if get(g:, 'vim_markdown_frontmatter', 0)
   syn include @yamlTop syntax/yaml.vim
   syn region Comment matchgroup=mkdDelimiter start="\%^---$" end="^---$" contains=@yamlTop
 endif
 
 " YAML frontmatter
 if get(g:, 'vim_markdown_frontmatter', 0)
   syn include @yamlTop syntax/yaml.vim
   syn region Comment matchgroup=mkdDelimiter start="\%^---$" end="^---$" contains=@yamlTop
 endif
 
+if get(g:, 'vim_markdown_math', 0)
+  syn include @tex syntax/tex.vim
+  syn region mkdMath matchgroup=mkdDelimiter start="\\\@<!\$" end="\$" contains=@tex
+  syn region mkdMath matchgroup=mkdDelimiter start="\\\@<!\$\$" end="\$\$" contains=@tex
+endif
+
 syn cluster mkdNonListItem contains=htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdIndentCode,mkdListItem,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath
 
 "highlighting for Markdown groups
 syn cluster mkdNonListItem contains=htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdIndentCode,mkdListItem,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath
 
 "highlighting for Markdown groups
index 4ce40ffc833feb990b2f9fa4a75e08986eac7df6..6ad8907ae04353ecd8d473a044e6ce50f62b4f4d 100644 (file)
@@ -197,6 +197,18 @@ Execute (multiline math):
   AssertEqual SyntaxOf('b'), 'mkdMath'
   AssertNotEqual SyntaxOf('c'), 'mkdMath'
 
   AssertEqual SyntaxOf('b'), 'mkdMath'
   AssertNotEqual SyntaxOf('c'), 'mkdMath'
 
+Given markdown;
+$ \sqrt{a}{b} $
+$$ \sqrt{a}{b} $$
+
+Execute (math tex highlighting):
+  let g:vim_markdown_math=0
+  syn off | syn on
+  AssertNotEqual SyntaxOf('a'), 'texMatcher'
+  let g:vim_markdown_math=1
+  syn off | syn on
+  AssertEqual SyntaxOf('a'), 'texMatcher'
+
 # YAML frontmatter
 
 Given markdown;
 # YAML frontmatter
 
 Given markdown;