]> 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:

Fix indent code block and add tests
authorHiroshi Shirosaki <h.shirosaki@gmail.com>
Sat, 9 Jan 2016 05:08:09 +0000 (14:08 +0900)
committerHiroshi Shirosaki <h.shirosaki@gmail.com>
Sat, 9 Jan 2016 05:15:46 +0000 (14:15 +0900)
`mkdIndentCode` is renamed to `mkdCode` because there is no need
to distinguish them.
We fixed a bug that indent code block at the start of a file is
not highlighted.

syntax/markdown.vim
test/syntax.vader

index fc036c6c97e6dc0081fddeca928c7b27cfa87d65..035199b078d7ecef824a136f7eaebbfab5c53805 100644 (file)
@@ -79,9 +79,9 @@ syn region mkdCode         start="<pre[^>]*>"              end="</pre>"
 syn region mkdCode         start="<code[^>]*>"             end="</code>"
 syn region mkdFootnote     start="\[^"                     end="\]"
 syn match  mkdCode         /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/
-syn match  mkdIndentCode   /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained
+syn match  mkdCode         /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained
 syn region mkdListItemLine matchgroup=mkdListItem start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" contains=@mkdNonListItem,@Spell
-syn region mkdNonListItemBlock start="\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell
+syn region mkdNonListItemBlock start="\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!\)" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell
 syn match  mkdRule         /^\s*\*\s\{0,1}\*\s\{0,1}\*$/
 syn match  mkdRule         /^\s*-\s\{0,1}-\s\{0,1}-$/
 syn match  mkdRule         /^\s*_\s\{0,1}_\s\{0,1}_$/
@@ -110,12 +110,11 @@ if get(g:, 'vim_markdown_math', 0)
   syn region mkdMath matchgroup=mkdDelimiter start="\\\@<!\$\$" end="\$\$" contains=@tex
 endif
 
-syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdIndentCode,mkdListItem,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath
+syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdListItem,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath
 
 "highlighting for Markdown groups
 HtmlHiLink mkdString        String
 HtmlHiLink mkdCode          String
-HtmlHiLink mkdIndentCode    String
 HtmlHiLink mkdFootnote      Comment
 HtmlHiLink mkdBlockquote    Comment
 HtmlHiLink mkdLineContinue  Comment
index 21d92bfb9e1973322eb597cf83ceca67b4707fc6..fb92ba81aa06af2739b69b97942e9484b7e2bc69 100644 (file)
@@ -86,7 +86,8 @@ Given markdown;
 [a](b) c [d](e)
 
 Execute (multiple links on a line):
-  AssertEqual SyntaxOf('c'), ''
+  AssertNotEqual SyntaxOf('c'), 'mkdLink'
+  AssertNotEqual SyntaxOf('c'), 'mkdURL'
 
 # Autolinks
 
@@ -185,6 +186,43 @@ Execute (code blocks can be fenced with backticks and a language specifier):
   AssertEqual SyntaxOf('code'), 'mkdCode'
   AssertNotEqual SyntaxOf('text'), 'mkdCode'
 
+# Indent Code Blocks
+
+Given markdown;
+a
+
+    b
+    c
+
+Execute (indent code blocks):
+  AssertNotEqual SyntaxOf('a'), 'mkdCode'
+  AssertEqual SyntaxOf('b'), 'mkdCode'
+  AssertEqual SyntaxOf('c'), 'mkdCode'
+
+Given markdown;
+# a
+
+b
+
+    c
+
+Execute (indent code blocks after header):
+  AssertNotEqual SyntaxOf('a'), 'mkdCode'
+  AssertNotEqual SyntaxOf('b'), 'mkdCode'
+  AssertEqual SyntaxOf('c'), 'mkdCode'
+
+Given markdown;
+-   a
+
+    b
+
+        c
+
+Execute (indent code blocks after list):
+  AssertNotEqual SyntaxOf('a'), 'mkdCode'
+  AssertNotEqual SyntaxOf('b'), 'mkdCode'
+  AssertEqual SyntaxOf('c'), 'mkdCode'
+
 # Math
 
 Given markdown;