Skip to content

fix: Skylighting code blocks in Typst lack proper block styling#14131

Open
gordonwoodhull wants to merge 1 commit intomainfrom
bugfix/14126
Open

fix: Skylighting code blocks in Typst lack proper block styling#14131
gordonwoodhull wants to merge 1 commit intomainfrom
bugfix/14126

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Feb 27, 2026

Summary

  • Override the Pandoc-generated #let Skylighting() Typst function to add width: 100%, inset: 8pt, and radius: 2pt to the block() call, matching native code block styling
  • Also fixes brand monospace-block.background-color not applying to Skylighting output (since #show raw.where(block: true) doesn't match #Skylighting() calls)
  • This is a temporary workaround until the fix can be upstreamed to the Skylighting library

Fixes #14126

Test plan

  • 8 new smoke-all tests covering default, line numbers, brand bgcolor, brand without bgcolor, brand inline, brand+theme, brand+idiomatic, brand inheritance
  • 5 pre-existing syntax-highlighting tests still pass
  • Visual inspection of rendered Typst PDFs with code blocks

@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Feb 27, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Feb 28, 2026

Now using @cderv's suggestion to post-process the Skylighting function in TS instead of using a Lua filter.

A TypeScript postprocessor patches the Pandoc-generated Skylighting
function in .typ output to add width: 100%, inset: 8pt, and radius: 2pt
to the block call, matching native code block styling.

The postprocessor matches the full Skylighting function signature to
ensure only the intended code is modified. For brand documents, also
resolves monospace-block background-color (including palette color names)
and overrides the bgcolor value.

Fixes #14126
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.

Code blocks in Typst with Skylighting do not have full width background or padding

2 participants