Skip to content

Switch site syntax highlighting to Highlight.js#7

Open
saforem2 wants to merge 1 commit intomainfrom
codex/replace-pandoc-syntax-highlighting-with-highlight.js
Open

Switch site syntax highlighting to Highlight.js#7
saforem2 wants to merge 1 commit intomainfrom
codex/replace-pandoc-syntax-highlighting-with-highlight.js

Conversation

@saforem2
Copy link
Owner

@saforem2 saforem2 commented Oct 12, 2025

Summary

  • disable Pandoc syntax highlighting for HTML outputs and load Highlight.js once per page
  • add a Highlight.js initialization snippet that runs after the document finishes loading
  • extend the light and dark syntax stylesheets to define Highlight.js token colors so they match the existing palette

Testing

  • quarto check (fails: command not found in container)

https://chatgpt.com/codex/tasks/task_e_68ebad86c080832a98c185e80a86f007

Summary by Sourcery

Switch code highlighting to Highlight.js by disabling Pandoc’s built-in styles, injecting the Highlight.js script with an initialization snippet, and updating light and dark CSS themes to style the Highlight.js token classes to match the existing palette.

Enhancements:

  • Disable built-in Pandoc highlight-style in the format configuration and include the Highlight.js CDN script with a post-load initialization snippet.
  • Extend light and dark syntax stylesheets with CSS variables and rules to style Highlight.js token classes using the existing color palette.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 12, 2025

Reviewer's Guide

This PR replaces Pandoc’s built-in highlighting with Highlight.js by disabling default highlighting in the Quarto config, injecting the Highlight.js script and initialization snippet after the page body, and extending both light and dark SCSS stylesheets with custom properties and token rules that align with the existing code color palette.

File-Level Changes

Change Details Files
Switch syntax highlighting to Highlight.js via Quarto config and include-after-body snippet
  • Set highlight-style to null for HTML outputs
  • Add include-after-body snippet to load Highlight.js and run highlightAll on DOMContentLoaded
quarto/_format.yml
Extend light and dark SCSS with Highlight.js variables and rules
  • Define --hljs-* CSS variables matching the site palette
  • Add base styles for code.hljs and pre code.hljs
  • Add token-specific rules for .hljs- classes
css/syntax-light.scss
css/syntax-dark.scss

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@netlify
Copy link

netlify bot commented Oct 12, 2025

Deploy Preview for laughing-elion-dcea8e ready!

Name Link
🔨 Latest commit ebbb41b
🔍 Latest deploy log https://app.netlify.com/projects/laughing-elion-dcea8e/deploys/68ebb2b430eb800008633361
😎 Deploy Preview https://deploy-preview-7--laughing-elion-dcea8e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Oct 12, 2025

Deploy Preview for samforeman ready!

Name Link
🔨 Latest commit ebbb41b
🔍 Latest deploy log https://app.netlify.com/projects/samforeman/deploys/68ebb2b4d15e4e00084dcd95
😎 Deploy Preview https://deploy-preview-7--samforeman.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 27
Accessibility: 85
Best Practices: 92
SEO: 83
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +100 to +106
include-after-body:
- text: | # Highlight.js
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-jy5nBnLsmJWYNN2/Ji+IRDigMKzl6GpAp7i8HP14KrU3xSR99ZvobmHxR1uU1kk9tRYRmtuyGqj1ZTx8qE4fpQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
window.addEventListener('DOMContentLoaded', () => {
if (window.hljs?.highlightAll) {
window.hljs.highlightAll();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid stripping Quarto’s line-number markup

The new include-after-body script calls hljs.highlightAll() on every code block after the page loads. Highlight.js replaces a node’s innerHTML with its own token markup. Quarto’s code-line-numbers: true feature generates <span id="cb…"> wrappers and anchor tags inside each <code> element to drive line numbers and per-line linking. Once Highlight.js rewrites the block, those spans are removed and the rendered page loses line numbers and line anchors even though the feature remains enabled. Consider either disabling Quarto’s line-numbering, running Highlight.js only on blocks without the sourceCode structure, or preprocessing the HTML so highlighting doesn’t clobber that markup.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant