Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to suppress error highlighting? #3605

Closed
chuck-confluent opened this issue Mar 24, 2020 · 2 comments
Closed

How to suppress error highlighting? #3605

chuck-confluent opened this issue Mar 24, 2020 · 2 comments
Assignees
Milestone

Comments

@chuck-confluent
Copy link

I've been reading and re-reading the user manual section on source highlighters, but haven't found the options to suppress error highlighting. For context, I am using the json highlighter in Rouge and I'd like to split the json into parts on multiple (pdf) pages. The lexer highlights errors, so on the second page, the closing braces are highlighted because their matching braces are on the first page. Is there an option to pass, like [source,json,numbered,errors=ignore] ?

Generally, I think the documentation could use some improvement in listing all the options available to syntax highlighters. The user manual mentions linenums, for example, but I've found in Rouge the syntax is numbered, not linenums. I'm not even sure where I learned that. It might have been a guess.

@mojavelinux
Copy link
Member

Asciidoctor has no control over this behavior. Asciidoctor delegates syntax highlighting to the source highlighter. How it handles that task is up to it. Rouge apparently requires that the JSON document be complete or else it flags it as an error. So it's best to highlight a valid JSON snippet or disable syntax highlighting (by removing the source style or using a generic language like text).

The user manual mentions linenums, for example, but I've found in Rouge the syntax is numbered, not linenums.

In truth, the name doesn't matter at all. If there is an attribute in the third position, line numbering is enabled. It could be named number-all-the-lines.

[source,json,number-all-the-lines]

But the preferred syntax is the option:

[source%linenums,json]

I'd like to split the json into parts on multiple (pdf) pages.

This sounds like an Asciidoctor PDF issue. Are you putting text between the snippets, or just breaking up a single block so that it fits on different pages? If the latter, you shouldn't need to as that's what Asciidoctor PDF already does.

@mojavelinux mojavelinux added this to the support milestone Mar 25, 2020
@mojavelinux mojavelinux self-assigned this Mar 25, 2020
@chuck-confluent
Copy link
Author

chuck-confluent commented Mar 25, 2020

Thanks again for your help, Dan!

I use asciidoctor-pdf to make slides, and there are some json examples where I want part of the json on one slide and the rest on the next slide for conceptual reasons. There is text in between (for example, the slide title). I'm pretty sure there's no way to force a page break in the middle of a code block since a code block is meant to stay together as much as possible.

It would be fine if the lexer ignored syntax errors. I brought up this issue on the Rouge page (linked earlier in the github conversation) and they are starting to agree that the lexer shouldn't necessarily highlight errors. They mentioned using a CSS rule to ignore error highlighting, but as these are PDFs, I don't think there is a way for me to control this from the asciidoctor-pdf side of things.

I could go in and make modifications to the lexer to ignore syntax errors, but that's going to be hard to maintain with my current build setup for such a small detail. For now, I will just live with it. Let me know if I'm wrong and there is something to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants