Skip to content

Code blocks not retaining monospace font on export #5576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hallsie opened this issue Apr 11, 2025 · 1 comment
Closed

Code blocks not retaining monospace font on export #5576

Hallsie opened this issue Apr 11, 2025 · 1 comment

Comments

@Hallsie
Copy link

Hallsie commented 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

@ssddanbrown
Copy link
Member

Hi @Hallsie,
Thanks for reporting.

I can confirm the lack of monospace code font to be a bug, related to this: sass/dart-sass#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 ssddanbrown changed the title Code blocks do not export as code blocks with line numbers to PDF Code blocks not retaining monospace font on export Apr 12, 2025
@ssddanbrown ssddanbrown added this to the v25.02.3 milestone Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants