Files
James MillsandClaude Opus 5 2de03b8c30 Let a styled document stay Markdown
Writing a page with any real design to it meant writing HTML in the .md
file, because the two things a class has to attach to were both out of
reach: goldmark's WithAttribute() only covers headings and code fences, so
a table, a list, a blockquote or an image could not carry one at all, and
goldmark-fences only ever emitted <div>, so a <section>, a <figure> or a
<figcaption> had to be hand-written. A landing page ended up more markup
than prose.

Fenced containers come in-tree to fix the second half. The word after the
colons names the element:

    :::figure{.diagram}
    ![Two appliances](/img/appliances.webp)
    :::figcaption
    Design renders; the production casing may differ.
    :::
    :::

Names come from an allowlist, and one outside it is reported and rendered
as a <div> rather than passed through. Two things the upstream extension
got wrong go with it: every container carried a data-fence attribute, which
was parser bookkeeping leaking into the output, and every aria-* attribute
was dropped, because goldmark's attribute filter matches names exactly and
has no notion of a prefix. The bookkeeping now lives on the node, and the
renderer allows the aria- and data- prefixes.

Block attributes fix the first half. A line holding nothing but an
attribute list applies to the block after it:

    {.pricing}
    | Setup option | Price    |
    | ------------ | -------- |
    | Yourself     | Included |

An image on its own line takes the attributes itself rather than handing
them to the paragraph around it, which is the only way width, height and
loading reach the <img>. Numbers are written out on the way, because
goldmark parses a bare number into a float64 and then renders it as the
empty string, which turns {width=1400} into width="".

Both are on by default. selfhosted.au was the exercise that found all of
this: its five pages went from 553 lines of embedded HTML to two <sup>
tags, with no change to what the site looks like.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LArUFzbPFiuwMn7ZdADfyi
2026-09-12 12:10:32 +10:00

43 lines
1.6 KiB
AMPL

module go.mills.io/zs
go 1.25.0
require (
github.com/13rac1/goldmark-embed v0.0.0-20201220231550-e6806f2de66a
github.com/alecthomas/chroma/v2 v2.27.0
github.com/gabriel-vasile/mimetype v1.4.15
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/sirupsen/logrus v1.10.2
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/yuin/goldmark v1.8.5
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20220924101305-151362477c87
go.abhg.dev/goldmark/anchor v0.2.0
go.abhg.dev/goldmark/wikilink v0.6.0
go.mills.io/static v0.0.0-20260831143852-78fb794ee31a
golang.org/x/sync v0.22.0
golang.org/x/text v0.41.0
gopkg.in/yaml.v2 v2.4.0
)
require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/cyphar/filepath-securejoin v0.5.0 // indirect
github.com/dlclark/regexp2/v2 v2.2.1 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/unrolled/logger v0.0.0-20201216141554-31a3694fe979 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/sys v0.36.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)