Closed rhoerbe closed 2 years ago
Can you be more specific as to where you are looking for line numbers? Do you mean line numbers in a source listing? Or something else?
Office Writer and MS Word and LaTex have an option to number non-blank lines in the left margin of a page. It could even reset the count to 1 with each page. Another goode is to print the line number only at n lines (like 3 or 5). My particular need is just a straight number from the first to the last line.
I've never seen or used line numbering used in the output document. Is this for review/auditing/reference purposes?
In theory this is possible, but it's extremely difficult given how the Prawn API works. It doesn't provide a per-line callback when writing text. (A better PDF library would surely make this a lot simpler, as I've learned from experience using Prawn).
Yes, it is for review purposes. I failed with asciidoc -b odt (broken output), now trying asciidoctor-latex. Not sure if docbook could do the trick, inital research showed no hint.
I would suggest to do the review on the source instead of the rendered output. I do PR and code review of asciidoc files every day. The rendered output is available for reference and convenience of reading but the feedback is given in the github pull request based on the source..
I have been arguing for this in a number of working groups an communities, but most people just do not take up text/github based workflows, sticking to word/excel/pdf/email. This is all work in the IT sector.
I know... so sad. If you are in the tech sector... just learn to use the proper tools. But alas.. good luck @rhoerbe
@rhoerbe: I am using Python to pre-process the text before using ascii-doctor
.
Let me know if you need such a script as I have not needed it in the past.
I use coderay
though and I agree that it is good to have this function available for the whole text or specific blocks of text.
I would appreciate if you would share your script.
https://github.com/nvdl/pyasciidoc
We can add more functions as scripts. The concept is to have modules chained by asciidoc directives to pre-process the text before it is converted to PDF.
Now, there is only one module. I have done some basic testing.
Hi guys. Let me vote for this feature. In some cases, it is very useful to have line numbers every 5 lines for documentation, for the purposes of easily referencing to specific parts. One example can be seen here: https://www.nmra.org/sites/default/files/s-9.2.1_2012_07.pdf
Thank you for providing that example.
I have no idea how this could be done using the PDF generator used by this converter. If you know how, feel free to submit a PR. It's not something I have time to work on.
Unfortunately, I'm nowhere near as compenent in this field as is required...
I understand. That was a general invitation for anyone following this thread.
I have documented how to add line numbers to paragraphs using an extended converter. You can find the example code at the following location: https://github.com/asciidoctor/asciidoctor-pdf/blob/main/docs/modules/extend/examples/pdf-converter-numbered-paragraphs.rb This example, as well as numerous others, will be included in the documentation for Asciidoctor PDF 2.0.0 when it is released.
Given that the rules for where to add line numbers can vary widely, I think this is best left up to an extended converter. If it becomes clear that a majority of users agree on what should be numbered and how, we can consider bringing that code into the primary converter.
@mojavelinux
I have read through the documentation. Adding numbers to a block is possible and trivial.
Applying this to the whole document is not supported upstream.
A solution does not seem trivial, but possible. There is a link to an extended converter in the mentioned issue. Normally that would be trivial to call with something like asciidoctor-pdf -r ./extended.rb file.adoc
But we do not call the program directly. It is automated after site generation. I tried adding this option to the antora-assembler.yml file, but it does not work. It might be due the fact that it is called with bundle exec.
How can the extended converter be used with the antora pdf extension? How can the antora assembler be configured for this? This does not seem to be covered in the current documentation. Please refer to me the relevent source if I am missing something.
I've offered what information I can offer here. If you need further assistance, please direct your questions to the project chat. Since you are taking about Antora, I think the Antora chat at https://chat.antora.org is the most appropriate place.
Is there any support in this module to print line numbers in the output? If not this is a feature request.