+ AssertNotEqual SyntaxOf('c'), 'mkdLink'
+ AssertNotEqual SyntaxOf('c'), 'mkdURL'
+
+Given markdown;
+[a] (b)
+
+Execute (space is not allowed between link text and parenthesis):
+ AssertNotEqual SyntaxOf('a'), 'mkdLink'
+ AssertNotEqual SyntaxOf('b'), 'mkdURL'
+
+Given markdown;
+[a](b)
+
+Execute (conceal link):
+ if has('conceal')
+ setlocal conceallevel=2
+ AssertEqual synconcealed(1, 1)[0], 1
+ AssertEqual synconcealed(1, 2)[0], 0
+ AssertEqual synconcealed(1, 3)[0], 1
+ AssertEqual synconcealed(1, 4)[0], 1
+ AssertEqual synconcealed(1, 4)[0], 1
+ AssertEqual synconcealed(1, 5)[0], 1
+ AssertEqual synconcealed(1, 6)[0], 1
+ setlocal conceallevel=0
+ endif
+
+Execute (disable conceal):
+ if has('conceal')
+ let g:vim_markdown_conceal=0
+ syn off | syn on
+ setlocal conceallevel=2
+ AssertEqual synconcealed(1, 1)[0], 0
+ AssertEqual synconcealed(1, 2)[0], 0
+ AssertEqual synconcealed(1, 3)[0], 0
+ AssertEqual synconcealed(1, 4)[0], 0
+ AssertEqual synconcealed(1, 4)[0], 0
+ AssertEqual synconcealed(1, 5)[0], 0
+ AssertEqual synconcealed(1, 6)[0], 0
+
+ let g:vim_markdown_conceal=1
+ syn off | syn on
+ AssertEqual synconcealed(1, 1)[0], 1
+ AssertEqual synconcealed(1, 2)[0], 0
+ AssertEqual synconcealed(1, 3)[0], 1
+ AssertEqual synconcealed(1, 4)[0], 1
+ AssertEqual synconcealed(1, 4)[0], 1
+ AssertEqual synconcealed(1, 5)[0], 1
+ AssertEqual synconcealed(1, 6)[0], 1
+
+ setlocal conceallevel=0
+ unlet g:vim_markdown_conceal
+ syn off | syn on
+ endif
+
+# Autolinks
+
+Given markdown;
+a <http://b> c
+
+Execute (autolink):
+ AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('<'), 'mkdDelimiter'
+ AssertEqual SyntaxOf('b'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('>'), 'mkdDelimiter'
+ AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
+
+Given markdown;
+http://12monkeys.foo
+
+Execute (autolink with domain starting with a number):
+ AssertEqual SyntaxOf('12monkeys'), 'mkdInlineURL'
+
+Given markdown;
+<HtTp://a>
+
+Execute (autolink with scheme case is insensitive):
+ AssertEqual SyntaxOf('a'), 'mkdInlineURL'
+
+Given markdown;
+<a>
+
+Execute (autolink without scheme is not a link):
+ AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
+
+Given markdown;
+< http://a >
+<http://b c>
+<http://d
+e>
+
+Execute (autolink with space is not a link):
+ AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
+ AssertNotEqual SyntaxOf('b'), 'mkdInlineURL'
+ AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
+ AssertNotEqual SyntaxOf('d'), 'mkdInlineURL'
+ AssertNotEqual SyntaxOf('e'), 'mkdInlineURL'
+
+Given markdown;
+\<http://a>
+
+Execute (autolinks can be backslash escaped):
+ AssertNotEqual SyntaxOf('<'), 'mkdDelimiter'
+
+Given markdown;
+a (http://b.bb) c
+
+Execute (autolink in parenthesis):
+ AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('('), 'mkdDelimiter'
+ AssertEqual SyntaxOf('b'), 'mkdInlineURL'
+ AssertEqual SyntaxOf(')'), 'mkdDelimiter'
+ AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
+
+Given markdown;
+[![a](http://b)](http://c)
+
+Execute (autolink in link text):
+ AssertEqual SyntaxOf('!'), 'mkdDelimiter'
+ AssertEqual SyntaxOf('a'), 'mkdLink'
+ AssertEqual SyntaxOf('b'), 'mkdURL'
+ AssertEqual SyntaxOf('c'), 'mkdURL'
+
+Given markdown;
+# [h1link](url)
+
+## [h2link](url)
+
+### [h3link](url)
+
+#### [h4link](url)
+
+##### [h5link](url)
+
+###### [h6link](url)
+
+[h1link_b](url)
+===============
+
+[h2link_b](url)
+---------------
+
+Execute (link in headers):
+ AssertEqual SyntaxOf('h1link'), 'mkdLink'
+ AssertEqual SyntaxOf('h2link'), 'mkdLink'
+ AssertEqual SyntaxOf('h3link'), 'mkdLink'
+ AssertEqual SyntaxOf('h4link'), 'mkdLink'
+ AssertEqual SyntaxOf('h5link'), 'mkdLink'
+ AssertEqual SyntaxOf('h6link'), 'mkdLink'
+ AssertEqual SyntaxOf('h1link_b'), 'mkdLink'
+ AssertEqual SyntaxOf('h2link_b'), 'mkdLink'
+
+Given markdown;
+# http://h1link.foo
+
+## http://h2link.foo
+
+### http://h3link.foo
+
+#### http://h4link.foo
+
+##### http://h5link.foo
+
+###### http://h6link.foo
+
+http://h1link_b.foo
+===================
+
+http://h2link_b.foo
+-------------------
+
+Execute (inline url in headers):
+ AssertEqual SyntaxOf('h1link'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('h2link'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('h3link'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('h4link'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('h5link'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('h6link'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('h1link_b'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('h2link_b'), 'mkdInlineURL'
+
+Given markdown;
+> [a](b)
+> http://foo.bar
+
+Execute (link in blockquote):
+ AssertEqual SyntaxOf('a'), 'mkdLink'
+ AssertEqual SyntaxOf('foo'), 'mkdInlineURL'
+
+Given markdown;
+[https://domain.tld](https://domain.com) not_a_link
+
+Execute (link with url title):
+ AssertEqual SyntaxOf('https://domain.tld'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('https://domain.com'), 'mkdInlineURL'
+ AssertNotEqual SyntaxOf('not_a_link'), 'mkdInlineURL'
+
+# Code Blocks
+
+Given markdown;
+~~~
+code
+~~~
+
+Execute (code blocks can be fenced with tildes):
+ AssertEqual SyntaxOf('c'), 'mkdCode'
+
+Given markdown;
+~~~~
+code
+~~~~~
+
+Execute (code blocks can be fenced with tildes longer than 3):
+ AssertEqual SyntaxOf('c'), 'mkdCode'
+
+Given markdown;
+````
+code
+`````
+
+Execute (code blocks can be fenced with backticks longer than 3):
+ AssertEqual SyntaxOf('c'), 'mkdCode'
+
+Given markdown;
+~~~ruby
+code
+~~~
+
+Execute (code blocks can have a language specifier):
+ AssertEqual SyntaxOf('c'), 'mkdCode'
+
+Given markdown;
+```c++
+code
+```
+
+text
+
+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'
+
+Given markdown;
+ a
+ b
+
+Execute (indent code block at beginning of file):
+ AssertEqual SyntaxOf('a'), 'mkdCode'
+ AssertEqual SyntaxOf('b'), 'mkdCode'
+
+Given markdown;
+```c++
+#include <iostream>
+code
+```
+
+```ruby
+def a
+end
+```
+
+Execute (fenced code block syntax with a language specifier):
+ let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
+ call b:func(0)
+ AssertEqual SyntaxOf('include'), 'cInclude'
+ AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
+ AssertEqual SyntaxOf('def'), 'rubyDefine'
+
+Given markdown;
+``` c++
+#include <iostream>
+code
+```
+
+``` vim
+let g:a = 1
+```
+
+``` ruby
+def a
+end
+```
+
+```
+ruby
+class B
+end
+```
+
+Execute (fenced code block syntax with a language specifier after whitespace):
+ let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
+ call b:func(0)
+ AssertEqual SyntaxOf('include'), 'cInclude'
+ AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
+ AssertEqual SyntaxOf('g:a'), 'vimVar'
+ AssertEqual SyntaxOf('def'), 'rubyDefine'
+ AssertNotEqual SyntaxOf('class'), 'rubyClass'
+
+Given markdown;
+```vim
+let g:a = 1
+```
+
+```viml
+let g:b = 1
+```
+
+Execute (fenced code block syntax with alias language specifier):
+ let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
+ call b:func(0)
+ AssertEqual SyntaxOf('g:a'), 'vimVar'
+ AssertEqual SyntaxOf('g:b'), 'vimVar'
+
+Given markdown;
+```csharp
+var s = "foo";
+```
+
+Execute (fenced code block languages setting):
+ let g:vim_markdown_fenced_languages = ['csharp=cs']
+ source ../ftplugin/markdown.vim
+ let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
+ call b:func(0)
+ AssertEqual SyntaxOf('foo'), 'csString'
+ unlet g:vim_markdown_fenced_languages
+
+Given markdown;
+```vim
+let g:a = 1
+```
+
+Execute (fenced code block includes language syntax with reopening same buffer):
+ let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
+ call b:func(0)
+ split
+ quit
+ edit
+ set filetype=markdown
+ execute "normal! i```vim\<cr>let g:a = 1\<cr>```"
+ call b:func(1)
+ AssertEqual SyntaxOf('g:a'), 'vimVar'
+
+Given markdown;
+```a+b-
+code
+```
+
+Execute (fenced code block syntax with an unknown language specifier):
+ let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
+ call b:func(0)
+ AssertEqual SyntaxOf('code'), 'mkdSnippetA_B_'
+
+Given markdown;
+```
+=
+a
+-
+```
+
+Execute (first = or - in fenced code block is not setex headers):
+ AssertEqual SyntaxOf('='), 'mkdCode'
+ AssertEqual SyntaxOf('-'), 'mkdCode'
+
+Given markdown;
+``` {style=""}
+a
+```
+
+Execute (fenced code block with extended info strings):
+ AssertEqual SyntaxOf('a'), 'mkdCode'
+
+# Code Blocks in pre and code tag
+
+Given markdown;
+<pre>
+a
+</pre>
+
+Execute (code block in pre tag):
+ AssertEqual SyntaxOf('a'), 'mkdCode'
+
+Given markdown;
+<code>
+a
+</code>
+
+Execute (code block in code tag):
+ AssertEqual SyntaxOf('a'), 'mkdCode'
+
+Given markdown;
+\<pre\>
+a
+\</pre\>
+
+Execute (not code block in escaped pre tag):
+ AssertNotEqual SyntaxOf('a'), 'mkdCode'
+
+Given markdown;
+\<code\>
+a
+\</code\>
+
+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'