Lukasa / language-restructuredtext

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

Syntax highlighting for headings #56

Closed gwax closed 6 years ago

gwax commented 6 years ago

Right now headings are not highlighted and only have the scope text.restructuredtext. Please add additional scopes to allow syntax highlighting: heading.markup.restructuredtext for all headings, and heading-#.restructuredtext where # is the pertinent numbered heading.

Alhadis commented 6 years ago

👋 Hey @gwax,

This is impossible for two reasons, both of which relate to limitations in the syntax highlighting engine used by Atom:

  1. It's impossible for the engine to process more than one line at a time. This is done for speed: with every change a user makes, the document needs to be reprocessed, and being able to do this from an arbitrary location helps performance.

  2. The engine has no concept of state. Since the order in which section markers appear determines a document's hierarchy, the highlighting engine must "remember" which characters denote top-level headings, subheadings, tertiary headings, and so forth. We can't assume that ====== will always represent heading-1, -------- represent heading-2, as it is in Markdown.

I know it's a pain. Lightweight markup languages like AsciiDoc and reStructuredText are the worst affected by the highlighting engine's limitations. :(

gwax commented 6 years ago

Bummer.

Thank you @Alhadis for the very clear and detailed response to my issue.