From 0aef7317dc7a2c32b5d99a9bcc418ec62b47379f Mon Sep 17 00:00:00 2001 From: michaelPotter Date: Sun, 8 Jan 2017 15:34:46 -0800 Subject: [PATCH 01/16] Add documentation --- README.md | 3 +++ doc/vim-markdown.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 9c6665e..edd177b 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,9 @@ let g:vim_markdown_emphasis_multiline = 0 Concealing is set for some syntax. For example, conceal `[link text](link url)` as just `link text`. +Also, `_italic_` and `*italic*` will conceal to just _italic_. +Similarly `__bold__`, `**bold**`, `___italic bold___`, and `***italic bold***` +will conceal to just __bold__, **bold**, ___italic bold___, and ***italic bold*** respectively. To enable conceal use Vim's standard conceal configuration. diff --git a/doc/vim-markdown.txt b/doc/vim-markdown.txt index eb61653..0d12a1d 100644 --- a/doc/vim-markdown.txt +++ b/doc/vim-markdown.txt @@ -146,6 +146,9 @@ Syntax Concealing ~ Concealing is set for some syntax. For example, conceal '[link text](link url)' as just 'link text'. +Also, '_italic_' and '*italic*' will conceal to just 'italic'. +Similarly '__bold__', '**bold**', '___italic bold___', and '***italic bold***' +will conceal to 'bold', 'bold', 'italic bold', and 'italic bold' respectively. To enable conceal use Vim's standard conceal configuration. > -- 2.39.5 From bb39f5d769c0ed3152f621fd61cc455f1b480918 Mon Sep 17 00:00:00 2001 From: michaelPotter Date: Sun, 8 Jan 2017 15:50:08 -0800 Subject: [PATCH 02/16] Fix leading space as part of ** bold --- syntax/markdown.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index a83ab63..35a1d82 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -52,7 +52,7 @@ syn region mkdBold matchgroup=mkdBold start="\%(\*\*\|__\)" end="\%(\*\*\|__\ syn region mkdBoldItalic matchgroup=mkdBoldItalic start="\%(\*\*\*\|___\)" end="\%(\*\*\*\|___\)" execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs\*\ze[^\\\*\t ]\%(\%([^*]\|\\\*\|\n\)*[^\\\*\t ]\)\?\*\_W" end="[^\\\*\t ]\zs\*\ze\_W" keepend' . s:oneline . s:concealends execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs_\ze[^\\_\t ]" end="[^\\_\t ]\zs_\ze\_W" keepend' . s:oneline . s:concealends -execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\*\*\ze\S" end="\S\zs\*\*" keepend' . s:oneline . s:concealends +execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs\*\*\ze\S" end="\S\zs\*\*" keepend' . s:oneline . s:concealends execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs__\ze\S" end="\S\zs__" keepend' . s:oneline . s:concealends execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs\*\*\*\ze\S" end="\S\zs\*\*\*" keepend' . s:oneline . s:concealends execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs___\ze\S" end="\S\zs___" keepend' . s:oneline . s:concealends -- 2.39.5 From 92fc4617833a7ed201e3066ede3f545286838031 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Wed, 1 Feb 2017 14:26:17 +0900 Subject: [PATCH 03/16] Add -H option for permission errors on travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a913cd7..ab79fcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: | export PATH="/usr/local/bin:$PATH" cd "$TRAVIS_BUILD_DIR" fi - sudo pip install virtualenv + sudo -H pip install virtualenv stty cols 80 script: -- 2.39.5 From d6d59eef6f604b6430fd6adade9e18364666232b Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 2 Feb 2017 17:31:49 +0900 Subject: [PATCH 04/16] Fix error: stty: stdin isn't a terminal on travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ab79fcd..8ea8d3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,6 @@ before_script: | cd "$TRAVIS_BUILD_DIR" fi sudo -H pip install virtualenv - stty cols 80 script: - make test -- 2.39.5 From 9722b92602e9e694b9ea29993fb45fa515a6c89c Mon Sep 17 00:00:00 2001 From: memeplex Date: Sun, 5 Mar 2017 20:48:35 -0300 Subject: [PATCH 05/16] Fix mkdLink highlighting region --- syntax/markdown.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 4602d66..b4eed3c 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -61,7 +61,7 @@ execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]" execute 'syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained oneline' . s:conceal execute 'syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained oneline' . s:conceal -execute 'syn region mkdLink matchgroup=mkdDelimiter start="\\\@ Date: Mon, 6 Mar 2017 16:55:17 +0900 Subject: [PATCH 06/16] Fix last line header folding Fold level should be specified to the last line. Based on the patch by @memeplex Fix #315, #317 --- after/ftplugin/markdown.vim | 8 ++++++-- test/folding.vader | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim index cdf0a26..9ee0100 100644 --- a/after/ftplugin/markdown.vim +++ b/after/ftplugin/markdown.vim @@ -125,7 +125,11 @@ else if l1 =~ '^#' && !s:is_mkdCode(a:lnum) " fold level according to option if s:vim_markdown_folding_level == 1 || matchend(l1, '^#\+') > s:vim_markdown_folding_level - return -1 + if a:lnum == line('$') + return matchend(l1, '^#\+') - 1 + else + return -1 + endif else " headers are not folded return 0 @@ -133,7 +137,7 @@ else endif if l0 =~ '^#' && !s:is_mkdCode(a:lnum-1) - " current line starts with hashes + " previous line starts with hashes return '>'.matchend(l0, '^#\+') else " keep previous foldlevel diff --git a/test/folding.vader b/test/folding.vader index adcae5f..ecf5f9b 100644 --- a/test/folding.vader +++ b/test/folding.vader @@ -36,3 +36,18 @@ Fold Level 2 Execute (fold level ==, --): AssertEqual foldlevel(2), 1, '==' AssertEqual foldlevel(4), 2, '--' + +Given markdown; +# H1 + +## H1.1 + +## H1.2 + +# H2 + +Execute (fold level # in last line): + AssertEqual foldlevel(1), 0, '# H1' + AssertEqual foldlevel(3), 1, '## H1.1' + AssertEqual foldlevel(5), 1, '## H1.2' + AssertEqual foldlevel(7), 0, '# H2' -- 2.39.5 From 0e153a2d2bbec90e383dcea8cbcf3d3449ec08fa Mon Sep 17 00:00:00 2001 From: memeplex Date: Wed, 8 Mar 2017 18:10:54 -0300 Subject: [PATCH 07/16] Fix two line link syntax --- syntax/markdown.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index b4eed3c..13f856d 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -61,7 +61,7 @@ execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]" execute 'syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained oneline' . s:conceal execute 'syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained oneline' . s:conceal -execute 'syn region mkdLink matchgroup=mkdDelimiter start="\\\@ Date: Thu, 9 Mar 2017 14:12:11 +0900 Subject: [PATCH 08/16] Add a test for mkdLink #319 --- test/syntax.vader | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/syntax.vader b/test/syntax.vader index b08a9a0..284e60f 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -413,6 +413,15 @@ Execute (link text with newline): AssertEqual SyntaxOf('b'), 'mkdLink' AssertEqual SyntaxOf('c'), 'mkdURL' +Given markdown; +[a] b [c](d) + +Execute (link text with newline): + AssertNotEqual SyntaxOf('a'), 'mkdLink' + AssertNotEqual SyntaxOf('b'), 'mkdLink' + AssertEqual SyntaxOf('c'), 'mkdLink' + AssertEqual SyntaxOf('d'), 'mkdURL' + Given markdown; (a) -- 2.39.5 From 827e3c42610e36cd78d54ba448438656588543ab Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 9 Mar 2017 14:57:48 +0900 Subject: [PATCH 09/16] Fix test description #319 --- test/syntax.vader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/syntax.vader b/test/syntax.vader index 284e60f..7096ad7 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -416,7 +416,7 @@ Execute (link text with newline): Given markdown; [a] b [c](d) -Execute (link text with newline): +Execute (link text with bracket sections): AssertNotEqual SyntaxOf('a'), 'mkdLink' AssertNotEqual SyntaxOf('b'), 'mkdLink' AssertEqual SyntaxOf('c'), 'mkdLink' -- 2.39.5 From 02d53bbba3becb82a77688ac4f02064f5686aeef Mon Sep 17 00:00:00 2001 From: memeplex Date: Fri, 3 Mar 2017 20:12:41 -0300 Subject: [PATCH 10/16] Don't highlight footnote def as link def --- syntax/markdown.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 13f856d..384c277 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -75,7 +75,7 @@ syn region mkdInlineURL matchgroup=mkdDelimiter start="(\(https\?:\/\/\(\w\+\(: syn region mkdInlineURL matchgroup=mkdDelimiter start="\\\@ ]*>" end=">" " Link definitions: [id]: URL (Optional Title) -syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite +syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[\^\@!" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained -- 2.39.5 From be5cbf1cb72716c5d9daaf19d07fd9ac4ffedfd1 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 9 Mar 2017 15:04:38 +0900 Subject: [PATCH 11/16] Add a test for footnotes #314 --- test/syntax.vader | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/syntax.vader b/test/syntax.vader index 7096ad7..0540155 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -422,6 +422,12 @@ Execute (link text with bracket sections): AssertEqual SyntaxOf('c'), 'mkdLink' AssertEqual SyntaxOf('d'), 'mkdURL' +Given markdown; +[^a]: b + +Execute (footnote is not link): + AssertNotEqual SyntaxOf('a'), 'mkdLinkDef' + Given markdown; (a) -- 2.39.5 From ab8ecf0bc73a792c60ad7a8a303290ccf89aa4e5 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 16 Mar 2017 09:39:28 +0900 Subject: [PATCH 12/16] Update doc for `ge` --- README.md | 4 ++-- doc/vim-markdown.txt | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c626e0a..3f0e8d8 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ let g:vim_markdown_new_list_item_indent = 2 ### Do not require .md extensions for Markdown links -If you want to have a link like this `[link text](link-url)` and follow it for editing in vim using the "ge" command, but have it open the file "link-url.md" instead of the file "link-url", then use this option: +If you want to have a link like this `[link text](link-url)` and follow it for editing in vim using the `ge` command, but have it open the file "link-url.md" instead of the file "link-url", then use this option: ```vim let g:vim_markdown_no_extensions_in_markdown = 1 @@ -241,7 +241,7 @@ Normal behaviour would be that vim-markup required you to do this `[link text](l ### Auto-write when following link -If you follow a link like this `[link text](link-url)` using the "ge" shortcut, this option will automatically save any edits you made before moving you: +If you follow a link like this `[link text](link-url)` using the `ge` shortcut, this option will automatically save any edits you made before moving you: ```vim let g:vim_markdown_autowrite = 1 diff --git a/doc/vim-markdown.txt b/doc/vim-markdown.txt index 3ee30e6..2601da1 100644 --- a/doc/vim-markdown.txt +++ b/doc/vim-markdown.txt @@ -21,6 +21,10 @@ Contents ~ 3. TOML Front Matter |vim-markdown-toml-front-matter| 4. JSON Front Matter |vim-markdown-json-front-matter| 10. Adjust new list item indent |vim-markdown-adjust-new-list-item-indent| + 11. Do not require .md extensions for Markdown links + |vim-markdown-do-not-require-.md-extensions-for-markdown-links| + 12. Auto-write when following link + |vim-markdown-auto-write-when-following-link| 4. Mappings |vim-markdown-mappings| 5. Commands |vim-markdown-commands| 6. Credits |vim-markdown-credits| @@ -96,10 +100,10 @@ To fold in a style like python-mode [6], add the following to your '.vimrc': Level 1 heading which is served as a document title is not folded. 'g:vim_markdown_folding_level' setting is not active with this fold style. -To prevent foldtext from being overridden, add the following to your '.vimrc': - +To prevent foldtext from being set add the following to your '.vimrc': +> let g:vim_markdown_override_foldtext = 0 - +< ------------------------------------------------------------------------------- *vim-markdown-set-header-folding-level* Set header folding level ~ @@ -149,10 +153,10 @@ Syntax Concealing ~ Concealing is set for some syntax. -For example, conceal '[link text](link url)' as just 'link text'. -Also, '_italic_' and '*italic*' will conceal to just 'italic'. -Similarly '__bold__', '**bold**', '___italic bold___', and '***italic bold***' -will conceal to 'bold', 'bold', 'italic bold', and 'italic bold' respectively. +For example, conceal '[link text](link url)' as just 'link text'. Also, +'_italic_' and '*italic*' will conceal to just _italic_. Similarly '__bold__', +'**bold**', '___italic bold___', and '***italic bold***' will conceal to just +**bold**, **bold**, **_italic bold_**, and **_italic bold_** respectively. To enable conceal use Vim's standard conceal configuration. > @@ -244,6 +248,31 @@ of indent is 4. If you'd like to change the number as 2, just write: > let g:vim_markdown_new_list_item_indent = 2 < +------------------------------------------------------------------------------- + *vim-markdown-do-not-require-.md-extensions-for-markdown-links* +Do not require .md extensions for Markdown links ~ + +If you want to have a link like this '[link text](link-url)' and follow it for +editing in vim using the 'ge' command, but have it open the file "link-url.md" +instead of the file "link-url", then use this option: +> + let g:vim_markdown_no_extensions_in_markdown = 1 +< +This is super useful for GitLab and GitHub wiki repositories. + +Normal behaviour would be that vim-markup required you to do this '[link text +](link-url.md)', but this is not how the Gitlab and GitHub wiki repositories +work. So this option adds some consistency between the two. + +------------------------------------------------------------------------------- + *vim-markdown-auto-write-when-following-link* +Auto-write when following link ~ + +If you follow a link like this '[link text](link-url)' using the 'ge' shortcut, +this option will automatically save any edits you made before moving you: +> + let g:vim_markdown_autowrite = 1 +< =============================================================================== *vim-markdown-mappings* Mappings ~ -- 2.39.5 From 7cb6bd72ae0d906395e41e75b193407c76ac3dd5 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 16 Mar 2017 10:50:13 +0900 Subject: [PATCH 13/16] Add tests for `ge` command --- test/ge_test.md | 1 + test/map.vader | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/ge_test.md diff --git a/test/ge_test.md b/test/ge_test.md new file mode 100644 index 0000000..0f5e100 --- /dev/null +++ b/test/ge_test.md @@ -0,0 +1 @@ +ge test diff --git a/test/map.vader b/test/map.vader index 92947f5..7ecdfad 100644 --- a/test/map.vader +++ b/test/map.vader @@ -50,6 +50,45 @@ Execute (gx autolink): AssertEqual b:func(1, match(b:line, ')') + 1), b:url AssertEqual b:func(1, match(b:line, 'd') + 1), '' +Given markdown; +[ge_test.md](ge_test.md) + +Execute (ge opens file): + normal ge + AssertEqual @%, 'ge_test.md' + AssertEqual getline(1), 'ge test' + +Given markdown; +[ge_test](ge_test) + +Execute (ge opens file without .md extensions): + let g:vim_markdown_no_extensions_in_markdown = 1 + normal ge + AssertEqual @%, 'ge_test.md' + AssertEqual getline(1), 'ge test' + unlet g:vim_markdown_no_extensions_in_markdown + +Given markdown; +[ge_test.md](ge_test.md) + +Execute (ge does not write before opening file): + normal ia + normal l + normal ge + AssertEqual @%, 'ge_test.md' + AssertEqual getline(1), 'ge test' + +Given markdown; +[ge_test.md](ge_test.md) + +Execute (ge auto-write before opening file): + let g:vim_markdown_autowrite = 1 + normal ia + normal l + AssertThrows normal ge + AssertEqual g:vader_exception, 'Vim(write):E382: Cannot write, ''buftype'' option is set' + unlet g:vim_markdown_autowrite + Given markdown; # a -- 2.39.5 From 2cd50d2ca657091c6aa787a3847284fb4cceff49 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Thu, 16 Mar 2017 17:25:40 +0900 Subject: [PATCH 14/16] Add document for math conceal #277 --- README.md | 7 +++++++ doc/vim-markdown.txt | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 3f0e8d8..0d03b34 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,13 @@ To disable conceal regardless of `conceallevel` setting, add the following to yo let g:vim_markdown_conceal = 0 ``` +To disable math conceal with LaTeX math syntax enabled, add the following to your `.vimrc`: + +```vim +let g:tex_conceal = "" +let g:vim_markdown_math = 1 +``` + ### Fenced code block languages You can use filetype name as fenced code block languages for syntax highlighting. diff --git a/doc/vim-markdown.txt b/doc/vim-markdown.txt index 2601da1..c6d579e 100644 --- a/doc/vim-markdown.txt +++ b/doc/vim-markdown.txt @@ -167,6 +167,12 @@ your '.vimrc': > let g:vim_markdown_conceal = 0 < +To disable math conceal with LaTeX math syntax enabled, add the following to +your '.vimrc': +> + let g:tex_conceal = "" + let g:vim_markdown_math = 1 +< ------------------------------------------------------------------------------- *vim-markdown-fenced-code-block-languages* Fenced code block languages ~ -- 2.39.5 From 2d1255e76fa298282ef7e1bc25143dcc4e0c3461 Mon Sep 17 00:00:00 2001 From: memeplex Date: Fri, 28 Apr 2017 14:56:38 -0300 Subject: [PATCH 15/16] Skip escaped $ inside math --- syntax/markdown.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 384c277..43cb898 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -143,8 +143,8 @@ endif if get(g:, 'vim_markdown_math', 0) syn include @tex syntax/tex.vim - syn region mkdMath start="\\\@ Date: Mon, 26 Jun 2017 13:49:01 -0400 Subject: [PATCH 16/16] Add support for another extension --- ftplugin/markdown.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index 21c9442..f5d0989 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -586,9 +586,15 @@ if !exists("*s:EditUrlUnderCursor") write endif if get(g:, 'vim_markdown_no_extensions_in_markdown', 0) - execute 'edit' fnamemodify(expand('%:~'), ':p:h').'/'.l:url.'.md' + " use another file extension if preferred + if exists('g:vim_markdown_auto_extension_ext') + let l:ext = '.'.g:vim_markdow_auto_extension_ext + else + let l:ext = '.md' + endif + execute 'edit' fnameescape(fnamemodify(expand('%:~'), ':p:h').'/'.l:url.l:ext) else - execute 'edit' l:url + execute 'edit' fnameescape(l:url) endif else echomsg 'The cursor is not on a link.' -- 2.39.5