vim-pandoc-syntax icon indicating copy to clipboard operation
vim-pandoc-syntax copied to clipboard

Indented codeblock causes highlight error

Open nandokawka opened this issue 9 years ago • 9 comments

When I indent codeblocks, the following normal md Text gets highlighted wrong. All is colored in the same color for the rest of the file. Is there a solution for this problem? Does anybody else has the same problem?

vimcodeindentation

nandokawka avatar Dec 29 '14 18:12 nandokawka

Why are you indenting fenced codeblocks? Those don't require that.

In any case, the problem seems to be that indentation is not enough: if present, it requires 4 spaces, where you seem to have only 2, and so the text is treated like a regular paragraph. It seems like pandoc behaves similarly, since:

  ``` sql 
  aaaa 
  \```

aaaa

outputs this HTML:

<p><code>sql    aaaa</code></p>
<p>aaaa</p>

pandoc, however, seems to stop the non formatted section after the last `, which we currently don't.

fmoralesc avatar Dec 31 '14 15:12 fmoralesc

Any idea when this might be a adressed? I filed a similar problem regarding Block Quotes containing Verbatim Blocks before I realized this problem had been filed.

IMO - it's not valid to ask why someone is using this. It's perfectly standard practice to indent example code in a text book. And it's very much documented as supported by pandoc... Quoting Block Quotations:

A block quotation is one or more paragraphs or other block elements (such as lists or headers), with each line preceded by a > character and an optional space.

And, in the Verbatim Blocks section, text indented by four spaces is treated as verbatim, but:

The initial (four space or one tab) indentation is not considered part of the verbatim text, and is removed in the output.

So, you have to use a Fenced Block either manually indented, or quoted to get the desired effect. From the Fenced code blocks section:

Everything between these lines is treated as code. No indentation is necessary:

Saying that it is not necessary, isn't the same as saying it will be indented (which it isn't), so to have an indented example, you either insert the spaces (or tab) manually, or use a quotation block.

SndChaser avatar Apr 12 '17 20:04 SndChaser

@SndChaser I asked why because I hadn't seen the use case, not as a way of saying this is not something to be addressed. Also, this was put forth quite a while ago, so perhaps pandoc's documentation was different and I missed this? I can't quite remember.

Anyway, I can't at the moment give any estimate of when I could address this, if at all :(

fmoralesc avatar Apr 12 '17 20:04 fmoralesc

@fmoralesc Sorry if I over reacted... I just read the comment the wrong way.

The reason I was asking about it is because it has been here for so long... But I do understand that it's something that is complicated and not easy to address.

As I said on IRC, I'll look at a couple of forks and see if they manage to address it, if not I'll fork the code and try to understand Vim's syntax highlighting...

SndChaser avatar Apr 12 '17 22:04 SndChaser

@SndChaser No problem at all. Just ping me if you have any questions.

fmoralesc avatar Apr 12 '17 22:04 fmoralesc

Just to name a use case:

A numbered list, which contains an unnumbered item, which is a code block.

This is typically expressed by "multiple paragraphs for a number in the list", where only the first one has that number in front and the others simply "belong" to that number as well.

ZelphirKaltstahl avatar Apr 13 '17 08:04 ZelphirKaltstahl

What happened to this issue? Highlighting indented code correctly seems like pretty basic functionality :)

mawkler avatar May 06 '20 21:05 mawkler

@Melkster I'm sure we'd be glad to accept a PR that addresses this. It is a problem, it just need somebody to contribute the time to fix it. Feel like taking a stab at it?

alerque avatar May 06 '20 22:05 alerque

@alerque I understand! Sadly I'm not sure I have the time or know enough vim script to be able to solve it myself.

mawkler avatar May 13 '20 20:05 mawkler