zhaoterryy / mkdocs-pdf-export-plugin

An MkDocs plugin to export content pages as PDF files
MIT License
318 stars 42 forks source link

How to get scrollable code boxes in generated PDFs, or at least remove line breaks from wrapped lines in code boxes? #115

Open Binarus opened 1 year ago

Binarus commented 1 year 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.

Is it possible to have such (horizontally) scrollable code blocks in the generated PDF documents as well?

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

First, it is very worrying for persons who read the PDF, because in code blocks they can't see whether a new line actually is a new line or is the continuation of the line above.

Second, when copying a wrapped long line from a code block in the PDF, the copied text contains line breaks where the line has been wrapped. This makes people unable to use the copied text directly, e.g. to paste it into a terminal as a new command line, without having to alter it before.

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

Thank you very much in advance, and best regards,

Binarus