Skip to content

Syntax highlight code in slides and labs #56

@winstliu

Description

@winstliu

Right now we syntax highlight all source files using source-highlight.

It would be nice to also syntax highlight all the code in the slides and labs. Would reduce eyestrain, especially for the labs.

The good news is that this can be done already:

  • pandoc supports named code blocks, so all we need to do is add cpp to all our code blocks.
  • reveal.js has
    { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
    . It's broken currently, but can be fixed by just adding reveal.js/ in front.

Ideally, the highlighting would be consistent across all sources. The labs will most likely stay in light mode, and probably the source files as well, but the slides are dark mode. That doesn't mean we can't have consistent highlighting, though, as many themes have both light and dark variants.

So all we need to do is find a theme! I personally have a soft spot for One Dark and One Light, having worked on Atom as they were being developed (they also have corresponding Emacs variants), but I understand that this really isn't a decision for me to make 😁.

Notes:

  • Pandoc does not use CSS for its theming, which is...slightly annoying. I should be able to figure out the CSS --> JSON conversion required, though, or just manually override the colors with CSS anyway after they've been generated.
  • source-highlight takes in the --style-css-file argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions