mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins and added vim-markdown
This commit is contained in:
5
sources_non_forked/vim-markdown/test/README.md
Normal file
5
sources_non_forked/vim-markdown/test/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
You can run the tests using the Makefile from the top directory:
|
||||
|
||||
make test
|
||||
|
||||
To run them manually please refer to the instructions/commands in the Makefile.
|
178
sources_non_forked/vim-markdown/test/folding-toc.vader
Normal file
178
sources_non_forked/vim-markdown/test/folding-toc.vader
Normal file
@ -0,0 +1,178 @@
|
||||
" Tests atx and setext folding, and :Toc.
|
||||
|
||||
Before:
|
||||
source ../after/ftplugin/markdown.vim
|
||||
|
||||
After:
|
||||
setlocal foldexpr=0
|
||||
setlocal foldmethod=manual
|
||||
|
||||
Given markdown;
|
||||
# chap 1
|
||||
|
||||
hello
|
||||
world
|
||||
|
||||
```bash
|
||||
# some bash scripting
|
||||
pwd
|
||||
|
||||
# this is another comment
|
||||
# other
|
||||
echo "foo"
|
||||
```
|
||||
|
||||
## chap 1.1
|
||||
|
||||
- dog
|
||||
- cat
|
||||
|
||||
~~~~bash
|
||||
mkdir foo
|
||||
# comment in ~
|
||||
~~~~
|
||||
|
||||
### chap 1.1.1
|
||||
|
||||
- dragons
|
||||
- fenixs
|
||||
|
||||
# chap 2
|
||||
|
||||
another
|
||||
|
||||
## chap 2.1
|
||||
|
||||
- uk
|
||||
- japan
|
||||
- china
|
||||
|
||||
|
||||
# chap 3
|
||||
|
||||
nothing here
|
||||
|
||||
chap 4
|
||||
======
|
||||
|
||||
setext are evil
|
||||
|
||||
chap 4.1
|
||||
--------
|
||||
|
||||
evil indeed
|
||||
|
||||
````bash
|
||||
# get system info
|
||||
uname -a
|
||||
````
|
||||
|
||||
Execute (fold level):
|
||||
AssertEqual foldlevel(1), 0, '# chap 1'
|
||||
AssertEqual foldlevel(3), 1, 'hello'
|
||||
AssertEqual foldlevel(6), 1, '```bash'
|
||||
AssertEqual foldlevel(7), 1, '# some bash scripting'
|
||||
AssertEqual foldlevel(15), 1, '## chap 1.1'
|
||||
AssertEqual foldlevel(21), 2, 'mkdir foo'
|
||||
AssertEqual foldlevel(22), 2, 'comment in ~'
|
||||
AssertEqual foldlevel(25), 2, '### chap 1.1.1'
|
||||
AssertEqual foldlevel(27), 3, '- dragons'
|
||||
AssertEqual foldlevel(30), 1, '# chap 2'
|
||||
AssertEqual foldlevel(32), 1, 'another'
|
||||
AssertEqual foldlevel(34), 1, '# chap 2.1'
|
||||
AssertEqual foldlevel(37), 2, '- japan'
|
||||
AssertEqual foldlevel(41), 1, '# chap 3'
|
||||
AssertEqual foldlevel(45), 1, 'chap 4\n======'
|
||||
AssertEqual foldlevel(48), 1, 'setext are evil'
|
||||
AssertEqual foldlevel(50), 2, 'chap 4.1\n------'
|
||||
|
||||
Execute (fold text result):
|
||||
AssertEqual foldtextresult(2), '+-- 28 lines: hello'
|
||||
AssertEqual foldtextresult(31), '+-- 10 lines: another'
|
||||
AssertEqual foldtextresult(42), '+-- 3 lines: nothing here'
|
||||
AssertEqual foldtextresult(45), '+-- 14 lines: chap 4'
|
||||
|
||||
Execute (fold level with setting):
|
||||
let g:vim_markdown_folding_level = 2
|
||||
source ../after/ftplugin/markdown.vim
|
||||
AssertEqual foldlevel(1), 0, '# chap 1'
|
||||
AssertEqual foldlevel(3), 1, 'hello'
|
||||
AssertEqual foldlevel(6), 1, '```bash'
|
||||
AssertEqual foldlevel(7), 1, '# some bash scripting'
|
||||
AssertEqual foldlevel(15), 0, '## chap 1.1'
|
||||
AssertEqual foldlevel(21), 2, 'mkdir foo'
|
||||
AssertEqual foldlevel(22), 2, 'comment in ~'
|
||||
AssertEqual foldlevel(25), 2, '### chap 1.1.1'
|
||||
AssertEqual foldlevel(27), 3, '- dragons'
|
||||
AssertEqual foldlevel(30), 0, '# chap 2'
|
||||
AssertEqual foldlevel(32), 1, 'another'
|
||||
AssertEqual foldlevel(34), 0, '# chap 2.1'
|
||||
AssertEqual foldlevel(37), 2, '- japan'
|
||||
AssertEqual foldlevel(41), 0, '# chap 3'
|
||||
AssertEqual foldlevel(45), 1, 'chap 4\n======'
|
||||
AssertEqual foldlevel(48), 1, 'setext are evil'
|
||||
AssertEqual foldlevel(50), 1, 'chap 4.1\n------'
|
||||
let g:vim_markdown_folding_level = 0
|
||||
|
||||
Execute (check TOC):
|
||||
:Toc
|
||||
:lclose
|
||||
let res = getloclist(0)
|
||||
let elem = res[0]
|
||||
AssertEqual elem.lnum, 1
|
||||
AssertEqual elem.text, '# chap 1'
|
||||
let elem = res[1]
|
||||
AssertEqual elem.lnum, 15
|
||||
AssertEqual elem.text, '## chap 1.1'
|
||||
let elem = res[2]
|
||||
AssertEqual elem.lnum, 25
|
||||
AssertEqual elem.text, '### chap 1.1.1'
|
||||
let elem = res[3]
|
||||
AssertEqual elem.lnum, 30
|
||||
AssertEqual elem.text, '# chap 2'
|
||||
let elem = res[4]
|
||||
AssertEqual elem.lnum, 34
|
||||
AssertEqual elem.text, '## chap 2.1'
|
||||
let elem = res[5]
|
||||
AssertEqual elem.lnum, 41
|
||||
AssertEqual elem.text, '# chap 3'
|
||||
let elem = res[6]
|
||||
AssertEqual elem.lnum, 45
|
||||
AssertEqual elem.text, 'chap 4'
|
||||
let elem = res[7]
|
||||
AssertEqual elem.lnum, 50
|
||||
AssertEqual elem.text, 'chap 4.1'
|
||||
|
||||
Given markdown;
|
||||
---
|
||||
layout: article
|
||||
title: A test of the heading folding when there is YAML frontmatter
|
||||
tags: markdown yaml vim-markdown
|
||||
---
|
||||
body
|
||||
|
||||
heading
|
||||
-------
|
||||
|
||||
Execute (fold level of yaml front matter):
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
source ../after/ftplugin/markdown.vim
|
||||
AssertEqual foldlevel(1), 0, '---'
|
||||
AssertEqual foldlevel(2), 0, 'layout: article'
|
||||
AssertEqual foldlevel(4), 0, 'tags: markdown yaml vim-markdown'
|
||||
AssertEqual foldlevel(5), 0, '---'
|
||||
AssertEqual foldlevel(6), 0, 'body'
|
||||
AssertEqual foldlevel(8), 2, 'heading'
|
||||
AssertEqual foldlevel(9), 2, '-------'
|
||||
unlet g:vim_markdown_frontmatter
|
||||
|
||||
Execute (check Toc of yaml front matter):
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
:Toc
|
||||
:lclose
|
||||
let res = getloclist(0)
|
||||
AssertEqual len(res), 1
|
||||
let elem = res[0]
|
||||
AssertEqual elem.lnum, 8
|
||||
AssertEqual elem.text, 'heading'
|
||||
unlet g:vim_markdown_frontmatter
|
53
sources_non_forked/vim-markdown/test/folding.vader
Normal file
53
sources_non_forked/vim-markdown/test/folding.vader
Normal file
@ -0,0 +1,53 @@
|
||||
Before:
|
||||
source ../after/ftplugin/markdown.vim
|
||||
|
||||
After:
|
||||
setlocal foldexpr=0
|
||||
setlocal foldmethod=manual
|
||||
|
||||
Given markdown;
|
||||
# Title
|
||||
|
||||
## Chapter 1
|
||||
|
||||
```
|
||||
This is code block
|
||||
# This is just a comment
|
||||
```
|
||||
|
||||
## Capter 2
|
||||
|
||||
foobar
|
||||
|
||||
Execute (fold level # in code block):
|
||||
AssertEqual foldlevel(1), 0, '# Title'
|
||||
AssertEqual foldlevel(3), 1, '## Chapter 1'
|
||||
AssertEqual foldlevel(7), 2, '# This is just a comment'
|
||||
AssertEqual foldlevel(8), 2, '```'
|
||||
AssertEqual foldlevel(10), 1, '## Chapter 2'
|
||||
AssertEqual foldlevel(12), 2, 'foobar'
|
||||
|
||||
Given markdown;
|
||||
Fold Level 1
|
||||
============
|
||||
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'
|
1
sources_non_forked/vim-markdown/test/ge_test.md
Normal file
1
sources_non_forked/vim-markdown/test/ge_test.md
Normal file
@ -0,0 +1 @@
|
||||
ge test
|
@ -0,0 +1,15 @@
|
||||
Before:
|
||||
let g:vim_markdown_new_list_item_indent = 2
|
||||
|
||||
After:
|
||||
unlet g:vim_markdown_new_list_item_indent
|
||||
|
||||
Given markdown;
|
||||
* item1
|
||||
|
||||
Do (new line from the first item of the list and add the second item):
|
||||
o* item2
|
||||
|
||||
Expect (insert 2 spaces to the head of second item):
|
||||
* item1
|
||||
* item2
|
26
sources_non_forked/vim-markdown/test/indent.md
Normal file
26
sources_non_forked/vim-markdown/test/indent.md
Normal file
@ -0,0 +1,26 @@
|
||||
1. Confirm indent with new line insert after list items
|
||||
|
||||
'\' is not list item.
|
||||
\ foo
|
||||
|
||||
If only space and three '*' or '-' character are in the line,
|
||||
this line means horizontal item.
|
||||
If current line is below horizontal item, it need not to indent.
|
||||
Following example is horizontal item.
|
||||
|
||||
---
|
||||
***
|
||||
- - -
|
||||
* * *
|
||||
|
||||
And list item must be specified space after [*-+].
|
||||
Following example is list item.
|
||||
|
||||
* foo
|
||||
- bar
|
||||
+ baz
|
||||
|
||||
But following example is not list item.
|
||||
*foo
|
||||
-bar
|
||||
+baz
|
73
sources_non_forked/vim-markdown/test/indent.vader
Normal file
73
sources_non_forked/vim-markdown/test/indent.vader
Normal file
@ -0,0 +1,73 @@
|
||||
Given markdown;
|
||||
* item1
|
||||
|
||||
Do (insert enter at list end):
|
||||
A\<cr>item2
|
||||
|
||||
Expect (auto insert * and indent level is same):
|
||||
* item1
|
||||
* item2
|
||||
|
||||
Given markdown;
|
||||
|
||||
Execute:
|
||||
syntax off
|
||||
|
||||
Do (insert enter at list end with syntax off):
|
||||
i* item1\<cr>item2
|
||||
|
||||
Expect (auto insert * and indent level is same):
|
||||
* item1
|
||||
* item2
|
||||
|
||||
Execute:
|
||||
syntax on
|
||||
|
||||
Given markdown;
|
||||
```
|
||||
* item1
|
||||
|
||||
Do (insert after list items in code block):
|
||||
jotext
|
||||
|
||||
Expect (no autoindent in code block):
|
||||
```
|
||||
* item1
|
||||
text
|
||||
|
||||
Given markdown;
|
||||
* item1
|
||||
|
||||
a
|
||||
|
||||
Do (insert enter after list):
|
||||
jji\<cr>b
|
||||
|
||||
Expect (no autoindent outside list):
|
||||
* item1
|
||||
|
||||
|
||||
ba
|
||||
|
||||
Given markdown;
|
||||
- a
|
||||
|
||||
# b
|
||||
|
||||
Do (insert header after list):
|
||||
jjwi#
|
||||
|
||||
Expect (no indent header after list):
|
||||
- a
|
||||
|
||||
## b
|
||||
|
||||
Given markdown;
|
||||
* item1
|
||||
|
||||
Do (new line from the first item of the list and add the second item):
|
||||
o* item2
|
||||
|
||||
Expect (insert 4 spaces to the head of second item):
|
||||
* item1
|
||||
* item2
|
153
sources_non_forked/vim-markdown/test/map.vader
Normal file
153
sources_non_forked/vim-markdown/test/map.vader
Normal file
@ -0,0 +1,153 @@
|
||||
Given markdown;
|
||||
a <http://b> c
|
||||
|
||||
Execute (gx autolink):
|
||||
let b:url = 'http://b'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, '<') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, '>') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), ''
|
||||
|
||||
Given markdown;
|
||||
a http://b.bb c
|
||||
|
||||
Execute (gx implicit autolink):
|
||||
let b:url = 'http://b.bb'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), ''
|
||||
|
||||
Given markdown;
|
||||
[a]: http://b "c"
|
||||
|
||||
Execute (gx link reference definition):
|
||||
let b:url = 'http://b'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
" TODO would be cool if all of the following gave the link.
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), ''
|
||||
|
||||
Given markdown;
|
||||
a [b](c) d
|
||||
|
||||
Execute (gx autolink):
|
||||
let b:url = 'c'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, '[') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'b') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, ']') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, '(') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), b:url
|
||||
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
|
||||
|
||||
b
|
||||
|
||||
# c
|
||||
|
||||
d
|
||||
|
||||
Execute (]] same level):
|
||||
AssertEqual line('.'), 1
|
||||
normal ]]
|
||||
AssertEqual line('.'), 5
|
||||
normal [[
|
||||
AssertEqual line('.'), 1
|
||||
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
b
|
||||
|
||||
## c
|
||||
|
||||
d
|
||||
|
||||
Execute (]] different levels level):
|
||||
AssertEqual line('.'), 1
|
||||
normal ]]
|
||||
AssertEqual line('.'), 5
|
||||
normal [[
|
||||
AssertEqual line('.'), 1
|
||||
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
b
|
||||
|
||||
## c
|
||||
|
||||
d
|
||||
|
||||
# e
|
||||
|
||||
f
|
||||
|
||||
Execute (][ different levels level):
|
||||
AssertEqual line('.'), 1
|
||||
normal ][
|
||||
AssertEqual line('.'), 9
|
||||
normal []
|
||||
AssertEqual line('.'), 1
|
||||
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
b
|
||||
|
||||
Execute (]c):
|
||||
normal! 3G
|
||||
AssertEqual line('.'), 3
|
||||
normal ]c
|
||||
AssertEqual line('.'), 1
|
85
sources_non_forked/vim-markdown/test/python-folding.vader
Normal file
85
sources_non_forked/vim-markdown/test/python-folding.vader
Normal file
@ -0,0 +1,85 @@
|
||||
Before:
|
||||
let g:vim_markdown_folding_style_pythonic = 1
|
||||
source ../after/ftplugin/markdown.vim
|
||||
|
||||
After:
|
||||
setlocal foldexpr=0
|
||||
setlocal foldmethod=manual
|
||||
|
||||
Given markdown;
|
||||
# Title
|
||||
|
||||
## Chapter 1
|
||||
|
||||
```
|
||||
This is code block
|
||||
# This is just a comment
|
||||
```
|
||||
|
||||
## Chapter 2
|
||||
|
||||
foobar
|
||||
|
||||
Execute (fold level # in code block):
|
||||
AssertEqual foldlevel(1), 0, '# Title'
|
||||
AssertEqual foldlevel(3), 1, '## Chapter 1'
|
||||
AssertEqual foldlevel(7), 1, '# This is just a comment'
|
||||
AssertEqual foldlevel(8), 1, '```'
|
||||
AssertEqual foldlevel(10), 1, '## Chapter 2'
|
||||
AssertEqual foldlevel(12), 1, 'foobar'
|
||||
|
||||
Execute (fold text of chapters):
|
||||
let b:width = winwidth(0)
|
||||
let b:hyphen = repeat('-', b:width - 18 > 2 ? b:width - 18 : b:width - 9 > 0 ? 3 : 2)
|
||||
AssertEqual foldtextresult(3), strpart('## Chapter 1', 0, b:width - 9) . ' ' . b:hyphen . ' 6'
|
||||
AssertEqual foldtextresult(10), strpart('## Chapter 2', 0, b:width - 9) . ' ' . b:hyphen . ' 2'
|
||||
|
||||
Given markdown;
|
||||
Fold text 1
|
||||
===========
|
||||
Fold text 2
|
||||
-----------
|
||||
|
||||
Execute (fold level ==, --):
|
||||
AssertEqual foldlevel(2), 0, '=='
|
||||
AssertEqual foldlevel(4), 1, '--'
|
||||
|
||||
Execute (fold text of ==, --):
|
||||
let b:width = winwidth(0)
|
||||
let b:hyphen = repeat('-', b:width - 17 > 2 ? b:width - 17 : b:width - 9 > 0 ? 3 : 2)
|
||||
AssertEqual foldtextresult(3), strpart('Fold text 2', 0, b:width - 9) . ' ' . b:hyphen . ' 1'
|
||||
|
||||
Given markdown;
|
||||
Headline
|
||||
|
||||
foobar
|
||||
|
||||
# Title
|
||||
|
||||
Execute (fold any preamble):
|
||||
AssertEqual foldlevel(1), 1, 'Headline'
|
||||
AssertEqual foldlevel(3), 1, 'foobar'
|
||||
AssertEqual foldlevel(5), 0, '# Title'
|
||||
|
||||
Given markdown;
|
||||
---
|
||||
layout: article
|
||||
title: A test of the heading folding when there is YAML frontmatter
|
||||
tags: markdown yaml vim-markdown
|
||||
---
|
||||
body
|
||||
|
||||
heading
|
||||
-------
|
||||
|
||||
Execute (fold level of yaml front matter):
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
source ../after/ftplugin/markdown.vim
|
||||
AssertEqual foldlevel(1), 1, '---'
|
||||
AssertEqual foldlevel(2), 1, 'layout: article'
|
||||
AssertEqual foldlevel(4), 1, 'tags: markdown yaml vim-markdown'
|
||||
AssertEqual foldlevel(5), 1, '---'
|
||||
AssertEqual foldlevel(6), 1, 'body'
|
||||
AssertEqual foldlevel(8), 1, 'heading'
|
||||
AssertEqual foldlevel(9), 1, '-------'
|
||||
unlet g:vim_markdown_frontmatter
|
16
sources_non_forked/vim-markdown/test/run-tests.sh
Normal file
16
sources_non_forked/vim-markdown/test/run-tests.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Exit on error.
|
||||
set -e
|
||||
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||
|
||||
for dep in ../build/tabular ../build/vim-toml ../build/vim-json ../build/vader.vim; do
|
||||
if [[ ! -d $dep ]]; then
|
||||
echo "Missing dependency: $dep"
|
||||
echo "You may just want to use 'make test'."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
vim -Nu vimrc -c 'Vader! *' > /dev/null
|
158
sources_non_forked/vim-markdown/test/syntax-singleline.vader
Normal file
158
sources_non_forked/vim-markdown/test/syntax-singleline.vader
Normal file
@ -0,0 +1,158 @@
|
||||
Before:
|
||||
let g:vim_markdown_emphasis_multiline = 0
|
||||
syn off | syn on
|
||||
|
||||
After:
|
||||
let g:vim_markdown_emphasis_multiline = 1
|
||||
syn off | syn on
|
||||
|
||||
Given markdown;
|
||||
a **b** c
|
||||
|
||||
Execute (bold):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
a __b__ c
|
||||
|
||||
Execute (bold):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
a *b* c
|
||||
|
||||
Execute (italic):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a _b_ c
|
||||
|
||||
Execute (italic):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
_a_b_
|
||||
|
||||
Execute (italic text has underscores):
|
||||
AssertEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a \*b\* c
|
||||
|
||||
Execute (not italic with escaped asterisks):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a \_b\_ c
|
||||
|
||||
Execute (not italic with escaped underscores):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a _b\_c_ d
|
||||
|
||||
Execute (italic with escaped underscores):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a_b_c
|
||||
|
||||
Execute (not italic underscores within text):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a *b\*c* d
|
||||
|
||||
Execute (italic with escaped asterisks):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a __b\_\_c__ d
|
||||
|
||||
Execute (bold with escaped underscores):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('c'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
_a b
|
||||
c_ d
|
||||
|
||||
Execute (italic with underscores in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
__a b
|
||||
c__ d
|
||||
|
||||
Execute (bold with underscores in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
___a b
|
||||
c___ d
|
||||
|
||||
Execute (bold italic with underscores in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
|
||||
|
||||
Given markdown;
|
||||
*a b
|
||||
c* d
|
||||
|
||||
Execute (italic with asterisks in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
**a b
|
||||
c** d
|
||||
|
||||
Execute (bold with asterisks in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
***a b
|
||||
c*** d
|
||||
|
||||
Execute (bold italic with asterisks in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
|
||||
|
89
sources_non_forked/vim-markdown/test/syntax.md
Normal file
89
sources_non_forked/vim-markdown/test/syntax.md
Normal file
@ -0,0 +1,89 @@
|
||||
# Fenced code living in an indented environment is correctly highlighted
|
||||
|
||||
1. run this command to do this:
|
||||
|
||||
```
|
||||
some command
|
||||
```
|
||||
|
||||
2. Subsequent list items are correctly highlighted.
|
||||
|
||||
Fenced code block with language:
|
||||
|
||||
```ruby
|
||||
def f
|
||||
0
|
||||
end
|
||||
```
|
||||
|
||||
# Links
|
||||
|
||||
[a](b "c")
|
||||
|
||||
[a]()
|
||||
|
||||
[good spell](a)
|
||||
|
||||
[badd spell](a)
|
||||
|
||||
[a](b "c")
|
||||
|
||||
[a]( b
|
||||
"c" )
|
||||
|
||||
a (`a`) b. Fix: <https://github.com/plasticboy/vim-markdown/issues/113>
|
||||
|
||||
Escaped:
|
||||
|
||||
\[a](b)
|
||||
|
||||
[a\]b](c)
|
||||
|
||||
## Known failures
|
||||
|
||||
Escape does not work:
|
||||
|
||||
[a\](b)
|
||||
|
||||
Should not be links because of whitespace:
|
||||
|
||||
[a] (b)
|
||||
|
||||
[a](a
|
||||
b)
|
||||
|
||||
[a](a b)
|
||||
|
||||
# Reference links
|
||||
|
||||
Single links:
|
||||
|
||||
[a][b]
|
||||
|
||||
[good spell][a]
|
||||
|
||||
[badd spell][a]
|
||||
|
||||
[a][]
|
||||
|
||||
[a] []
|
||||
|
||||
[a][b] c [d][e]
|
||||
|
||||
Reference link followed by inline link:
|
||||
|
||||
[a] [b](c)
|
||||
|
||||
## Known failures
|
||||
|
||||
Should be shortcut reference links:
|
||||
|
||||
[a]
|
||||
|
||||
[a] b [c]
|
||||
|
||||
Should be a single link:
|
||||
|
||||
[a] [b]
|
||||
|
||||
[a] b [c](d)
|
1258
sources_non_forked/vim-markdown/test/syntax.vader
Normal file
1258
sources_non_forked/vim-markdown/test/syntax.vader
Normal file
File diff suppressed because it is too large
Load Diff
44
sources_non_forked/vim-markdown/test/table-format.vader
Normal file
44
sources_non_forked/vim-markdown/test/table-format.vader
Normal file
@ -0,0 +1,44 @@
|
||||
Before:
|
||||
let &gdefault = 1
|
||||
|
||||
After:
|
||||
let &gdefault = 0
|
||||
|
||||
Given markdown;
|
||||
| normal |no space| 2 spaces ||
|
||||
| - |-| --- ||
|
||||
| normal |no space| 2 spaces ||
|
||||
|
||||
Execute (format unformatted table):
|
||||
TableFormat
|
||||
|
||||
Expect (table is formatted):
|
||||
| normal | no space | 2 spaces | |
|
||||
|--------|----------|----------|--|
|
||||
| normal | no space | 2 spaces | |
|
||||
|
||||
Given markdown;
|
||||
| a | b |
|
||||
|---|---|
|
||||
| c | d |
|
||||
|
||||
Execute (format well formatted table):
|
||||
TableFormat
|
||||
|
||||
Expect (table is not modified):
|
||||
| a | b |
|
||||
|---|---|
|
||||
| c | d |
|
||||
|
||||
Given markdown;
|
||||
| left |right| center ||
|
||||
| :- | --: |:---:|:|
|
||||
| left |right| center ||
|
||||
|
||||
Execute (format table with colons):
|
||||
TableFormat
|
||||
|
||||
Expect (preserve colons to align text):
|
||||
| left | right | center | |
|
||||
|:-----|------:|:------:|:--|
|
||||
| left | right | center | |
|
53
sources_non_forked/vim-markdown/test/toc-autofit.vader
Normal file
53
sources_non_forked/vim-markdown/test/toc-autofit.vader
Normal file
@ -0,0 +1,53 @@
|
||||
" Tests toc window auto-fit to longest header, but without exceeding half screen.
|
||||
|
||||
Given markdown;
|
||||
# chap 1
|
||||
|
||||
# chap 2
|
||||
|
||||
# chap 3
|
||||
|
||||
# chap 4
|
||||
|
||||
# chap 5
|
||||
|
||||
# chap 6
|
||||
|
||||
# chap 7
|
||||
|
||||
# chap 8
|
||||
|
||||
# chap 9
|
||||
|
||||
# chap 10
|
||||
|
||||
# chap 11
|
||||
|
||||
# chap 12
|
||||
|
||||
## chap 12.1
|
||||
|
||||
### chap 12.1.1
|
||||
|
||||
#### chap 12.1.1.1
|
||||
|
||||
##### chap 12.1.1.1.1
|
||||
|
||||
###### chap 12.1.1.1.1.1
|
||||
|
||||
# chap 13
|
||||
|
||||
Execute (toc window autofit width):
|
||||
set number
|
||||
let g:vim_markdown_toc_autofit = 1
|
||||
let line = '###### chap 12.1.1.1.1.1'
|
||||
AssertEqual getline('33'), line
|
||||
:Toc
|
||||
let real_width = winwidth(0)
|
||||
:lclose
|
||||
let expected_width = len(line) + 2*5 + 1 + 3 - 7
|
||||
AssertEqual real_width, expected_width
|
||||
set nonumber
|
||||
" 2 spaces * 5 additional header levels + 1 space for first header +
|
||||
" 3 spaces for line numbers - 7 chars ('###### ') that don't show up on the TOC
|
||||
|
185
sources_non_forked/vim-markdown/test/toc.vader
Normal file
185
sources_non_forked/vim-markdown/test/toc.vader
Normal file
@ -0,0 +1,185 @@
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
Execute (Toc does not set nomodifiable on other files):
|
||||
" Sanity check.
|
||||
Assert &modifiable
|
||||
|
||||
:Toc
|
||||
:lclose
|
||||
:edit a
|
||||
|
||||
Assert &modifiable
|
||||
|
||||
Given markdown;
|
||||
header 1
|
||||
========
|
||||
|
||||
test
|
||||
|
||||
header 2
|
||||
--------
|
||||
|
||||
test
|
||||
|
||||
### header 3
|
||||
|
||||
test
|
||||
|
||||
Execute (Toc setex headers):
|
||||
:Toc
|
||||
|
||||
Expect (setex headers):
|
||||
header 1
|
||||
header 2
|
||||
header 3
|
||||
|
||||
Given markdown;
|
||||
# header 1
|
||||
|
||||
test
|
||||
|
||||
## header 2
|
||||
|
||||
test
|
||||
|
||||
### header 3
|
||||
|
||||
test
|
||||
|
||||
Execute (Toc atx headers):
|
||||
:Toc
|
||||
|
||||
Expect (atx headers):
|
||||
header 1
|
||||
header 2
|
||||
header 3
|
||||
|
||||
Given markdown;
|
||||
ATX tests.
|
||||
|
||||
# h1 space
|
||||
|
||||
#h1 nospace
|
||||
|
||||
# h1 2 spaces
|
||||
|
||||
# h1 trailing hash #
|
||||
|
||||
## h2 space
|
||||
|
||||
##h2 nospace
|
||||
|
||||
## h2 trailing hash ##
|
||||
|
||||
### h3 space
|
||||
|
||||
###h3 nospace
|
||||
|
||||
### h3 trailing hash ###
|
||||
|
||||
#### h4
|
||||
|
||||
##### h5
|
||||
|
||||
###### h6
|
||||
|
||||
---
|
||||
|
||||
Relative positions.
|
||||
|
||||
# h1 before h2
|
||||
|
||||
## h2 between h1s
|
||||
|
||||
# h1 after h2
|
||||
|
||||
---
|
||||
|
||||
Setex tests.
|
||||
|
||||
setex h1
|
||||
========
|
||||
|
||||
setex h2
|
||||
--------
|
||||
|
||||
setex h1 single punctuation
|
||||
=
|
||||
|
||||
setex h1 punctuation longer than header
|
||||
================================
|
||||
|
||||
Prevent list vs Setex confusion:
|
||||
|
||||
- not Setex
|
||||
- because list
|
||||
|
||||
---
|
||||
|
||||
Mixed tests.
|
||||
|
||||
setex h1 before atx
|
||||
===================
|
||||
|
||||
## atx h2
|
||||
|
||||
### atx h3
|
||||
|
||||
# atx h1
|
||||
|
||||
setex h2
|
||||
------------------
|
||||
|
||||
### atx h3 2
|
||||
|
||||
Execute (Toc multiple headers):
|
||||
:Toc
|
||||
|
||||
Expect (multiple headers):
|
||||
h1 space
|
||||
h1 nospace
|
||||
h1 2 spaces
|
||||
h1 trailing hash
|
||||
h2 space
|
||||
h2 nospace
|
||||
h2 trailing hash
|
||||
h3 space
|
||||
h3 nospace
|
||||
h3 trailing hash
|
||||
h4
|
||||
h5
|
||||
h6
|
||||
h1 before h2
|
||||
h2 between h1s
|
||||
h1 after h2
|
||||
setex h1
|
||||
setex h2
|
||||
setex h1 single punctuation
|
||||
setex h1 punctuation longer than header
|
||||
setex h1 before atx
|
||||
atx h2
|
||||
atx h3
|
||||
atx h1
|
||||
setex h2
|
||||
atx h3 2
|
||||
|
||||
Execute:
|
||||
:lclose
|
||||
|
||||
Given markdown;
|
||||
# header 1
|
||||
|
||||
## header 2
|
||||
|
||||
### header 3
|
||||
|
||||
Execute (Toc cursor on the current header):
|
||||
normal! 4G
|
||||
:Toc
|
||||
AssertEqual line('.'), 2
|
||||
:lclose
|
||||
normal! G
|
||||
:Toc
|
||||
AssertEqual line('.'), 3
|
||||
:lclose
|
27
sources_non_forked/vim-markdown/test/vimrc
Normal file
27
sources_non_forked/vim-markdown/test/vimrc
Normal file
@ -0,0 +1,27 @@
|
||||
set nocompatible
|
||||
set rtp+=../
|
||||
set rtp+=../build/tabular/
|
||||
set rtp+=../build/vim-toml/
|
||||
set rtp+=../build/vim-json/
|
||||
set rtp+=../build/vader.vim/
|
||||
let $LANG='en_US'
|
||||
filetype on
|
||||
filetype plugin on
|
||||
filetype indent on
|
||||
syntax on
|
||||
|
||||
function! Markdown_GetScriptID(fname) abort
|
||||
let a:snlist = ''
|
||||
redir => a:snlist
|
||||
silent! scriptnames
|
||||
redir END
|
||||
let a:mx = '^\s*\(\d\+\):\s*\(.*\)$'
|
||||
for a:line in split(a:snlist, "\n")
|
||||
if stridx(substitute(a:line, '\\', '/', 'g'), a:fname) >= 0
|
||||
return substitute(a:line, a:mx, '\1', '')
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
function! Markdown_GetFunc(fname, funcname) abort
|
||||
return function('<SNR>' . Markdown_GetScriptID(a:fname) . '_' . a:funcname)
|
||||
endfunction
|
Reference in New Issue
Block a user