GithubHelp home page GithubHelp logo

Comments (8)

ggrossetie avatar ggrossetie commented on June 20, 2024 2

I'm glad it's working. I'm reopening because I think we can improve things:

  • Remove the dark grey box
  • Activate Highlight.js syntax highlighter when :source-highlighter: is defined

from asciidoctor-vscode.

ggrossetie avatar ggrossetie commented on June 20, 2024 2

Asciidoctor PDF is written in Ruby and does not support Highlight.js. You can use Highlight.js when converting to HTML with Asciidoctor (Ruby) because the syntax highlighting is done client side. Asciidoctor (Ruby) also supports Rouge when converting to HTML. In this case, the syntax highlighting is done during the processing.

As mentioned above, you should use:

    "asciidoc.preview.asciidoctorAttributes": {
        "source-highlighter": "highlight.js"
    }

You can leave :source-highlighter: rouge in your document since it has a lower precedence. With this setting, it should use Highlight.js in the VS code preview and Rouge when converting to HTML/PDF using Asciidoctor (Ruby).

from asciidoctor-vscode.

ggrossetie avatar ggrossetie commented on June 20, 2024

You need to enable syntax highlighting:

:source-highlighter: highlight.js

Having said that, the grey box on top of the code block is unexpected, I will take a look 👀

from asciidoctor-vscode.

AlessandroVol23 avatar AlessandroVol23 commented on June 20, 2024

You need to enable syntax highlighting:

:source-highlighter: highlight.js

Having said that, the grey box on top of the code block is unexpected, I will take a look 👀

I do have it activated in the main.adoc

:source-highlighter: rouge

and it also works in the PDF output. It just doesn't work in the preview of VS Code.

If I'm setting this option:

  "asciidoc.preview.useEditorStyle": false

Then I the black box is gone (maybe something with dark mode)?
But I'd like to see it in the preview as it would be in the final pdf.

So, with the option source-highlighter does syntax highlighting works for you in the VS Code preview as well?

Thanks for the fast reply!

from asciidoctor-vscode.

ggrossetie avatar ggrossetie commented on June 20, 2024

Rouge is written in Ruby and is not available in a JavaScript environment. Only Highlight.js is compatible with Asciidoctor.js. You can use a .asciidoctorconfig to configure Highlight.js when using VS code or add it in your settings.json:

    "asciidoc.preview.asciidoctorAttributes": {
        "source-highlighter": "highlight.js"
    }

In theory, we could check if source-highlighter is defined and fallback to Highlight.js in case the syntax highlighter is not available in the VS code environment.

from asciidoctor-vscode.

AlessandroVol23 avatar AlessandroVol23 commented on June 20, 2024

Ah that fixed it. Thank you so much! 😊

from asciidoctor-vscode.

AlessandroVol23 avatar AlessandroVol23 commented on June 20, 2024

Not sure if this is related to this issue. But now my syntax highlighting works in my preview but not in my generated pdf anymore with highlight.js 🤔

It doesn't work with rogue as well. I can see it in my HTML output but not in my pdf output.
Should create a dedicated issue for that?

Setting in main.adoc

:source-highlighter: highlightjs

Preview:
image

HTML:
image

PDF:
image

Any clue on what I can do here?

from asciidoctor-vscode.

AlessandroVol23 avatar AlessandroVol23 commented on June 20, 2024

Okay that works thanks!

from asciidoctor-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.