add shortcodes as the first internal/ext feature

A call is `{{< name key="value" >}}` alone on a line, parsed by a goldmark block
parser into an AST node and rendered by executing a theme template of that name
(ADR-0036). `figure` ships; `include` and `gallery` need the including bundle's
directory, which the parser does not carry yet, so they wait.

The layering did the design work here. internal/render may not import
internal/ext, so render.New takes a callback that receives a Partial and returns
Markdown extensions, and cmd/khosra/wire.go holds the only list of enabled
features. Empty that list and the engine still builds and serves — which is the
property extensions.md says the contract should have.

Raw HTML stays disabled. An author's text reaches a page only as arguments that
html/template escapes in context, which the real binary shows: a hostile alt
becomes &lt;script&gt; and src="javascript:…" becomes #ZgotmplZ. Getting
contextual escaping from the standard library rather than writing it is the whole
reason a fragment renders this instead of the feature.

parseSet became variadic so the fragment set reuses it rather than growing a
second copy of the overlay logic; `Partial` takes map[string]string after the
advisory correctly flagged `any` as generality nothing had asked for.
This commit is contained in:
2026-08-01 02:23:35 +06:00
parent 47df821056
commit 1f7ca09313
14 changed files with 459 additions and 55 deletions
+8 -8
View File
@@ -24,7 +24,7 @@ func testHandler(t *testing.T) http.Handler {
if err != nil {
t.Fatal(err)
}
r, err := render.New(nil)
r, err := render.New(nil, nil)
if err != nil {
t.Fatal(err)
}
@@ -72,7 +72,7 @@ func multilingualHandler(t *testing.T) http.Handler {
if err != nil {
t.Fatal(err)
}
r, err := render.New(nil)
r, err := render.New(nil, nil)
if err != nil {
t.Fatal(err)
}
@@ -124,7 +124,7 @@ func aliasHandler(t *testing.T) http.Handler {
if err != nil {
t.Fatal(err)
}
r, err := render.New(nil)
r, err := render.New(nil, nil)
if err != nil {
t.Fatal(err)
}
@@ -171,7 +171,7 @@ func listingHandler(t *testing.T, n int) http.Handler {
if err != nil {
t.Fatal(err)
}
r, err := render.New(nil)
r, err := render.New(nil, nil)
if err != nil {
t.Fatal(err)
}
@@ -239,7 +239,7 @@ func TestStaticFilesAreServedAndDirectoriesAreNot(t *testing.T) {
if err != nil {
t.Fatal(err)
}
r, err := render.New(fsys)
r, err := render.New(fsys, nil)
if err != nil {
t.Fatal(err)
}
@@ -280,7 +280,7 @@ func TestAStaticPathThatEscapesTheRootIs404(t *testing.T) {
if err != nil {
t.Fatal(err)
}
r, err := render.New(fsys)
r, err := render.New(fsys, nil)
if err != nil {
t.Fatal(err)
}
@@ -313,7 +313,7 @@ func seriesHandler(t *testing.T) http.Handler {
if err != nil {
t.Fatal(err)
}
r, err := render.New(nil)
r, err := render.New(nil, nil)
if err != nil {
t.Fatal(err)
}
@@ -403,7 +403,7 @@ func tagHandler(t *testing.T) http.Handler {
if err != nil {
t.Fatal(err)
}
r, err := render.New(nil)
r, err := render.New(nil, nil)
if err != nil {
t.Fatal(err)
}