tpope / vim-markdown

Vim Markdown runtime files
1.23k stars 191 forks source link

Code block region regex improved. #140

Closed padawin closed 3 years ago

padawin commented 5 years ago

At the moment, any line starting with 4 spaces or a tab is considered as a code block, which causes issues in code like this:

1. Agenda Item 1: Frob the Bazzit
   - The bazzit is something that makes us have
     very _short_ lines indeed.
   - Further frobbing is necessary

The line "very short lines indeed." is considered as a code block (and therefore, the short is not italised.

The change of this commit enforces a code block to be preceeded with an empty line. This gives the following behaviour:

1. Agenda Item 1: Frob the Bazzit
   - The bazzit is something that makes us have
     This is **NOT** a code block
   - Further frobbing is necessary

    This **IS** a code block

    This **IS** also a code block
    And so is that

Some text

    This **IS** also a code block
    Which is followed directly by some not code after this line.
Some more text
very _short_ lines indeed.
    This is **NOT** a code block

very _short_ lines indeed.

For context, this comes from https://stackoverflow.com/q/55645317/3866623

Here is a screenshot with a result (code colored in blue): code-md

0cjs commented 5 years ago

I'm the guy who posted this originally to StackOverflow, and this does actually appear to fix the problem for me, at least in my limited testing so far. I've dropped a syntax clear markdownCodeBlock followed by the patched line into my ~/.vim/after/syntax/markdown.vim so I'll post here if I find anything on which this breaks.