Skip to content

Instantly share code, notes, and snippets.

@zebreus
Last active June 28, 2023 19:26
Show Gist options
  • Save zebreus/72768b7d0e93b989e896bb1feef440d2 to your computer and use it in GitHub Desktop.
Save zebreus/72768b7d0e93b989e896bb1feef440d2 to your computer and use it in GitHub Desktop.
Really hacky workaround for highlightjs in asciidoctor-web-pdf / paged.js

Really hacky script for fixing listings with highlightjs in asciidoctor-web-pdf / paged.js

Add this script as docinfo-footer-pdf.html to your project and add the following to the top of your asciidoc file:

ifdef::env-web-pdf[]
:docinfo: shared-footer
endif::env-web-pdf[]

This script will replace all newlines in pre elements with <br> elements and spaces with &nbsp;

That works mostly, at least pagedjs does not crash anymore. The start of pages is a bit bugged and if a listing will span multiple pages it will always start on its own page.

I think pagedjs has problems if there is only whitespace and newlines between spans in a white-space: pre element. IDK what the exact bug is, but I currently dont have the time to find and fix it upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment