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

Merge pull request #397 from sim590/inexact-ft-match-syntax-hl
authorHiroshi Shirosaki <h.shirosaki@gmail.com>
Thu, 17 Jan 2019 05:24:45 +0000 (14:24 +0900)
committerGitHub <noreply@github.com>
Thu, 17 Jan 2019 05:24:45 +0000 (14:24 +0900)
ftplugin: syntax highlighting for fts *markdown*

README.md
doc/vim-markdown.txt
ftdetect/markdown.vim
ftplugin/markdown.vim
syntax/markdown.vim
test/syntax.vader

index 982248e299a32b8aa4d6687ceb688e8b591e67f7..25b708786e66b8b917c820254b7df2417af6da4e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -277,6 +277,14 @@ JSON syntax highlight requires [vim-json](https://github.com/elzr/vim-json).
 let g:vim_markdown_json_frontmatter = 1
 ```
 
+#### Strikethrough
+
+Strikethrough uses two tildes. `~~Scratch this.~~`
+
+```vim
+let g:vim_markdown_strikethrough = 1
+```
+
 ### Adjust new list item indent
 
 You can adjust a new list indent. For example, you insert a single line like below:
index 29ed66ddc5f7940de3f647cd4b26a8a225ef488f..1e81ea2e7695d2f60b9e33cd7ca708036a756224 100644 (file)
@@ -24,6 +24,7 @@ Contents ~
    2. YAML Front Matter                        |vim-markdown-yaml-front-matter|
    3. TOML Front Matter                        |vim-markdown-toml-front-matter|
    4. JSON Front Matter                        |vim-markdown-json-front-matter|
+   5. Strikethrough                                |vim-markdown-strikethrough|
   11. Adjust new list item indent    |vim-markdown-adjust-new-list-item-indent|
   12. Do not require .md extensions for Markdown links
                 |vim-markdown-do-not-require-.md-extensions-for-markdown-links|
@@ -318,6 +319,14 @@ JSON syntax highlight requires vim-json [9].
 >
   let g:vim_markdown_json_frontmatter = 1
 <
+-------------------------------------------------------------------------------
+                                                   *vim-markdown-strikethrough*
+Strikethrough ~
+
+Strikethrough uses two tildes. '~~Scratch this.~~'
+>
+  let g:vim_markdown_strikethrough = 1
+<
 -------------------------------------------------------------------------------
                                      *vim-markdown-adjust-new-list-item-indent*
 Adjust new list item indent ~
index 611ecaa0d0cf8331ea4c6b8047f62657bb04a20a..07682da4cd5da623e60725215198c89f5bda7411 100644 (file)
@@ -1,3 +1,8 @@
+if !has('patch-7.4.480')
+    " Before this patch, vim used modula2 for .md.
+    au! filetypedetect BufRead,BufNewFile *.md
+endif
+
 " markdown filetype file
-au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown
-au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set filetype=markdown
+au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} setfiletype markdown
+au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} setfiletype markdown
index 2c83000e43f06737ae4e220eb7b64c9b8471289b..989aef83bd356bd2129c6297d7be44744cd104a5 100644 (file)
@@ -734,7 +734,7 @@ function! s:MarkdownHighlightSources(force)
                 let include = '@' . toupper(filetype)
             endif
             let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s'
-            execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) ? ' concealends' : '')
+            execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
             execute printf('syntax cluster mkdNonListItem add=%s', group)
 
             let b:mkd_known_filetypes[ft] = 1
index 5056af482dd7692b29cd35d05fcf4928e1a61601..d0077a4134843381d61ebbdf46202ae3d518e290 100644 (file)
@@ -36,10 +36,14 @@ syn sync linebreaks=1
 
 let s:conceal = ''
 let s:concealends = ''
+let s:concealcode = ''
 if has('conceal') && get(g:, 'vim_markdown_conceal', 1)
   let s:conceal = ' conceal'
   let s:concealends = ' concealends'
 endif
+if has('conceal') && get(g:, 'vim_markdown_conceal_code_blocks', 1)
+  let s:concealcode = ' concealends'
+endif
 
 " additions to HTML groups
 if get(g:, 'vim_markdown_emphasis_multiline', 1)
@@ -94,13 +98,13 @@ syn match  htmlH2       /^.\+\n-\+$/ contains=mkdLink,mkdInlineURL,@Spell
 "define Markdown groups
 syn match  mkdLineBreak    /  \+$/
 syn region mkdBlockquote   start=/^\s*>/                   end=/$/ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!`/                     end=/\(\([^\\]\|^\)\\\)\@<!`/'  . s:concealends
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!``/ skip=/[^`]`[^`]/   end=/\(\([^\\]\|^\)\\\)\@<!``/' . s:concealends
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(`\{3,}\)[^`]*$/                       end=/^\s*\z1`*\s*$/'            . s:concealends
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!\~\~/  end=/\(\([^\\]\|^\)\\\)\@<!\~\~/'               . s:concealends
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(\~\{3,}\)\s*[0-9A-Za-z_+-]*\s*$/      end=/^\s*\z1\~*\s*$/'           . s:concealends
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<pre[^>]*\\\@<!>"                            end="</pre>"'                   . s:concealends
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<code[^>]*\\\@<!>"                           end="</code>"'                  . s:concealends
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!`/                     end=/`/'  . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!``/ skip=/[^`]`[^`]/   end=/\(\([^\\]\|^\)\\\)\@<!``/' . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(`\{3,}\)[^`]*$/                       end=/^\s*\z1`*\s*$/'            . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!\~\~/  end=/\(\([^\\]\|^\)\\\)\@<!\~\~/'               . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(\~\{3,}\)\s*[0-9A-Za-z_+-]*\s*$/      end=/^\s*\z1\~*\s*$/'           . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<pre[^>]*\\\@<!>"                            end="</pre>"'                   . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<code[^>]*\\\@<!>"                           end="</code>"'                  . s:concealcode
 syn region mkdFootnote     start="\[^"                     end="\]"
 syn match  mkdCode         /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/
 syn match  mkdCode         /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/
@@ -145,6 +149,12 @@ if get(g:, 'vim_markdown_math', 0)
   syn region mkdMath start="\\\@<!\$\$" end="\$\$" skip="\\\$" contains=@tex keepend
 endif
 
+" Strike through
+if get(g:, 'vim_markdown_strikethrough', 0)
+    syn region mkdStrike matchgroup=mkdStrike start="\%(\~\~\)"    end="\%(\~\~\)"
+    HtmlHiLink mkdStrike        htmlStrike
+endif
+
 syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath
 
 "highlighting for Markdown groups
index fdf9c0be4dac25a3babd4ab3bbb9c8d52482aca2..3baa41f61980468b9bb45f5ad5ed211b707e7d14 100644 (file)
@@ -882,6 +882,23 @@ a
 Execute (not code block in escaped code tag):
   AssertNotEqual SyntaxOf('a'), 'mkdCode'
 
+# Code quotes
+
+Given markdown;
+`a`
+
+Execute (code in code quotes):
+  AssertEqual SyntaxOf('a'), 'mkdCode'
+
+Given markdown;
+`a\` b `c\` d
+
+Execute (code quotes not escaped ending with backslash):
+  AssertEqual SyntaxOf('a\'), 'mkdCode'
+  AssertNotEqual SyntaxOf('b'), 'mkdCode'
+  AssertEqual SyntaxOf('c\'), 'mkdCode'
+  AssertNotEqual SyntaxOf('d'), 'mkdCode'
+
 # Math
 
 Given markdown;