Skip to content
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

Fix whitespace handling in syntaxhighlighter #3229

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Conversation

haarg
Copy link
Member

@haarg haarg commented Nov 13, 2024

No description provided.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.14%. Comparing base (73dc5d1) to head (185dd14).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3229      +/-   ##
==========================================
+ Coverage   73.10%   73.14%   +0.04%     
==========================================
  Files          69       69              
  Lines        2398     2398              
  Branches      338      338              
==========================================
+ Hits         1753     1754       +1     
  Misses        517      517              
+ Partials      128      127       -1     

see 1 file with indirect coverage changes

The syntaxhighlighter library strips blank lines at the start of code
block it is trying to highlight. In addition to just being wrong, this
means that line numbers on the source page will not line up with the
real files.

Work around this by providing the library with fake objects that ignore
the attempt to strip these lines. This uses a fake string and a fake
element to hold it. This is an ugly workaround, but allows us to
continue using the syntax highlighter via npm.
Rather than padding empty lines with single spaces, we can use CSS to
ensure correct alignment. This avoids copy/pasting code including
invented spaces on empty lines.
@haarg haarg merged commit c6f5789 into master Nov 13, 2024
10 checks passed
@haarg haarg deleted the haarg/fix-synhi-whitespace branch November 13, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants