marshallward / vim-restructuredtext

Syntax file for reStructuredText on Vim.
26 stars 12 forks source link

Incorrect highlighting when || is not followed by whitespace #58

Closed philj56 closed 3 years ago

philj56 commented 3 years ago

The following example shows the issue:

.. math::
    |E| + 3
    |E|+3

The first line highlights correctly, with the + 3 using normal maths highlighting. On the second line, the lack of whitespace causes the |E| highlighting to never end, and carries on through the whole document until another || pair followed by whitespace is found.

Edit: Actually this doesn't just apply to math mode, the same thing happens without the directive.

marshallward commented 3 years ago

Thank you, this error is due to a recent change to start supporting inline syntax inside of generic directives (e.g. .. note::). Unfortunately .. math:: is not a generic directive and is probably better interpreted as .. code:: latex.

So I believe the solution here is to create an exception for .. math::.

marshallward commented 3 years ago

As for the |E| + 3 vs |E|+3, I think that the highlights are correct, since inline tokens require a blank character after the termination.

But I agree it's not correct to interpret this as a substitution inside of a math directive.

marshallward commented 3 years ago

My memory seems to be failing me; I believe this is a special case of #54.

philj56 commented 3 years ago

Ah you're right, I hadn't read all the way through that issue

marshallward commented 3 years ago

@madjxatw I've just applied your patch, which I should have done ages ago. Very sorry about that, sometimes I get too comfortable with the GitHub PR process.

While the particular problem has been solved, I think the discussion here is a good one and still unresolved, so I'm going to turn on Discussion and move this over there.