Hasty Briefsbeta

Bilingual

Doing my own syntax highlighting (finally)

6 months ago
  • #programming
  • #web-design
  • #syntax-highlighting
  • The author decided to revamp syntax highlighting on their blog after 13 years of using default settings.
  • Inspired by Nikita Prokopov's article, they adopted a minimalistic approach, highlighting only key elements like strings, comments, and variable definitions.
  • The new color scheme uses red for comments, green for strings, magenta for numbers and constants, blue for variable definitions, and grey for punctuation.
  • The author uses Rouge for syntax highlighting, which parses code into tokens and wraps them in HTML spans for CSS styling.
  • To highlight variable definitions specifically, the author manually annotates code snippets and uses a Jekyll plugin to modify the HTML output.
  • The new design makes comments more prominent and aims for better readability with a restrained color palette.
  • The author acknowledges that syntax highlighting is subjective but believes a minimal approach works best for short code snippets in blog posts.
  • The change was motivated by a desire to improve readability and align the code snippets with the rest of the site's design.
  • The author enjoys the creative freedom of personalizing their blog and finds joy in continuous improvements.