Skip to content

Implement idiomatic syntax highlighting for revealjs output #11420

@jgm

Description

@jgm

Discussed in #11418

Originally posted by ghamerly January 24, 2026
reveal.js works well with highlight.js (on its own), but when pandoc generates revealjs slides, it is not possible (as far as I can see) to simply integrate highlight.js. There are two reasons:

  1. pandoc generates <pre [attributes]><code>..., but highlight.js expects <pre><code [attributes]>...
  2. the revealjs template needs some minor additions - in particular to add initialization for RevealHighlight plugin in Reveal.initialize(.

I've made a miniature working demo that enables pandoc to generate revealjs slides that seem to work well with highlight.js. I'm sure something I did could be simpler, but it boils down to:

  • a Lua filter to put attributes on the "correct" HTML tags
  • a slightly modified revealjs template

Here's the demo. Feedback is welcome. I'm going to try to use this in my teaching workflow.
https://github.com/ghamerly/pandoc-revealjs-highlightjs

As suggested in that Discussion, we could modify the revealjs writer to generate code suitable for reveal's built-in highlighting if the idiomatic highlighting option is selected.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions