'How to have linenumbers for literal blocks with Asciidoctor?
My technical documents contains some examples showing the console output of some operations.
I guess the right markup for this type of content, as it isn't source code is literal.
[literal]
....
Hi world!
....
I would like also to have linenumbers for literal text, as it sometimes helps to find easier a specific line, if you can name it.
The linenums attribute can't be used, at least it seems so, and I would prefer not to be forced to use source for console output, as I have to specify a language for the content of the source block.
Any idea? What did I miss?
Solution 1:[1]
Adding line numbers is a presentation issue, and by itself, asciidoctor doesn't do that for you. Currently, that job is delegated to the source highlighter that is currently configured.
You have to specify the linenums attribute on each source block that should display line numbers.
AFAIK, only the rouge or pygments source highlighters support line numbers for PDF.
For HTML output, you have the option of adding some JavaScript to your page that can initialize the source highlighter to include line numbers everywhere, including for literal text blocks. How you do that depends on which source highlighter that you are using.
For source blocks, the language is optional. You do have to specify a language if you use additional attributes, but you can likely use the text language (as @BallpointBen suggested).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | eskwayrd |
