Song with chords
Chords sit above the right words, and the whole song moves key with one line.
What it shows
Put chords above the words they fall on, and move a whole song to another key with one line.
What you learn
Directives in {braces}, a block for the chorus, a rule that takes every other line, a chord lifted above its syllable, bars split into cells, scopes that swap one set of chords for another.
Try this
- Change
@scope key-of-gabove the title to@scope key-of-a, and every chord moves up a tone. - Move a [chord] to another word, and it floats above that one instead.
Apple Tree Hill
Words and music by Marta Kowalczyk
Intro
Verse 1
We Gcut our names in the Emapple bark
the Csummer I turned Dnine.
You Gsaid a tree forEmgets nothing,
it just Cgrows aDround the Gline.
So Cmeet me up on GApple Tree Hill
when the Clight is Ggoing Dslow.
The Gtown has changed its Emmind a lot,
but the Cold tree Ddoesn't Gknow.
Verse 2
They Gbuilt the road where the Emorchard grew,
and the Cfarmhouse came down Dtoo,
but Gone tree stands at the Emtop of the hill,
still Ckeeping Dme and Gyou.
Bridge
AmNumbers change and Cletters get lost,
Ampeople move Cout of Dtown.
AmBark keeps growing Cover the cut,
but it Cnever Dwears it Gdown.
Outro
Sing the last chorus twice, the second time with only the guitar.
How it's made
- Each sung line is a line of text. A chord in brackets, such as
[G], floats above the letter after it. One inline rule does it, and the chord takes no width, so the words keep their spacing. - The title, the chips and the labels are directives in braces:
{title: …},{meta: …}and{c: Verse 1}. The chorus is everything between{soc}and{eoc}. @scope key-of-gabove the title picks a set of chords. In the scopeskey-of-aandkey-of-e, each written chord shows as the one a tone up or a minor third down, and the key chip follows.
Try it yourself
- Change
@scope key-of-gabove the title to@scope key-of-a. Every chord moves up a tone, and the first chip says Key of A. - In the first line of the chorus, move
[C]from "So" to "meet". The chord moves with it. - Add
{c: Coda}and a sung line under the outro's bars. A new label appears, and the line has room for chords. - In the palette, change
songto#1971c2. The chords, the chips and the chorus bar turn blue.
Next: Sheet music engraves a tune as a score; Group chat turns lines of text into a conversation.
~~~ selfscribe
# Lesson: Put chords above the words they fall on, and move a whole song to another key with one line.
# You learn: directives in {braces}, a block for the chorus, a rule that takes every other line, a chord lifted above its syllable, bars split into cells, scopes that swap one set of chords for another.
# Try this: change `@scope key-of-g` above the title to `@scope key-of-a`, and every chord moves up a tone.
# Try this: move a [chord] to another word, and it floats above that one instead.
# summary: Chords sit above the right words, and the whole song moves key with one line.
# category: fun
# tags: document, simple, creative
# uses: music
#
# No `use markdown`: the sheet has its own marks, all of them below.
set title Song with chords
set heading-font Fraunces
# ---- Colours, each with its shade for dark pages -------------------------------------
palette
song #b5402a dark #ff9e87
wash color-mix(in srgb, var(--song) 7%, transparent)
rule color-mix(in srgb, currentColor 14%, transparent)
# ---- Directives: "{title: …}", "{subtitle: …}", "{meta: a · b}", "{c: Verse 1}" --------
line {title: _} -> div.song-title { font: 600 2.9em/1.05 var(--doc-font-heading, Georgia, serif); letter-spacing: -0.02em; margin: 0.1em 0 0.15em } as sg-title
line {subtitle: _} -> div.song-sub { font-style: italic; opacity: 0.7; margin-bottom: 1em } as sg-sub
# The meta line is split at each · into chips.
line {meta: _} -> div.song-meta split "·" span.sg-chip { display: flex; flex-wrap: wrap; gap: 0.45em; padding-bottom: 1.6em; margin-bottom: 0.4em; border-bottom: 1px solid var(--rule) } as sg-meta
class sg-chip { font: 600 0.74em/1 var(--doc-font-ui); padding: 0.55em 0.85em; border-radius: 999px; background: var(--wash); color: var(--song) }
# "{c: Verse 1}": a small label with a hairline running to the right edge.
line {c: _} -> div.section { display: flex; align-items: center; gap: 0.8em; font: 700 0.7em/1 var(--doc-font-ui); letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.6; margin: 2em 0 0.1em } as sg-section
class section::after { content: ""; flex: 1; border-top: 1px solid var(--rule) }
# Everything between {soc} and {eoc} is the chorus.
block {soc} ... {eoc} -> div.chorus { margin: 1em 0 0.4em; padding: 0.2em 1.2em 0.9em; border-left: 3px solid var(--song); border-radius: 0 14px 14px 0; background: var(--wash); font-weight: 600 } as sg-chorus
# ---- Lyrics: every other line is one sung line, with room above it for chords ----------
# A lone slot matches any line, and every longer pattern wins over it.
line _ -> div.lyric { font-size: 1.1em; line-height: 1.3; padding-top: 1.15em } as sg-lyric
# "[G]": the chord takes no width and is lifted above the letter after it.
inline [_] -> b.chord
class chord { display: inline-block; width: 0; overflow: visible; white-space: nowrap; position: relative; top: -1.3em; font: 700 0.76em/1 var(--doc-font-ui); color: var(--song) }
# ---- "| [G] | [Em] |": a row of bars, one cell per bar ----------------------------------
line | _ | -> div.bars split "|" span.sg-bar { display: flex; gap: 0.35em; margin: 0.7em 0 0.2em } as sg-bars
class sg-bar { flex: 0 0 4.4em; padding: 0.75em 0.8em; line-height: 1; border-radius: 8px; background: var(--wash); border: 1px solid color-mix(in srgb, var(--song) 16%, transparent) }
# In a bar or a chip the chord sits in the box instead of above a word.
class sg-bar b { position: static; width: auto; font-size: 0.9em }
class sg-chip b { position: static; width: auto; font-size: 1em; color: inherit }
# ---- One line moves the key: "@scope key-of-a" above the title ---------------------------
# Each scope shows every written chord as another. The chord has no text of its own there:
# its --to value is drawn in its place. The key chip holds a chord too, so it follows.
class moved::before { content: var(--to) }
# key-of-g is the song as written: each chord shows as it is typed.
scope key-of-g
inline [_] -> b.chord
scope key-of-a
inline [G] -> b.chord.moved { --to: "A" }
inline [Em] -> b.chord.moved { --to: "F♯m" }
inline [C] -> b.chord.moved { --to: "D" }
inline [D] -> b.chord.moved { --to: "E" }
inline [Am] -> b.chord.moved { --to: "Bm" }
scope key-of-e
inline [G] -> b.chord.moved { --to: "E" }
inline [Em] -> b.chord.moved { --to: "C♯m" }
inline [C] -> b.chord.moved { --to: "A" }
inline [D] -> b.chord.moved { --to: "B" }
inline [Am] -> b.chord.moved { --to: "F♯m" }
scope
# ---- After the song: "{h: …}" headings, "- point", "1. step", "`code`" and "# a note" ------
# A heading takes its space above from a value the page reads, so the rule sets that value.
line {h: _} -> h2.sg-h { --doc-heading-gap: 2.6em } as sg-h
line - _ -> li group ul
line _#. _ -> li group ol
inline `_` -> code verbatim
line # _ -> div.song-note { font-size: 0.88em; font-style: italic; opacity: 0.65; margin-top: 1.4em } as sg-note
~~~
@scope key-of-g
{title: Apple Tree Hill}
{subtitle: Words and music by Marta Kowalczyk}
{meta: Key of [G] · 4/4 · 92 bpm · Down, down-up, up-down-up}
{c: Intro}
| [G] | [Em] | [C] | [D] |
{c: Verse 1}
We [G]cut our names in the [Em]apple bark
the [C]summer I turned [D]nine.
You [G]said a tree for[Em]gets nothing,
it just [C]grows a[D]round the [G]line.
{soc}
So [C]meet me up on [G]Apple Tree Hill
when the [C]light is [G]going [D]slow.
The [G]town has changed its [Em]mind a lot,
but the [C]old tree [D]doesn't [G]know.
{eoc}
{c: Verse 2}
They [G]built the road where the [Em]orchard grew,
and the [C]farmhouse came down [D]too,
but [G]one tree stands at the [Em]top of the hill,
still [C]keeping [D]me and [G]you.
{c: Bridge}
[Am]Numbers change and [C]letters get lost,
[Am]people move [C]out of [D]town.
[Am]Bark keeps growing [C]over the cut,
but it [C]never [D]wears it [G]down.
{c: Outro}
| [C] | [Am] | [D] | [G] |
# Sing the last chorus twice, the second time with only the guitar.
@end
{h: How it's made}
- Each sung line is a line of text. A chord in brackets, such as `[G]`, floats above the letter after it. One inline rule does it, and the chord takes no width, so the words keep their spacing.
- The title, the chips and the labels are directives in braces: `{title: …}`, `{meta: …}` and `{c: Verse 1}`. The chorus is everything between `{soc}` and `{eoc}`.
- `@scope key-of-g` above the title picks a set of chords. In the scopes `key-of-a` and `key-of-e`, each written chord shows as the one a tone up or a minor third down, and the key chip follows.
{h: Try it yourself}
1. Change `@scope key-of-g` above the title to `@scope key-of-a`. Every chord moves up a tone, and the first chip says Key of A.
2. In the first line of the chorus, move `[C]` from "So" to "meet". The chord moves with it.
3. Add `{c: Coda}` and a sung line under the outro's bars. A new label appears, and the line has room for chords.
4. In the palette, change `song` to `#1971c2`. The chords, the chips and the chorus bar turn blue.
# Next: Sheet music engraves a tune as a score; Group chat turns lines of text into a conversation.