From a7d486f0902aef1d9599e46fddf08e58aff52be8 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sat, 1 Jun 2019 11:47:47 -0400 Subject: [PATCH] Style section headers --- src/blog/a-dsl-for-music.html.pm | 2 -- src/pollen.rkt | 8 +++++++- src/stylesheet.css.pp | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/blog/a-dsl-for-music.html.pm b/src/blog/a-dsl-for-music.html.pm index f0d70fb..b9d1b57 100644 --- a/src/blog/a-dsl-for-music.html.pm +++ b/src/blog/a-dsl-for-music.html.pm @@ -3,8 +3,6 @@ ◊title{A DSL for Music} ◊published-date[2018 8 5] -◊;; TODO add author and date - ◊section{Haskell School of Music} I recently discovered Haskell School of Music. It’s a book about algorithmic music, which is awesome because: a) I’ve been obsessed with procedural generation for years and b) I like music as much as I like programming. So you can imagine my excitement when I discovered that someone had written a textbook combining my favorite areas of study. diff --git a/src/pollen.rkt b/src/pollen.rkt index dd48a4e..e9fa536 100644 --- a/src/pollen.rkt +++ b/src/pollen.rkt @@ -11,6 +11,12 @@ (define (zip-kws kws kw-args) (map list (map string->symbol (map keyword->string kws)) kw-args)) +(define (with-class attrs cls) + (let ((existing-cls (assoc 'class attrs))) + (dict-set attrs 'class (if existing-cls + (list (string-append (cadr existing-cls) " " cls)) + (list cls))))) + (define title (make-keyword-procedure (lambda (kws kw-args . elements) @@ -19,7 +25,7 @@ (define section (make-keyword-procedure (lambda (kws kw-args . elements) - (txexpr 'h2 (zip-kws kws kw-args) elements)))) + (txexpr 'h2 (with-class (zip-kws kws kw-args) "section-header") elements)))) (define link (make-keyword-procedure diff --git a/src/stylesheet.css.pp b/src/stylesheet.css.pp index 5bf616d..efc8f9b 100644 --- a/src/stylesheet.css.pp +++ b/src/stylesheet.css.pp @@ -71,3 +71,7 @@ pre > code.hljs { float: left; margin-right: 1em; } + +.section-header { + margin-top: 2em; +}