New CSS for the Yeet Log

Table of Contents

I've spent the last couple of hours sorting out a stylesheet for this blog. It's loosely based on my Emacs theme, located in my "emacs.d" at lisp/themes/custom-theme.el.

Examples

Headings

The headings (html only goes up to <h6>) use the same colours as the org-level-n faces. The variable org-html-toplevel-hlevel's default value is 2, which means that the top-level heading is actually <h2>. This allows to use a different colour from the title, so the html headings actually mimic the org-level-(n+1) faces.

By default, org-mode only exports up to 3 headline levels. I set org-export-headline-levels to 6 in order for the smaller headings to have the appropriate html tag:

(setq org-export-headline-levels 6)

As of [2020-09-19 Sat], I've added extra asterisks before the headings, just like org. Not sure if I'll keep it this way, it's kind of gaudy.

Tables

Tables, of course, are org-mode's signature blue:

css Emacs face colour
h1 org-document-title midnight blue
h2 org-level-1 blue
h3 org-level-2 sienna
h4 org-level-3 purple
h5 org-level-4 firebrick
h6 org-level-5 forest green

org-level-3, h4

org-level-4, h5
org-level-5, h6

Source Blocks

In Emacs, I'm really not a fan of the "highlighted source blocks" fad – I think it just looks messy and awkward. When exported to html, however, I think it looks quite nice.

(defun celsius-to-fahrenheit (celc &optional insert)
  (interactive (list
                (read-number "Celsius: ")
                current-prefix-arg))
  (funcall (if insert
               #'insert
             #'message)
           (format "%d°C = %d°F"
                   celc
                   (+ 32 (/ celc (/ 5.0 9.0))))))

(celsius-to-fahrenheit 12)
12°C = 53°F

Table of Contents

I'll be honest – I was at a loss for what to do with the TOC. Emacs doesn't actually show a table of contents (org-shifttab makes it redundant), so I had to come up with an idea myself. I decided to make it darker so that it isn't in the way – this led to some frustration as I'm not very familiar with CSS, but I got it looking pretty nice in the end.

Screenshot

Here is a screenshot to compare my Emacs theme with this page's stylesheet:

Sorry, your browser does not support SVG.

Author: Jamie Beardslee

Date: 2020-08-20 (modified 2020-09-19)

Top: The Yeet Log