asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
340 stars 97 forks source link

Alternative code block breaks syntax hightlighting #439

Open leorochael opened 3 years ago

leorochael commented 3 years ago

Description

When including code listings delimited by .... the syntax highlighter gets lost, as can be seen in the screenshot below.

According to the Asciidoctor documentation, code blocks delimited by .... are valid:

https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#literals-and-source-code

System Information

AsciiDoc v2.8.9 VS.Code 1.60.0 OS: Linux x64 5.4.0-81-generic

To Reproduce

  1. Download and rename the attached file to remove .txt extension and leave the .adoc extension.
  2. Open in VS.Code
  3. See that the syntax highlighting is broken: the second block comment is not highlighted in green.

Screenshots & Files

Sample file demonstrating the problem:

dot-listing-breaks-highlighting.adoc.txt

Screenshot of the broken highlighting:

image

Additional Context

N/A

ggrossetie commented 3 years ago

As far as I know, Visual Code is using a parser (based on a regular expressions defined in https://github.com/asciidoctor/asciidoctor-vscode/blob/master/syntaxes/Asciidoctor.json) to do syntax highlighting.

This parser has some limitations because the AsciiDoc syntax can be context-dependent. Having said that it might be possible to fix this particular issue.

If you want to give it a try, here's some documentation about the syntax highlighter in Visual Code: https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide

danyill commented 3 years ago

Some time ago we moved to using the same grammar as the Atom language and the process for updating it is documented in Contributing.

However the grammar in the Atom language package hasn't been modified in the last 4 years. Perhaps in future the spec effort will allow a language server approach in future. I think it would still be ideal to upstream the grammar efforts and then synch periodically.

See here for the rationale for changing from what was done previously and a discussion of the grammars available for Asciidoc.