ScoreScript for Notion

Write music as text and get engraved notation back. Notion has no plugin API, so this is a Worker with two doors into it: an embed block that holds a live editor, and an image block that points at a URL which renders to notation.

Open the playground New embed →

[key G] *"Allegro" 4G< A <B~ A | 2G (p) 2D
ScoreScriptAllegro

Recipe 1 — a live editor in the page

  1. Click New embed. You land on a page whose address is https://embed.scorescript.org/e/<id> — copy that address.
  2. In Notion, type /embed and press Enter.
  3. Paste the address and click Embed link.

The block is now an editor. Type in it and the notation redraws; the text is saved to this Worker, so the same music is there on every device and for everyone the Notion page is shared with. Drag the block's bottom edge to make it taller and its side handles to make it wider — the staff follows the width.

Recipe 2 — notation as an image

  1. In Notion, type /image and press Enter.
  2. Choose Embed link.
  3. Paste a URL of the form https://embed.scorescript.org/svg?s=4C%20D%20E%20F

Everything after s= is URL-encoded ScoreScript (a space is %20, a bar line | is %7C). An image block is static and cannot be edited in place, which is exactly what you want for finished examples. The Copy image link button inside an embed hands you https://embed.scorescript.org/svg/<id>, the same music as a picture.

The /svg endpoint

sthe source, URL-encoded. Defaults to a C-major scale.
wwidth in pixels (120–4000). Default 640.
ssone staff space in pixels (2–64) — the scale. Default 8.
fgink, as 1a1a1a or #1a1a1a. Default: the SVG's currentColor, which is black in an image block and inherits when inlined.
bgpaper. Default: none, so the image is transparent.

The endpoint is CORS-open and cached, so it works from anywhere an image URL works: Notion, a README, a slide, an <img> tag.

The language, in six lines

4C D E Fduration first, then pitch; the duration sticks until you change it
4Eb< Bb <D~ Eb'< > hairpins, ~ slur or tie, ' up an octave, , down
[C E G]a chord; r is a rest; | is a bar line
(p) (>) (dolce)marks in parentheses — before the note prints above, after prints below
[key Eb] [meter 3/4]brackets hold what stands at a point in the staff; [A] is a rehearsal mark
*"Andante"a tempo word; {3: 8C D E} is a triplet

The full card is spec/SCORESCRIPT.md in the ScoreScript repo. A source that does not compile still draws what it can, and the editor tells you why.