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

Text towards the end of long markdown documents sometimes renders all in cursive

Open joelostblom opened this issue 8 years ago • 7 comments

I am seeing an issue where text towards the end of long markdown documents is rendered all in cursive rather than the appropriate syntax highlighting. To get the text at the end to render properly, I need to unfold all headings and scroll up in the document until, at some point, the text renders as it should, then I scroll back down and the text at the end remains properly rendered.

When I have seen similar behavior in long code documents, it has been sufficient to set:

:syntax sync fromstart  

But this seems to have no effect on the text in markdown documents.

I have had some troubles finding a good sample file to reproduce this issue, as it happens rather sporadically, and not always from the same point in the document. I am going to work more on finding a good example, but I just wanted to check if anyone recognizes this problem from my description and if there is a known solution.

joelostblom avatar Oct 21 '17 21:10 joelostblom

I have seem this happen sometimes.

Are you using embedded languages? In some cases the scripts will declare their own settings for syntax sync, and there can be conflicts.

fmoralesc avatar Oct 23 '17 11:10 fmoralesc

@fmoralesc I am not using an embedded language, at least not intentionally (I didn't know about embedded languages, but from what I understand after reading about it, I don't think I am using one).

I just tried with a minimal .vimrc:

call plug#begin()
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
call plug#end()

and the problem remains.

I spent some time trying to create a minimal reproducible example. It turns out that this behavior is not related to the length of the document as I initially thought, but rather the culprit seems to be folded sections with references that contain colons. Here is a sample:

# Heading

Test with a citation containing a colon [@software_name:_2008].


# This renders in cursive if unfolded before the above

The **text** here also [renders](link here) in `cursive`.

If I unfold the second heading before the first, it will render in cursive instead of the appropriate syntax highlighting. As soon as I unfold the first heading, rendering occurs as expected in the second heading, even when I fold the first heading again.

joelostblom avatar Oct 23 '17 13:10 joelostblom

Just as I posted the above, I realized this probably happens because the : negates the immediately following underscore somehow when the text is folded. This does indeed seem to be the case. Adding an additional underscore to end of the reference or removing the first underscore solves the issue.

joelostblom avatar Oct 23 '17 13:10 joelostblom

I see. The _ after : activates the italics, but that should be prevented. I will see what I can do.

(btw, this is an issue in vim-pandoc-syntax)

fmoralesc avatar Oct 23 '17 20:10 fmoralesc

Great, thanks for looking into this!

joelostblom avatar Oct 23 '17 20:10 joelostblom

@fmoralesc I do not see the behavior I described in the test case any longer (using the same minimal vimrc on nvim 0.3.1). Can you confirm that the test is working for you also? If so this issue can be closed (although, I can't find the commit that fixed it).

joelostblom avatar Oct 14 '18 17:10 joelostblom

Scratch that, I forgot that my nvim does not display cursive text... :man_facepalming: Sorry, I opened it in vim 8.1.374 and the issue persists.

My current workaround is to run tr ':_' '_' < old-bib.bib > new-bib.bib to remove all the occurrences of :_.

joelostblom avatar Oct 14 '18 17:10 joelostblom