Fix region detection for indented code blocks

Prior to this commit, _any_ line that started with at least 4 spaces or
a tab would be considered a code block.

For example, the third level of a 2-space-indented list would be
highlighted as code, not as list items.

Note: this conforms to the original Markdown spec:
> To produce a code block in Markdown, simply indent every line of the
> block by at least 4 spaces or 1 tab.
> A code block continues until it reaches a line that is not indented
> (or the end of the article).

While this doesn't explicitly state that a blank line _before_ the code
block is required, in practical testing, it is. As such, I've included
the requirement of a blank line preceeding the indent to match the
region start.

Any line not indented by at least 4 spaces will end the region.

Closes https://github.com/tpope/vim-markdown/issues/81
Closes https://github.com/tpope/vim-markdown/issues/164
Closes https://github.com/tpope/vim-markdown/issues/94 (possibly)
Closes https://github.com/tpope/vim-markdown/pull/140
This commit is contained in:
Zach Himsel
2020-07-17 16:12:45 -06:00
committed by Tim Pope
parent baf2592d33
commit f08447c76b

View File

@@ -75,7 +75,7 @@ syn region markdownH6 matchgroup=markdownH6Delimiter start=" \{,3}######\s" end=
syn match markdownBlockquote ">\%(\s\|$\)" contained nextgroup=@markdownBlock
syn region markdownCodeBlock start=" \|\t" end="$" contained
syn region markdownCodeBlock start="^\n\( \{4,}\|\t\)" end="^\ze \{,3}\S.*$" keepend
" TODO: real nesting
syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@=" contained