- Status: Accepted (2026-11-17).
- Decides: what a code block that a code renderer draws (spec §7.7) shows: its code, what the renderer draws, or both together; and how a
compmdblock shows the CompMD it holds beside what that renders. - Related: spec §7.7 (code renderers), §12.3 (the expanded tree), §14 (degradation, printing, plain text), code renderers, printing a document, a blog in CompMD.
- A code block whose language a code renderer renders always shows what the renderer draws; its code shows only in a plain renderer, or as the fallback when the component can't run.
- A post or a guide that explains a block ("this is what the block below draws") writes the code twice: once in a block of another language (
```text, or the fence indented), once in the block that renders. The two drift apart. - The website's guides show each example's source beside its render with a component of their own (
Example.svelte), from snapshots their build makes. That component isn't part of CompMD, so a blog post can't use it.
-
renderis a param every rendered block takes, asaltis (spec §7.7):render=source,render=outputorrender=both. The default isoutput, which is what a rendered block shows today, so no document changes.```mermaid {render=both alt="Draft, then review, then published"} graph LR; Draft --> Review --> Published ```
It is the processor's param, not the component's: the component never gets it, as it never gets
altdirectly (it getsfallback.text). A code renderer's signature that declares a param namedrenderwould never get it from a block, so it is F013. The spec says nothing today of a signature that declaresalt,classorid, and the processor gives each a meaning by form (a block'saltnever reaches the component, a leaf's does;class=xgoes to a component that declares it,.xto the box). This change says the same of them as ofrender: F013 foraltin a code renderer's signature, and forclassandidin any, in the same catalog row (decided in review). A declared common param (padding) is left as it is. It isn't evaluated: a bare value only, sorender=(…)is F009, since what shows is decided when the document is written, not from data or inputs. An unknown value (render=code) is F009, naming the three values. -
render=sourceshows the code block and nothing else. The component isn't run, and the block needs noalt(no W101), since it draws nothing that needs a text alternative. Its other params are still checked against the signature (F008, F009, F010), so switching it back tooutputgives no new diagnostics. This is for a post that shows a diagram's source on its own, and for an author who wants to see the code while a renderer misbehaves, without changing the block's language. -
render=bothshows the code block, then what it draws, in one box. The common params (spec §9.2) apply to that box, which holds the two;altis still needed (W101), for the drawing. The order is fixed, code first: a reader reads the source, then what it makes. How they're laid out is the renderer's style, not the spec's:@compmd/renderstacks them, and gives the box a class (compmd-both) so a host's or a blog's stylesheet can set them side by side on a wide page; stacked is the default on every width. No param for the layout: the common params'directionand breakpoints already lay out a box's blocks, and the two blocks inside are the box's. On screen,@compmd/renderkeeps the code hidden until the reader asks for it (spec §7.7, informative; 2026-11-23): the code's frame (compmd-code, which every code block has) is a bar over the output naming the code's language and its lines, with Show code and Copy, and a tag in the output's corner (compmd-both-tag) names the output while the code shows. Printed, the code shows and the bar and the tag don't. Everybothblock folds its code; no param chooses it. The bar's words come from CSS, so the page's text stays the document's, and one listener on the document works the buttons (followCodeFrames), in a page written ahead as HTML too. -
What falls back, falls back once. When the component can't run (pending, W118, W121, a processor without a browser), a
bothblock shows its code once, not the code twice: the drawing's fallback is the code block, which is already there. A pending component's placeholder still marks the drawing's place. -
The expanded tree says it on the
codenode (spec §12.3): a rendered block getsrender,"output"when absent, besidecomponentandalt.source: acodenode withrender: "source"and nocomponent, so a renderer that doesn't knowrendershows the code block, as it should.both: acodenode withrender: "both",componentandalt. A renderer shows the code block, then runs the component below it. A renderer that doesn't knowrendertreats it asoutput: it draws, and shows the code only as the fallback, which loses the code but nothing the reader can't read in the plain Markdown.
The schema (
compmd-tree.schema.json) gets the field, and the conformance set cases for each value, the default, a bad value, an evaluated value,sourcewithoutaltand the reserved name. -
Plain renderers show the code, whatever
rendersays. A plain renderer ignores the info string after the language, so every value degrades to the code block (spec §14), and GitHub draws a Mermaid block itself, as today. Nothing in §14's table changes; a sentence says so. -
Printing and plain text follow what shows. On paper (spec §14, Printing),
bothprints the code, then the drawing (or the drawing's fallback, byprint: fallback, once, as in decision 4);sourceprints the code. A document's plain text gives a rendered block's code once, as it does today, for every value: the code is the block's text and the drawing's fallback. -
A
```compmdblock takesrendertoo, and renders the CompMD it holds as an example: a document of its own. A```compmdblock with nocomponent=is a code block today, CompMD source shown as source. Withrender=outputorrender=bothit is an example: the processor processes its text as a.comp.mddocument and shows what that renders (withboth, after the code, as decision 3). This is what the guides'Example.sveltedoes, and what a post about CompMD needs.```compmd {render=both} --- rating: 4 --- Rated :value[4 of 5]{of=(string(md.doc.rating) + " of 5")}. ```
- The default stays
source, unlike a code renderer'soutput: every```compmdblock written so far is an example meant as source, so no document changes. A definition fence (```compmd component=card) isn't an example;renderon it is F008, as any key a definition fence doesn't take. - Its param list is read as a rendered block's (spec §7.7):
render, the common params,classandid, which apply to the example's box; any other key is F008 (an unknown param). Today the processor ignores what followscompmdon a block that isn't a definition; nothing written so far is a param list there, so this breaks nothing. Noalt: the example is content, read as it is, not a drawing. - Its own document, by the rule for imported documents (spec §6.3, scope is lexical). Its frontmatter is its own:
md.docis the example's keys, itsmdkey its version, imports, data and inputs, and an example without frontmatter is a version 1 document with none. Nothing of the outer document reaches it: not the outermd.doc, not its imports, data, inputs or definitions. Itscomponent=fences define components for it alone. What it imports and the data files it reads resolve from the outer document's place, so./sales.csvis next to the outer file, and they are loaded with the outer document's permissions (a processor that may not fetch for the outer document may not for the example). - Its inputs are its own, and the reader can change them. Its
inputsare declared in its frontmatter, as a document's, and start at their defaults; the values whoever runs the processor gives (a command-line argument, a URL query) are the outer document's only. Its input components change its inputs, and the processor renders the example again (spec §8.5), not the outer document. In the expanded tree the example's root lists its inputs, as a root does (spec §12.3), and an input param'sinputnames an input of the nearest root above it, so a renderer knows which documentsetchanges. How a processor keeps an example's values between renders is its business, as for a document (spec §8.7). - Its diagnostics are the outer document's, at their place in the block: line and column in the outer file, as the text is written there (the fence's indentation counted). So a broken example shows in the editor where it is written, and strict mode fails on it as on any fatal error. A post that shows an error on purpose writes it with
render=source. - One level. A
```compmdblock inside an example shows its source, whatever itsrendersays (W123, a new warning: "an example inside an example shows its source"), so an example can't hold examples to any depth. - The expanded tree: the
codenode,lang: "compmd", getsrenderanddocument, the example's expanded root (type: "root", itschildrenand itsinputs). A renderer shows the code block (forboth), then the root's children in the example's box. A renderer that doesn't knowdocumentshows the code block, which is the example's source, so nothing is lost. - Origins (spec §12.3) of the example's nodes are ranges of the outer document, where their text is written in the block, so an editor keeps an example's rendered parts through an edit as it does any node's.
- An example's components are its own (decided 2026-11-17). A renderer finds host-language components by name, and an example can define or import a
cardthat isn't the document'scard. So each example has a number, its place among the document's examples from 1, which its expanded root gives asexample; the processor's list of host-language components gives each one's example, absent for the document's own; and a renderer looks a component up among those of the nearest root above it. An example'scardand the document's are two entries, which never meet. - Components and the sandbox: an example's host-language components run as the outer document's do (running components in the sandbox): in frame mode in the outer document's frame, which the example renders in, and in host mode each use that isn't trusted in a frame of its own. Their trust levels are those the host gives the outer document's packs, so an example can't do more than its document.
- Plain renderers show the code, as for decision 6. Plain text gives the code once, as decision 7. Printing:
bothprints the code, then the example;outputthe example.
- The default stays
- The spec: §7.7, a bullet for
render(its values, its default, that it isn't evaluated, thatsourceneeds noalt, thatbothis one box, code first); §5.1's sentence onclass,idandaltnamesrender; §12.3, thecodenode'srender; §14, a sentence that plain renderers show the code for every value, and the printing and plain-text sentences; the catalog's F008, F009, F013 and W101 rows name it. Examples (decision 8): a new §7.8, Examples, for```compmdblocks, §6.3's lexical scope naming them, §8.7's sentence that an example's inputs are its own, §12.3'sdocumenton thecodenode and input params naming the nearest root's input, W123 in the catalog. A changelog entry under Unreleased. - The processor: the fence's param list reads
render(validate/params/fence.rs),sourceleaves the component out of the expandedcodenode (expand.rs), W101 skipssource. Examples: a```compmdblock's param list read; its text processed as a document from the outer document's place, its diagnostics moved to their place in the outer file, its root underdocument; W123; inputs given to an example by the API. The conformance cases for both. @compmd/renderand the sandbox: acodenode withrender: "both"renders as a box with the code block (highlighted, as any code block) and the component's mount below it; thecompmd-bothclass; the fallback shown once; print styles keep the two together when they fit (break-inside: avoid, as for a box). Acodenode withdocumentrenders the example's root in that box, its input components setting the example's inputs.- The blog and the guides: the blog's guide shows
render=bothin a post, and an example; the authors' guide shows both (chapter 17), the developers' guide how a host keeps an example's inputs (exampleSet,exampleInputs). The website'sExample.sveltestays: it shows examples on the site's own Svelte page, which isn't a CompMD document, so a```compmdblock can't take its place there. - Editors (CompMD in editors): the processor's hints complete
render's values on a code renderer's block, and an example's diagnostics are at their place in the document. The grammars and the language server are tasks of their own, still to come: they highlight a```compmdblock's text as CompMD, and complete an example'srender, whose hint has no component to name, unlike a rendered block's.
(2026-11-17) both is stacked by default (decision 3); compmd examples are part of this change (decision 8); F013 covers a declared render, alt (on a code renderer), class and id together, in this change (decision 1). The design was approved with an example's inputs as proposed: the reader can change them, and each example keeps its own (decision 8). An example's components are its own (option (a), decided 2026-11-17): its root's example number, the processor's host-language components listed with it, and renderers and the sandbox finding them by it.