Lukasa / language-restructuredtext

A ReStructuredText syntax package for Atom
MIT License
27 stars 15 forks source link

Syntax highlighting for raw directive #55

Closed mia1024 closed 6 years ago

mia1024 commented 7 years ago

I noticed the rule for raw directive syntax highlighting is not right. For example, the correct way to write something in raw html is:

.. raw:: html

    <iframe src="https://google.com"></iframe>

However, in atom this won't trigger the html syntax highlighting, which only happens when i write like this (without the blank line, which is incorrect):

.. raw:: html
    <iframe src="https://google.com"></iframe>
mia1024 commented 7 years ago

Ironically, it seems github has the same problem

Alhadis commented 7 years ago

There's not much we can do about this, sadly. The syntax highlighting engine currently used by Atom (as well as on GitHub) is restricted to processing one line at a time. Meaning there's no easy way to tell if the current line is the start of a raw:: html block, or the start of an ordinary block which follows a raw::html block

Ironically, it seems github has the same problem

Well, it isn't ironic if GitHub is using this very grammar for highlighting reStructuredText. ;)

mia1024 commented 7 years ago

I just noticed that in atom, the syntax highlighting for math directive is behaving as expected. For example,

.. math::

    f'(x)=\lim_{\Delta x \to 0} \frac{f(x+\Delta x)-f(x)}{\Delta x}

In contrast, without the math directive:

f'(x)=\lim_{\Delta x \to 0} \frac{f(x+\Delta x)-f(x)}{\Delta x}

Or

.. math::

    f'(x)=\lim_{\Delta x \to 0} \frac{f(x+\Delta x)-f(x)}{\Delta x}
f'(x)=\lim_{\Delta x \to 0} \frac{f(x+\Delta x)-f(x)}{\Delta x}

All the LaTeX commands are highlighted within the math block, even though there is one (or, in fact, more) blank line following the math directive. So I would imagine there is a way to make raw directive to function similarly?

Alhadis commented 7 years ago

Hey mate,

It's quite possible, although I'm unable to look into it at present. A PR would be warmly welcomed in the meantime, assuming I don't get around to it sooner or later. =)

kylebarron commented 6 years ago

The ..raw:: html directive should color fine now on master.

Alhadis commented 6 years ago

Will cut a release shortly.