atom-asciidoc-preview icon indicating copy to clipboard operation
atom-asciidoc-preview copied to clipboard

No preview due to broken syntax highlighting

Open marcelhuberfoo opened this issue 6 years ago • 6 comments

Description

Generating the preview is broken for certain language specifiers. Curiously it works for some but not for all. It might be related to these issues https://github.com/asciidoctor/asciidoctor.js/issues/715 and https://github.com/asciidoctor/asciidoctor.js/issues/716, which were fixed lately. Unfortunately there wasn't an update to the atom previewer.

  • Atom version: 1.36.0 x64 (Elecron:4.1.4,Chrome:69.0.3497.128,Node:v10.11.0)
  • OS: linux, Arch
  • asciidoc-preview version: 2.12.3
  • language-asciidoc version: 1.11.0

Screenshots

Broken: DeepinScreenshot_select-area_20190426080311

Working: DeepinScreenshot_select-area_20190426080349

Syntax example

// does not work
= Title

== Installation

.Something
[source, bash]
// ruby, perl etc. doesn't work either
----
ls -la
----
// works
= Title

== Installation

.Something
[source, console]
----
ls -la
----

marcelhuberfoo avatar Apr 26 '19 06:04 marcelhuberfoo

Hello @marcelhuberfoo, could you please open the developer pane and check the console ? You should see an error message when the document is not rendered.

To open the Developer Tools press Ctrl+Shift+I.

The Atom extension is using a client side syntax highlighting based on https://www.npmjs.com/package/highlights (the internal syntax highlighter used in Atom).

ggrossetie avatar Apr 26 '19 06:04 ggrossetie

Hi @Mogztter I was wondering if I could open a log console or whatever but didn't think about the dev console... Here you go, hope it helps tracking down the cause.

highlights.coffee? [sm]:44 Uncaught (in promise) TypeError: grammar.tokenizeLines is not a function
    at highlightSync (highlights.coffee? [sm]:33)
    at tokenizeCodeBlocks (renderer.coffee? [sm]:125)
    at renderer.coffee? [sm]:13
    at process._tickCallback (internal/process/next_tick.js:68)
highlightSync @ highlights.coffee? [sm]:44
tokenizeCodeBlocks @ renderer.coffee? [sm]:145
(anonymous) @ renderer.coffee? [sm]:23
_tickCallback @ internal/process/next_tick.js:68

The source line at highlights.coffee:44 is:

    lineTokens = grammar.tokenizeLines fileContents

Thank you.

marcelhuberfoo avatar Apr 26 '19 06:04 marcelhuberfoo

I think it's related to: https://github.com/asciidoctor/atom-asciidoc-preview/issues/279#issuecomment-434883201 Please uncheck the "Tree Sitter Parsers" option in core settings.

ggrossetie avatar Apr 26 '19 06:04 ggrossetie

Yep, that solves my preview problem. Sorry, didn't see that comment before.

marcelhuberfoo avatar Apr 26 '19 08:04 marcelhuberfoo

It's OK, I think we should add a clear mention somewhere in the README because currently there's an incompatibility with the Tree Sitter grammars (and this issue happens frequently).

Can we close this issue ?

ggrossetie avatar Apr 26 '19 08:04 ggrossetie

The mentioning sounds good to me. Yes, from my point you can close the issue. Thank you again for your time and help.

marcelhuberfoo avatar Apr 26 '19 08:04 marcelhuberfoo