linenums and nowrap

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

linenums and nowrap

rlarsen
Hello,

I've got a maven project using asciidoctorj version 1.5.6.

I've noticed that the syntax highlighter for code blocks can get out of sync if the sample block has long lines that require wrapping. The wrapped line gets assigned the next number and by the end of the block, the numbers are misaligned and the last few lines are displayed without line numbers.

I can't seem to use the nowrap option and the linenums option at the same time. I tried `source%nowrap`, setting a global `:prewrap!:` (docs) and `options="nowrap`. Is this still true in later versions?

sample xml code block, should end up with 5 lines and 5 linenumbers:

.Test block
[source,xml,linenums]
....
<book id="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111">
      <author>2</author>
      <title>3</title>
      <description>4</description>
   </book>
....

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: linenums and nowrap

mojavelinux
Administrator
This problem is a shortcoming of the source highlighter.

If you're using wrapping with line numbers on, you must set the linenums mode to "inline" instead of the default "table".

:coderay-linenums-mode: inline

or

:pygments-linenums-mode: inline

If you want to disable wrapping, then you should unset the prewrap document attribute.

NOTE: Prior to 1.5.8, there was a bug in the stylesheet for CodeRay that was preventing wrapping from being disabled when using linenums with the table linenums-mode.

Cheers,

-Dan

On Wed, Apr 11, 2018 at 3:17 PM rlarsen [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hello,

I've got a maven project using asciidoctorj version 1.5.6.

I've noticed that the syntax highlighter for code blocks can get out of sync if the sample block has long lines that require wrapping. The wrapped line gets assigned the next number and by the end of the block, the numbers are misaligned and the last few lines are displayed without line numbers.

I can't seem to use the nowrap option and the linenums option at the same time. I tried `source%nowrap`, setting a global `:prewrap!:` (docs) and `options="nowrap`. Is this still true in later versions?

sample xml code block, should end up with 5 lines and 5 linenumbers:

.Test block
[source,xml,linenums]
....
<book id="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111">
      <author>2</author>
      <title>3</title>
      <description>4</description>
   </book>
....

Thanks!



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/linenums-and-nowrap-tp6241.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux