Code blocks not retaining monospace font on export #5255

Closed
opened 2026-02-05 09:51:47 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @Hallsie on GitHub (Apr 11, 2025).

Describe the Bug

As stated. I put a code block in with say 10 lines of code. When I export to a PDF it keeps it in a frame but the font is not a fixed width font anymore and things do not look correct:

Image

That is on the page. And below is in the PDF:

Image

As you can see it looks completely different because the * no longer has equal spacing. Also, the line numbers are gone.

Steps to Reproduce

  1. in a document, make a code block and do some typing and line up things. Make it multiple lines and use all caps or mix, shouldn't matter it should all line up correctly because of the fixed width font.
  2. save
  3. export the pdf and see it is not the same anymore and that the code line numbers are gone as well.

Expected Behaviour

I would expect a code block to come out on a PDF the way it looks on the site, fixed width terminal style font with line numbers in a box. The box is there, but the other two things are not.

Screenshots or Additional Context

No response

Browser Details

Chrome 135.0.7049.85 (64-bit)

Exact BookStack Version

v25.02

Originally created by @Hallsie on GitHub (Apr 11, 2025). ### Describe the Bug As stated. I put a code block in with say 10 lines of code. When I export to a PDF it keeps it in a frame but the font is not a fixed width font anymore and things do not look correct: ![Image](https://github.com/user-attachments/assets/c9f110d0-65ed-417e-89a0-ec98458bb194) That is on the page. And below is in the PDF: ![Image](https://github.com/user-attachments/assets/0a4e3f95-827d-4c17-913d-49c99918b579) As you can see it looks completely different because the * no longer has equal spacing. Also, the line numbers are gone. ### Steps to Reproduce 1. in a document, make a code block and do some typing and line up things. Make it multiple lines and use all caps or mix, shouldn't matter it should all line up correctly because of the fixed width font. 2. save 3. export the pdf and see it is not the same anymore and that the code line numbers are gone as well. ### Expected Behaviour I would expect a code block to come out on a PDF the way it looks on the site, fixed width terminal style font with line numbers in a box. The box is there, but the other two things are not. ### Screenshots or Additional Context _No response_ ### Browser Details Chrome 135.0.7049.85 (64-bit) ### Exact BookStack Version v25.02
OVERLORD added the 🐛 Bug🚚 Export System labels 2026-02-05 09:51:47 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Apr 12, 2025):

Hi @Hallsie,
Thanks for reporting.

I can confirm the lack of monospace code font to be a bug, related to this: https://github.com/sass/dart-sass/issues/472
The BOM is breaking all CSS variables, including code fonts, leading to this result.
We'll need to strip or handle this BOM character as part of our process.

I'm going to update this bug report to focus on that.

In regards to line numbers, that's somewhat by design.
Line numbers (and other code ability) are handled on the JavaScript side currently, leaving the original underlying code/stored state as plain as possible and a plain (pre>code) block.
Feel free to raise this as a separate feature request though if strongly desired.

@ssddanbrown commented on GitHub (Apr 12, 2025): Hi @Hallsie, Thanks for reporting. I can confirm the lack of monospace code font to be a bug, related to this: https://github.com/sass/dart-sass/issues/472 The BOM is breaking all CSS variables, including code fonts, leading to this result. We'll need to strip or handle this BOM character as part of our process. I'm going to update this bug report to focus on that. In regards to line numbers, that's somewhat by design. Line numbers (and other code ability) are handled on the JavaScript side currently, leaving the original underlying code/stored state as plain as possible and a plain (pre>code) block. Feel free to raise this as a separate feature request though if strongly desired.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5255