Syntax Themes

Custom syntax highlighting for code blocks in Yolo.

syntax code highlighting themes

Syntax Themes

Yolo highlights code with custom syntax themes. Each color theme includes a matching syntax theme.

Syntax files:

  • src/_data/themes.json - the sh* keys hold syntax colors
  • src/assets/ext/js/theme-vars.js - expands them to syntax CSS variables

Syntax themes map colors to code tokens like keywords, strings, and comments.


Custom Syntax Theme

  1. Add an entry to a group in src/_data/themes.json.
  2. Set the sh* colors for light and dark modes.
  3. Update settings.yml:
settings.ymlcopy_all
name: Yolo
title: Yolo on my friend
description: Loveable single pages
brand:
  theme: reveal
  syntax: reveal

Syntax Swatches

These swatches show the current syntax theme colors. Each shows the token name and CSS selector.

Background and Text

Note: The container color is applied to the background of code blocks, and the text color to text/code not styled by a syntax token.

container (background)
text (color)

Syntax Tokens

Tip: Click a pill to see the colors.

Name Tokens
name (n)
name-attribute (na)
name-builtin-pseudo (bq)
name-builtin (nb)
name-class (nc)
name-constant (no)
name-decorator (nd)
name-entity (ni)
name-exception (ne)
name-function-magic (fm)
name-function (nf)
name-label (nl)
name-namespace (nn)
name-other (nx)
name-property (py)
name-tag (nt)
name-variable (nv)
name-variable-class (vc)
name-variable-global (vg)
name-variable-instance (vi)
name-variable-magic (vm)
 
String Tokens
string (s)
string-single (s1)
string-double (s2)
string-affix (sa)
string-backtick (sb)
string-char (sc)
string-doc (sd)
string-escape (se)
string-heredoc (sh)
string-interpol (si)
string-regex (sr)
string-symbol (ss)
string-other (sx)
 
Comment Tokens
comment (c)
comment-hashbang (ch)
comment-multiline (cm)
comment-preproc (cp)
comment-preprocfile (cpf)
comment-single (c1)
comment-special (cs)
 
Generic Tokens
generic-deleted (gd)
generic-emph (ge)
generic-error (gr)
generic-heading (gh)
generic-inserted (gi)
generic-output (go)
generic-prompt (gp)
generic-strong (gs)
generic-subheading (gu)
generic-traceback (gt)
Keyword Tokens
keyword (k)
keyword-constant (kc)
keyword-declaration (kd)
keyword-namespace (kn)
keyword-pseudo (kp)
keyword-reserved (kr)
keyword-type (kt)
 
Number Tokens
number (n)
number-bin (mb)
number-float (mf)
number-hex (mh)
number-integer-long (il)
number-integer (mi)
number-oct (mo)
 
Misc Tokens
error (err)
punctuation (p)
whitespace (w)
highlight-line (hll)
Literal and Date Tokens
literal (l)
literal-date (ld)
Operator Tokens
operator (o)
operator-word (ow)

Snippets

Click the header to copy code. 📋

Bashcopy_all
#!/bin/bash
function say_howdy() {
  echo "Howdy $1!"
}

if [ $# -ne 1 ]; then
    echo "Usage: Howdy <NAME>"
    exit 1
fi

say_howdy $1
JavaScriptcopy_all
function sayHowdy(name) {
  console.log("Howdy " + name + "!");
}

if(process.argv.length != 3) {
  console.log("Usage: Howdy <NAME>");
  process.exit(1);
}

sayHowdy(process.argv[2]);