vim-pandoc / vim-pandoc-syntax

pandoc markdown syntax, to be installed alongside vim-pandoc
MIT License
425 stars 61 forks source link

Highlighting of indented codeblocks #253

Open tfoerst3r opened 5 years ago

tfoerst3r commented 5 years ago

Hallo.

It seems to me that indented code blocks (as discussed in Issue #207) are not highlighted correctly (see images blow). I have found no information how to change this. Any help would be appreciated.

    # Test

    Code:

    ``` python
    def test:
        print('test')
```
def test:
    print('test')
```

    def test:
        print('test')


![test](https://user-images.githubusercontent.com/32761865/50086615-ead9b280-01fd-11e9-9532-42eb62ca6560.png)
Konfekt commented 5 years ago

Perhaps this is due to https://github.com/vim-pandoc/vim-pandoc-syntax/blob/56e8e41ef863a0a7d33d85c3c0c895aa6e9e62d3/syntax/pandoc.vim#L248 and related to https://github.com/vim-pandoc/vim-pandoc-syntax/issues/229

randomizedthinking commented 5 years ago

Encountered the same issue today. I tested how pandoc would treat such cases:

pandoc -o test.pdf test.md

I found, when #indent-space is <= 3, then pandoc will recognize them as valid code block construction. When #indent-space >= 4, then pandoc will treat them as typewriter text. It makes sense.

Yet, the current vim-pandoc-syntax recognizes constructions with >=4 leading spaces as code blocks. I think maybe the logic is somehow flipped.

Konfekt commented 5 years ago

Dear @randomizedthinking, so it should read

syn match pandocCodeblock /\([ ]\{1,3}.*$/ 

? What about tabs?

randomizedthinking commented 5 years ago

@Konfekt the code is not the one you just mentioned. In EnableEmbedsforCodeblocksWithLang, a syn region is defined for each lang: pandocDelimitedCodeBlock.

bpj commented 4 years ago

Personally I would prefer if indented blocks weren't highlighted, because false positives are far more annoying than false negatives. If you crave highlighting of code blocks fenced blocks with language appropriate highlighting are available.

Konfekt commented 4 years ago

There is at

" syntax/pandoc.vim (lines 290-292)
if g:pandoc#syntax#protect#codeblocks == 1
    syn match pandocCodeblock /\([ ]\{4}\|\t\).*$/
endif

the undocumented option g:pandoc#syntax#protect#codeblocks that switches highlighting of indented code blocks off by setting it to 0.

alerque commented 4 years ago

@Icy-Thought You have a completely different issue than what is being discussed in this issue and it will require a different fix. Can you please open that as a separate issue so we can track it properly?

alerque commented 4 years ago

@bpj What kind of false positives worry you? Highlighting the wrong embedded language or Highlighting things that shouldn't be code blocks at all?

bpj commented 4 years ago

Things that aren't code blocks at all, namely list item continuation paragraphs.

-- Better --help|less than helpless

Den tis 9 juni 2020 18:50Caleb Maclennan notifications@github.com skrev:

@bpj https://github.com/bpj What kind of false positives worry you? Highlighting the wrong embedded language or Highlighting things that shouldn't be code blocks at all?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vim-pandoc/vim-pandoc-syntax/issues/253#issuecomment-641435049, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3OU24XZJE7WRCLVWGQPLRVZR2HANCNFSM4GLBDG4A .

Icy-Thought commented 4 years ago

@Icy-Thought You have a completely different issue than what is being discussed in this issue and it will require a different fix. Can you please open that as a separate issue so we can track it properly?

@alerque Deleted it and created a new issue with the mentioned issue to reduce future confusion which could arise from my earlier comment.