orzih / mkdocs-with-pdf

Generate a single PDF file from MkDocs repository.
MIT License
333 stars 77 forks source link

Can we make code blocks scrollable in the generated PDF file? #133

Open Binarus opened 2 years ago

Binarus commented 2 years ago

I am completely new to mkdocs and its plugins. I am currently writing a documentation that contains code blocks with some very long lines. I am using the material theme. The code blocks are showing as expected on the HTML pages. That is, they have a horizontal scroll bar if they contain lines that are too long to fit into the page width. That horizontal scroll bar can be operated as usual.

What do I need to do to get such (horizontally) scrollable code blocks in the generated PDF documents as well? Is this possible at all?

Currently, the code blocks in the PDF wrap long lines, which imposes two problems:

First, it is very worrying for the reader, because we can't see whether a new line is the continuation of the line above or is really a new line.

Second, when copying a wrapped long line from the PDF, the copied text contains line breaks where the lines have been wrapped. This should not be the case. The user should be able to copy such lines from the PDF and to paste them somewhere without having to alter them.

If we can't have scrollable code blocks in the PDF (but I still hope we can), what do I need to do to to at least remove the line breaks mentioned above?

Thank you very much in advance, and best regards,

Binarus

nurse-the-code commented 3 months ago

Can you give us an example of any existing PDF that has those features? I am not even sure the PDF file format specification supports such behavior.

Honestly, it sounds like you might want to generate an offline static site (which could be opened in most web browsers) rather than a PDF based on my understanding of what you are asking for.