reactive-md 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG-ch.md +333 -306
- package/CHANGELOG.md +334 -307
- package/CONTRIBUTING-ch.md +22 -22
- package/CONTRIBUTING.md +22 -22
- package/README-ch.md +431 -431
- package/README-en.md +431 -431
- package/README.md +429 -429
- package/SECURITY-ch.md +83 -83
- package/SECURITY.md +83 -83
- package/THIRD_PARTY_NOTICES.md +111 -1
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +263 -263
- package/cli/assets.mjs +395 -395
- package/cli/build.mjs +445 -444
- package/cli/check.mjs +444 -444
- package/cli/document.mjs +130 -130
- package/cli/errors.mjs +61 -61
- package/cli/fs-utils.mjs +133 -133
- package/cli/glob.mjs +203 -203
- package/cli/help.mjs +323 -323
- package/cli/init.mjs +1577 -1577
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +65 -65
- package/cli/migrate.mjs +368 -368
- package/cli/package-loader.mjs +41 -41
- package/cli/package.mjs +211 -211
- package/dist-library/{LocalDocumentView-K7Y-2bRJ.js → LocalDocumentView-BuqgJZEY.js} +11 -11
- package/dist-library/LocalDocumentViewCore-DXE0I0Qc.js +9830 -0
- package/dist-library/LocalReactiveDocumentCore-CWBe4Mm5.js +275 -0
- package/dist-library/{authoring-Co_TiE-P.js → authoring-Ci_KzJ0q.js} +87 -67
- package/dist-library/{compile-LhpTKqCR.js → compile-Dx6Uw3D9.js} +11 -11
- package/dist-library/{compiler-core-DTxY-qYz.js → compiler-core-DDDdvuLy.js} +2618 -1846
- package/dist-library/compiler-dxLPB9Ym.js +86 -0
- package/dist-library/{component-state-BBJ08vML.js → component-state-BRwvTV0d.js} +15 -14
- package/dist-library/component-state-CwKX_SN5.js +763 -0
- package/dist-library/{config-BUo-8O5C.js → config-DXLvctiZ.js} +68 -66
- package/dist-library/config-validation-D3D7Dy2J.js +586 -0
- package/dist-library/{controls-BWiLLtBO.js → controls-DoZyLCrV.js} +2434 -2410
- package/dist-library/{coordinate-BSl6enWV.js → coordinate-B1VFK9fd.js} +108 -107
- package/dist-library/{data-table-DfvytZKQ.js → data-table-8-3F15Jf.js} +69 -66
- package/dist-library/{default-components-BwQf0oP-.js → default-components-s21NevON.js} +29 -28
- package/dist-library/{display-lw3BT1TA.js → display-B_uutKkN.js} +1 -1
- package/dist-library/{config-validation-C5kJYk-J.js → document-theme-C8J6UyNO.js} +241 -731
- package/dist-library/export-CIAIPBov.js +370 -0
- package/dist-library/{gallery-B8kSt1oI.js → gallery-Dv1rOvL0.js} +151 -147
- package/dist-library/html-Cr4CBwAH.js +758 -0
- package/dist-library/identity-BUx0Q_-d.js +40 -0
- package/dist-library/{incremental-D_6vwAAE.js → incremental-9nx92u9c.js} +407 -143
- package/dist-library/layout-BBB2VF0S.js +562 -0
- package/dist-library/{mount-preset-C5s9ebEH.js → mount-preset-DMZ5wd3t.js} +3 -3
- package/dist-library/observability-4KqXhIEU.js +421 -0
- package/dist-library/observability-core-Bcu7vpnl.js +24 -0
- package/dist-library/options-BBp9IcHm.js +121 -0
- package/dist-library/{package-core-D0POW4Gd.js → package-core-K5xesGqy.js} +30 -29
- package/dist-library/{parser-standard-OToYcOBL.js → parser-standard-CBA1-hdG.js} +3332 -3840
- package/dist-library/{plugin-packs-B1XPWcFs.js → plugin-packs-Bh1HhLym.js} +3 -2
- package/dist-library/preset-core-DeZPA8IE.js +1298 -0
- package/dist-library/react-0DCh-Mar.js +7 -0
- package/dist-library/reactive-md-authoring.js +28 -30
- package/dist-library/reactive-md-build.js +99 -61
- package/dist-library/reactive-md-compiler-standard.js +10 -9
- package/dist-library/reactive-md-compiler.js +3 -3
- package/dist-library/reactive-md-default-packs.js +3 -2
- package/dist-library/reactive-md-default-preset.js +3 -2
- package/dist-library/reactive-md-export.js +4 -4
- package/dist-library/reactive-md-minimal-preset.js +2 -2
- package/dist-library/reactive-md-minimal-react-preset.js +3 -3
- package/dist-library/reactive-md-observability.js +4 -0
- package/dist-library/reactive-md-pdf.js +127 -3
- package/dist-library/reactive-md-plugin-chart.js +3 -3
- package/dist-library/reactive-md-plugin-data.js +5 -5
- package/dist-library/reactive-md-plugin-diagram.js +4 -4
- package/dist-library/reactive-md-plugin-forms.js +4 -4
- package/dist-library/reactive-md-plugin-gallery.js +3 -3
- package/dist-library/reactive-md-plugin-navigation.js +3 -3
- package/dist-library/reactive-md-plugin-network.js +119 -116
- package/dist-library/reactive-md-plugin-plot.js +4 -4
- package/dist-library/reactive-md-print.css +304 -304
- package/dist-library/reactive-md-react-minimal.js +4 -4
- package/dist-library/reactive-md-react-server.js +6 -6
- package/dist-library/reactive-md-react-unstyled.js +11 -12
- package/dist-library/reactive-md-react.js +11 -12
- package/dist-library/reactive-md-runtime-browser.js +2 -1
- package/dist-library/reactive-md-runtime.js +4 -3
- package/dist-library/reactive-md-sdk.js +8 -7
- package/dist-library/reactive-md-standalone-configured.js +2 -2
- package/dist-library/reactive-md-standalone-host.js +2 -2
- package/dist-library/reactive-md-testing-browser.js +2 -2
- package/dist-library/reactive-md-testing-react.js +6 -6
- package/dist-library/reactive-md-testing.js +5 -5
- package/dist-library/reactive-md.js +649 -373
- package/dist-library/{registry-05JiqmEp.js → registry-D6OGkOcX.js} +3 -3
- package/dist-library/{registry-core-Bbad9Bm2.js → registry-core-C9xOunaw.js} +1 -1
- package/dist-library/{resources-IeJomeUT.js → resources-B0x_w3s9.js} +71 -46
- package/dist-library/{runtime-B2fxeveq.js → runtime-BDnnimPA.js} +17 -16
- package/dist-library/{runtime-CuOyRe9f.js → runtime-BpQdZmFI.js} +269 -263
- package/dist-library/{schema-C-AeByPp.js → schema-BryM_VRW.js} +14 -14
- package/dist-library/{sdk-core-BJLJaVR5.js → sdk-core-ChslheKs.js} +499 -158
- package/dist-library/{session-core-BGka5D1J.js → session-core-dxQCJBNa.js} +171 -156
- package/dist-library/{shareable-jkGi2g6y.js → shareable-B8xMoGEa.js} +265 -297
- package/dist-library/types/authoring/catalog.d.ts +1 -2
- package/dist-library/types/build/diagnostics.d.ts +1 -1
- package/dist-library/types/components/shared/visual-frame.d.ts +6 -2
- package/dist-library/types/local/compilation/compiler-capabilities.d.ts +3 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +11 -3
- package/dist-library/types/local/compilation/compiler-services.d.ts +8 -4
- package/dist-library/types/local/compilation/compiler.d.ts +3 -3
- package/dist-library/types/local/compilation/session/incremental.d.ts +20 -5
- package/dist-library/types/local/compilation/streaming.d.ts +27 -0
- package/dist-library/types/local/configuration/capability-policy.d.ts +3 -0
- package/dist-library/types/local/configuration/diagnostic-messages.d.ts +48 -0
- package/dist-library/types/local/configuration/options-core.d.ts +1 -2
- package/dist-library/types/local/configuration/options.d.ts +1 -0
- package/dist-library/types/local/css/author-css.d.ts +66 -0
- package/dist-library/types/local/html/extended-fragment.d.ts +41 -0
- package/dist-library/types/local/html/html.d.ts +39 -3
- package/dist-library/types/local/index.d.ts +7 -1
- package/dist-library/types/local/observability-codes.d.ts +2 -0
- package/dist-library/types/local/observability-core.d.ts +25 -0
- package/dist-library/types/local/observability-messages.d.ts +6 -0
- package/dist-library/types/local/observability.d.ts +43 -0
- package/dist-library/types/local/parsing/author-markdown.d.ts +11 -0
- package/dist-library/types/local/parsing/parse-session.d.ts +2 -2
- package/dist-library/types/local/parsing/parser-convert.d.ts +2 -1
- package/dist-library/types/local/parsing/parser-core.d.ts +8 -1
- package/dist-library/types/local/parsing/parser-internals.d.ts +2 -1
- package/dist-library/types/local/parsing/parser.d.ts +2 -2
- package/dist-library/types/local/rendering/document/ExtendedHtmlFragment.d.ts +14 -0
- package/dist-library/types/local/rendering/document/LocalDocumentViewCore.d.ts +25 -1
- package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +1 -1
- package/dist-library/types/local/rendering/document/use-author-script.d.ts +3 -0
- package/dist-library/types/local/rendering/document/view-render-context.d.ts +11 -1
- package/dist-library/types/local/runtime/author-script-protocol.d.ts +59 -0
- package/dist-library/types/local/transport/worker.d.ts +79 -5
- package/dist-library/types/local/types.d.ts +60 -16
- package/dist-library/types/observability.d.ts +7 -0
- package/dist-library/types/react/component-api.d.ts +10 -1
- package/dist-library/types/react/component-utils.d.ts +9 -1
- package/dist-library/types/react/sdk-core.d.ts +4 -1
- package/dist-library/types/shareable.d.ts +5 -4
- package/dist-library/types/standalone/prepare.d.ts +1 -1
- package/dist-library/types/standalone/session-core.d.ts +3 -2
- package/dist-library/{types-BFC5rzC4.js → types-Ib5kSScP.js} +1 -1
- package/dist-library/types-daDo2c_w.js +3 -0
- package/dist-library/{validation-BlDL2uD9.js → validation-B3RI0xOk.js} +218 -200
- package/dist-library/version-DAxuGOG2.js +147 -0
- package/dist-library/{visual-frame-G8PHoj1e.js → visual-frame-_rcd5HUv.js} +6 -5
- package/dist-library/{visuals-BkYRmYGO.js → visuals-DkDhNdEZ.js} +24191 -24190
- package/dist-standalone/reactive-md-standalone.js +124 -117
- package/docs/README-ch.md +101 -94
- package/docs/README.md +101 -94
- package/docs/compatibility/api-stability-ch.md +25 -0
- package/docs/compatibility/api-stability-en.md +25 -0
- package/docs/compatibility/compatibility-ch.md +146 -129
- package/docs/compatibility/compatibility-en.md +146 -129
- package/docs/compatibility/compatibility-manifest.schema.json +161 -0
- package/docs/compatibility/deprecation-ch.md +21 -0
- package/docs/compatibility/deprecation-en.md +21 -0
- package/docs/compatibility/source-versioning-ch.md +162 -162
- package/docs/compatibility/source-versioning-en.md +162 -162
- package/docs/compatibility/support-matrix-ch.md +108 -0
- package/docs/compatibility/support-matrix-en.md +108 -0
- package/docs/development/component-development-ch.md +66 -66
- package/docs/development/component-development-en.md +66 -66
- package/docs/development/component-development-reference-ch.md +253 -253
- package/docs/development/component-development-reference-en.md +238 -238
- package/docs/development/component-protocol-ch.md +748 -748
- package/docs/development/component-protocol-en.md +750 -750
- package/docs/development/extension-tutorial-ch.md +308 -308
- package/docs/development/extension-tutorial-en.md +308 -308
- package/docs/development/performance-overview-ch.md +422 -422
- package/docs/development/performance-overview-en.md +422 -422
- package/docs/guides/local-guide-ch.md +532 -532
- package/docs/guides/local-guide-en.md +532 -532
- package/docs/integration/author-tools-ch.md +64 -64
- package/docs/integration/author-tools-en.md +64 -64
- package/docs/integration/compiler-ch.md +49 -47
- package/docs/integration/compiler-en.md +36 -34
- package/docs/integration/directory-discovery-en.md +1 -1
- package/docs/integration/editor-ch.md +295 -295
- package/docs/integration/editor-en.md +303 -303
- package/docs/integration/extension-sdk-ch.md +394 -394
- package/docs/integration/extension-sdk-en.md +379 -379
- package/docs/integration/local-integration-ch.md +646 -524
- package/docs/integration/local-integration-en.md +662 -540
- package/docs/integration/shareable-export-ch.md +307 -305
- package/docs/integration/shareable-export-en.md +309 -307
- package/docs/reference/diagnostics-counting-ch.md +104 -104
- package/docs/reference/diagnostics-counting-en.md +104 -104
- package/docs/reference/html-compatibility-ch.md +93 -140
- package/docs/reference/html-compatibility-en.md +95 -140
- package/docs/reference/local-interaction-syntax-ch.md +724 -724
- package/docs/reference/local-interaction-syntax-en.md +722 -722
- package/docs/reference/public-api-ch.md +39 -7
- package/docs/reference/public-api-en.md +39 -7
- package/docs/reference/theme-protocol-ch.md +198 -198
- package/docs/reference/theme-protocol-en.md +217 -217
- package/docs/releases/release-0.4.0-ch.md +91 -91
- package/docs/releases/release-0.4.0-en.md +91 -91
- package/docs/releases/release-0.4.1-ch.md +25 -25
- package/docs/releases/release-0.4.1-en.md +25 -25
- package/docs/releases/release-0.5.0-ch.md +43 -43
- package/docs/releases/release-0.5.0-en.md +43 -43
- package/docs/releases/release-0.5.1-ch.md +41 -41
- package/docs/releases/release-0.5.1-en.md +41 -41
- package/docs/releases/release-0.5.2-ch.md +37 -37
- package/docs/releases/release-0.5.2-en.md +37 -37
- package/docs/releases/release-0.5.3-ch.md +26 -26
- package/docs/releases/release-0.5.3-en.md +26 -26
- package/docs/releases/release-0.6.0-ch.md +59 -59
- package/docs/releases/release-0.6.0-en.md +59 -59
- package/docs/releases/release-0.6.1-ch.md +29 -29
- package/docs/releases/release-0.6.1-en.md +29 -29
- package/docs/releases/release-0.7.0-ch.md +86 -86
- package/docs/releases/release-0.7.0-en.md +86 -86
- package/docs/releases/release-0.9.1-ch.md +29 -0
- package/docs/releases/release-0.9.1-en.md +29 -0
- package/docs/releases/release-0.9.2-ch.md +33 -0
- package/docs/releases/release-0.9.2-en.md +33 -0
- package/examples/component-package/README-ch.md +101 -101
- package/examples/component-package/README.md +133 -133
- package/examples/conformance/README-ch.md +55 -55
- package/examples/conformance/README.md +55 -55
- package/examples/conformance/component-protocol-1.json +482 -482
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/local-draft-1.json +50 -50
- package/examples/conformance/local-draft-2.json +212 -212
- package/examples/game-2048-package/LICENSE +21 -21
- package/examples/game-2048-package/NOTICES.md +11 -11
- package/examples/game-2048-package/README-ch.md +91 -91
- package/examples/game-2048-package/README.md +98 -98
- package/examples/game-2048-package/package.json +35 -35
- package/examples/game-2048-package/sample/document.reactive.md +17 -17
- package/examples/game-2048-package/scripts/build-export.mjs +44 -44
- package/examples/game-2048-package/scripts/build.mjs +130 -130
- package/examples/game-2048-package/scripts/verify.mjs +180 -180
- package/examples/game-2048-package/src/component.css +161 -161
- package/examples/game-2048-package/src/components.tsx +326 -326
- package/examples/game-2048-package/src/game-engine.ts +228 -228
- package/examples/game-2048-package/src/harness.tsx +34 -34
- package/examples/game-2048-package/src/manifest.ts +85 -85
- package/examples/game-2048-package/src/node-entry.ts +30 -30
- package/examples/game-2048-package/src/sample.ts +4 -4
- package/examples/game-2048-package/tsconfig.json +15 -15
- package/examples/integration/README-ch.md +82 -63
- package/examples/integration/README.md +82 -63
- package/examples/integration/core/index.mjs +32 -32
- package/examples/integration/extension-sdk/README-ch.md +24 -24
- package/examples/integration/extension-sdk/README.md +24 -24
- package/examples/integration/streaming/index.html +48 -0
- package/examples/integration/streaming/main.js +175 -0
- package/examples/integration/streaming/package.json +13 -0
- package/examples/integration/streaming/worker.js +3 -0
- package/examples/integration/worker/index.html +19 -19
- package/examples/integration/worker/main.js +61 -61
- package/examples/integration/worker/package.json +13 -13
- package/examples/integration/worker/worker.js +3 -3
- package/examples/local/README-ch.md +76 -76
- package/examples/local/README.md +76 -76
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/recipes/invoice-zh.reactive.md +36 -36
- package/examples/local/recipes/invoice.reactive.md +36 -36
- package/examples/local/recipes/workshop-zh.reactive.md +33 -33
- package/examples/local/recipes/workshop.reactive.md +33 -33
- package/examples/local/showcase/README-ch.md +22 -22
- package/examples/local/showcase/README.md +31 -31
- package/examples/local/showcase/explore.reactive.md +102 -102
- package/examples/local/showcase/flow.reactive.md +86 -86
- package/examples/local/showcase/forms.reactive.md +126 -126
- package/examples/local/showcase/functions.reactive.md +119 -119
- package/examples/local/showcase/layout.reactive.md +100 -100
- package/examples/local/showcase/statistics.reactive.md +108 -108
- package/examples/local/showcase/tasks.reactive.md +89 -89
- package/examples/local/showcase/zh/explore.reactive.md +102 -102
- package/examples/local/showcase/zh/flow.reactive.md +86 -86
- package/examples/local/showcase/zh/forms.reactive.md +126 -126
- package/examples/local/showcase/zh/functions.reactive.md +119 -119
- package/examples/local/showcase/zh/layout.reactive.md +100 -100
- package/examples/local/showcase/zh/statistics.reactive.md +108 -108
- package/examples/local/showcase/zh/tasks.reactive.md +89 -89
- package/examples/minimal-extension/README-ch.md +78 -78
- package/examples/minimal-extension/README.md +78 -78
- package/examples/minimal-extension/index.html +15 -15
- package/examples/minimal-extension/package.json +26 -26
- package/examples/minimal-extension/sample/document.reactive.md +10 -10
- package/examples/minimal-extension/scripts/build.mjs +32 -32
- package/examples/minimal-extension/scripts/export.mjs +72 -72
- package/examples/minimal-extension/scripts/test-node.mjs +75 -75
- package/examples/minimal-extension/src/extension.tsx +90 -90
- package/examples/minimal-extension/src/preview.tsx +12 -12
- package/examples/minimal-extension/src/source.ts +4 -4
- package/examples/minimal-extension/tsconfig.json +14 -14
- package/examples/sci-fi-theme/README-ch.md +133 -133
- package/examples/sci-fi-theme/README.md +148 -148
- package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -454
- package/examples/sci-fi-theme/demo/demo.css +638 -638
- package/examples/sci-fi-theme/demo/document.reactive.md +206 -206
- package/examples/sci-fi-theme/demo/index.html +13 -13
- package/examples/sci-fi-theme/demo/main.tsx +215 -215
- package/examples/sci-fi-theme/docs/design-system-ch.md +245 -245
- package/examples/sci-fi-theme/docs/design-system.md +474 -474
- package/examples/sci-fi-theme/package.json +28 -28
- package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -98
- package/examples/sci-fi-theme/src/components.css +2370 -2370
- package/examples/sci-fi-theme/src/index.ts +6 -6
- package/examples/sci-fi-theme/src/notch.css +142 -142
- package/examples/sci-fi-theme/src/sci-fi.css +7 -7
- package/examples/sci-fi-theme/src/theme.ts +39 -39
- package/examples/sci-fi-theme/tsconfig.json +20 -20
- package/examples/sci-fi-theme/vite.config.ts +24 -24
- package/examples/tetris-package/LICENSE +21 -21
- package/examples/tetris-package/NOTICES.md +11 -11
- package/examples/tetris-package/README-ch.md +91 -91
- package/examples/tetris-package/README.md +95 -95
- package/examples/tetris-package/package.json +35 -35
- package/examples/tetris-package/sample/document.reactive.md +16 -16
- package/examples/tetris-package/scripts/build-export.mjs +44 -44
- package/examples/tetris-package/scripts/build.mjs +130 -130
- package/examples/tetris-package/scripts/verify.mjs +173 -173
- package/examples/tetris-package/src/component.css +145 -145
- package/examples/tetris-package/src/components.tsx +334 -334
- package/examples/tetris-package/src/harness.tsx +34 -34
- package/examples/tetris-package/src/manifests.ts +93 -93
- package/examples/tetris-package/src/node-entry.ts +16 -16
- package/examples/tetris-package/src/sample.ts +4 -4
- package/examples/tetris-package/src/tetris-engine.ts +325 -325
- package/examples/tetris-package/tsconfig.json +15 -15
- package/package.json +12 -1
- package/dist-library/LocalDocumentViewCore-BLG4hMuO.js +0 -9535
- package/dist-library/LocalReactiveDocumentCore-DVQ6WA9G.js +0 -259
- package/dist-library/compiler-DfGbQhyD.js +0 -62
- package/dist-library/component-state-BoLCGee4.js +0 -801
- package/dist-library/component-utils-BvHL8VGt.js +0 -298
- package/dist-library/export-C7IDW9ul.js +0 -311
- package/dist-library/layout-C22VjZh0.js +0 -542
- package/dist-library/options-CdSKOi7p.js +0 -116
- package/dist-library/preset-core-CKc5YXSM.js +0 -1443
- package/dist-library/react-LY5qsVeP.js +0 -7
|
@@ -1,722 +1,722 @@
|
|
|
1
|
-
# Reactive MD local interaction syntax specification
|
|
2
|
-
|
|
3
|
-
**English** · [中文](local-interaction-syntax-ch.md)
|
|
4
|
-
|
|
5
|
-
Syntax identifier: `local-draft-3`, 2026-10-31. If this is your first time with the syntax, read the [beginner guide](../guides/local-guide-en.md) first; this document is the complete specification. Hosts select local interaction mode through `compileLocal` and `LocalReactiveDocument`, see [integration notes](../integration/local-integration-en.md). See [Versions and compatibility](../compatibility/compatibility-en.md) for package version relationships, 0.x compatibility rules and migration, and [Source revisions and migration](../compatibility/source-versioning-en.md) for the optional revision directive and `reactive-md migrate`. Complete examples are in the [example index](../../examples/local/README.md).
|
|
6
|
-
|
|
7
|
-
## 1. Positioning and scope
|
|
8
|
-
|
|
9
|
-
Named values, formatting and date functions, cross-field validation, conditional tones, arrays and bounded table-row generation are part of this revision: [5.4 Named values](#54-named-values), [5.5 Formatting, strings and dates](#55-formatting-strings-and-dates), [5.6 Arrays and aggregates](#56-arrays-and-aggregates), [4.4 Cross-field validation](#44-cross-field-validation), [7.2 Conditional tones](#72-conditional-tones) and [9.5 Generated tables](#95-generated-tables).
|
|
10
|
-
|
|
11
|
-
See [Diagnostics and counting rules](diagnostics-counting-en.md) for source positions, text lengths and resource units. String `len()` and text-control length constraints count Unicode code points.
|
|
12
|
-
|
|
13
|
-
Reactive MD is for local interactive documents: authors write Markdown and place input controls; when readers adjust parameters, related text, formulas, charts and diagrams update immediately.
|
|
14
|
-
|
|
15
|
-
The base language requires only two connection rules: `bind` names an input, and `{{ expression }}` reads it elsewhere. Components handle their own selection, expansion, search, sorting, timing and reset.
|
|
16
|
-
|
|
17
|
-
This revision does not include external service calls, form submission, asynchronous resources, named actions, event handlers, programmable collection edits, general loop templates or arbitrary scripts. Legacy `state/data/computed/actions` configuration blocks are not part of this syntax. Expressions can produce string or numeric arrays; checklist and multi-select components produce string arrays. Tables can use prose Markdown or bounded local row generation through `data-table`.
|
|
18
|
-
|
|
19
|
-
By default a document only keeps in-memory state for the current instance. Reopening starts from initial values; persistence is not part of the author syntax. No language version declaration, component import or YAML is required. A document may optionally declare its revision with one `<!-- reactive-md: local-draft-3 -->` line in the prologue, before the theme and body; unversioned documents use the current revision. See [Source revisions and migration](../compatibility/source-versioning-en.md). Hosts should explicitly select draft parsing mode and must not guess by mixing old and new syntax.
|
|
20
|
-
|
|
21
|
-
Documents may select a theme with `<theme name="default">` before the body; omission uses `default`. This is static metadata, not a component. Custom themes must be registered by the host and support both color schemes; see the [theme protocol](theme-protocol-en.md).
|
|
22
|
-
|
|
23
|
-
## 2. Your first document
|
|
24
|
-
|
|
25
|
-
```markdown
|
|
26
|
-
# Cost estimate
|
|
27
|
-
|
|
28
|
-
<panel title="Adjust the plan">
|
|
29
|
-
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
30
|
-
<toggle bind="annual" label="Annual billing">
|
|
31
|
-
</panel>
|
|
32
|
-
|
|
33
|
-
Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Slider declares the number `people` with initial value 2; toggle declares the boolean `annual`, off by default. The panel provides restore-defaults by default, restoring its internal parameters at once.
|
|
37
|
-
|
|
38
|
-
When no cross-component linkage is needed, omit `bind`, for example `<counter label="People" initial="2">`. The component remains interactive; it just has no public variable.
|
|
39
|
-
|
|
40
|
-
## 3. Markdown and tags
|
|
41
|
-
|
|
42
|
-
### 3.1 Document structure
|
|
43
|
-
|
|
44
|
-
Headings, paragraphs, emphasis, links, images, quotes, lists, plain tables, inline code and code fences continue to use Markdown. Component tags may sit in a paragraph or a standalone block, depending on component type. Container contents continue to parse as Markdown; authors do not need to add a `markdown` attribute.
|
|
45
|
-
|
|
46
|
-
Code fences highlight common programming languages plus `latex` / `tex`, `cattca`, `mermaid`, `jinja` / `jinja2`, `dockerfile` / `docker` and `vue`. Vue single-file components highlight templates, JavaScript / TypeScript and CSS / SCSS separately; Cattca highlights Markdown narrative and command blocks. Mermaid fences display highlighted source. Unlabeled code is detected within a bounded set of common languages, with the detected language shown in the toolbar. Blocks without sufficient detection evidence stay plain. Use `text`, `txt`, `plaintext` or `nohighlight` to request plain text explicitly. Unknown languages and blocks longer than 20,000 characters preserve the original text. Highlighting and copying retain source whitespace.
|
|
47
|
-
|
|
48
|
-
Block component start and end tags each occupy a line. Attributes in a start tag may span multiple lines. A `>` inside a tag ends the tag only when it is outside quotes. Indentation is only for readability: container content is dedented by the common indentation and then parsed as Markdown; indentation inside code fences is preserved.
|
|
49
|
-
|
|
50
|
-
The inline components `badge`, `tooltip`, `jump` and `text` can be embedded in sentences. Other components are block components; `option`, `tab`, `disclosure`, `node`, `edge` and `step` are child components restricted to specific parent containers.
|
|
51
|
-
|
|
52
|
-
### 3.2 Two tag shapes
|
|
53
|
-
|
|
54
|
-
| Type | Form | Rules |
|
|
55
|
-
| --- | --- | --- |
|
|
56
|
-
| Void component | `<slider bind="a" label="Amplitude">` | No end tag; a trailing `/>` is also accepted |
|
|
57
|
-
| Container with content | `<card title="Notes">` and `</card>` | Must be explicitly closed; nesting is allowed |
|
|
58
|
-
|
|
59
|
-
Void components are fixed to `input`, `textarea`, `number`, `slider`, `range-slider`, `coordinate`, `toggle`, `checkbox`, `date`, `counter`, `timer`, `progress`, `anchor` and `edge`. The declaration tags `external`, `computed`, `const` and `validation`, and the structural `column`, also have no body. Every other component listed in this revision uses paired tags. `textarea` text is set through `initial`, so it is a void component.
|
|
60
|
-
|
|
61
|
-
For example:
|
|
62
|
-
|
|
63
|
-
```markdown
|
|
64
|
-
<card title="Plan notes">
|
|
65
|
-
Price updates with **People**.
|
|
66
|
-
|
|
67
|
-
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
68
|
-
|
|
69
|
-
Total cost: {{ people * 100 }} USD.
|
|
70
|
-
</card>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Tag names and attribute names use lowercase kebab-case; an end tag must match the most recently unclosed container. Automatic closing and correction of mismatched tags are not allowed. Legacy directives such as `:::card` are not interpreted as components.
|
|
74
|
-
|
|
75
|
-
### 3.3 Attributes
|
|
76
|
-
|
|
77
|
-
Regular attribute values are enclosed in single or double quotes; boolean attributes may omit their value. Attribute order has no semantics, and duplicate attributes are errors.
|
|
78
|
-
|
|
79
|
-
| Form | Meaning |
|
|
80
|
-
| --- | --- |
|
|
81
|
-
| `label="People"` | String |
|
|
82
|
-
| `max="20"` | Parsed as a number according to the component attribute definition |
|
|
83
|
-
| `required` | Boolean true |
|
|
84
|
-
| `required="false"` | Boolean false |
|
|
85
|
-
| `disabled="{{ people >= 20 }}"` | Dynamic boolean |
|
|
86
|
-
| `max="{{ rooms * 4 }}"` | Dynamic number constraint (`number`, `slider`) |
|
|
87
|
-
| `min="{{ departure }}"` | Dynamic date bound (`date`) |
|
|
88
|
-
| `required="{{ business }}"` | Dynamic required (`input`, `textarea`, `date`) |
|
|
89
|
-
| `label="Current people: {{ people }}"` | Text interpolation |
|
|
90
|
-
| `bind="people"` | Static variable name |
|
|
91
|
-
|
|
92
|
-
Omitted boolean attributes use the component default rather than always assuming false; for example `panel.reset` defaults to true.
|
|
93
|
-
|
|
94
|
-
`"`, `'`, `&`, `<` and `>` in attribute values decode to the corresponding characters; backslashes are not used to escape attribute quotes. Dynamic values for numeric and boolean attributes must be one complete interpolation and keep the original type; text attributes may contain multiple interpolations.
|
|
95
|
-
|
|
96
|
-
`bind`, `initial`, `name`, `id`, `value` (option identifier), `to`, `from`, `answer`, `kind`, field mappings and layout enums are static attributes. `min`, `max` and `required` are dynamic on `number`, `slider`, `date`, `input` and `textarea`: use one complete interpolation whose result is a number, a `YYYY-MM-DD` string (or empty string) or a boolean respectively. `step`, length limits, selector options and the range-slider/coordinate bounds remain static. Plot `min/max` may be dynamic to adjust the observed range. The `rows` attribute of `textarea` is a static row count, while `data-table.rows` is a required expression; do not confuse the two.
|
|
97
|
-
|
|
98
|
-
Dynamic constraints are checked when a value is written and when the control is displayed. Writes use the constraints in effect at that moment and still commit atomically. If another parameter narrows a range so that an existing value becomes invalid, the stored value is kept and the field shows the constraint error; it is never clamped, reset or snapped to a nearby legal value. Reducing the field to satisfy the new range, or restoring the dependency, clears the error. Dynamic `required` switching to true while the field is empty shows a hint and does not fill the field. A dynamic bound that cannot be evaluated, a dynamic `min` greater than `max`, or an invalid dynamic date bound rejects the related write and leaves state and revision unchanged. `runtime.validate()` keeps its cross-field meaning; dynamic constraint failures are enforced on writes and displayed on the field. Shared bindings must declare the same static range and step and, when a bound is dynamic, the same expression. `step` and text-length limits remain static.
|
|
99
|
-
|
|
100
|
-
Unknown components, unknown attributes, wrong positions or wrong attribute types all produce source diagnostics. Registered tags are not executed as arbitrary HTML; authors cannot use `script`, `style`, `onclick` or other script entry points.
|
|
101
|
-
|
|
102
|
-
### 3.4 Code, math and escaping
|
|
103
|
-
|
|
104
|
-
Prose such as `Array<T>`, `Map<string, number>`, `x<y` and currency `$5` or `$10` stays text. Complete formulas still use `$...$` or `$$...$$`; an unmatched single dollar sign stays literal.
|
|
105
|
-
|
|
106
|
-
The default path accepts the [P0 HTML subset](html-compatibility-en.md#p0-html-in-the-default-mode): text formatting, headings, containers, disclosures, quotations, code, lists, links and images. It produces controlled nodes and reuses the current theme and renderer. Ordinary single newlines remain Markdown soft breaks. Under the temporary routing policy, enabling author CSS, JavaScript or extended HTML sends the entire source to native HTML and stops Markdown and ReactiveMD interpretation.
|
|
107
|
-
|
|
108
|
-
Reference a footnote with `[^note]` and define it with `[^note]: Note text`. Continuation paragraphs, lists and code blocks use Markdown indentation. Definitions support Markdown and the basic HTML above. Notes appear at the end in first-reference order; repeated references share a number and each has a return link. Identifiers are case-insensitive and the first duplicate definition wins. Undefined references stay literal; unused definitions stay hidden. Controls and interpolations inside notes remain text and create no bindings or executable expressions.
|
|
109
|
-
|
|
110
|
-
Tags, interpolations and formula markers inside inline code and code fences are displayed verbatim. The source revision directive in the prologue is the recognized version comment; other Markdown comments `<!-- ... -->` produce no components or variables.
|
|
111
|
-
|
|
112
|
-
Use `\{{` in prose to display a literal `{{`, and `\<slider>` or inline code to show a tag example. These backslash escapes belong only to the Markdown context and do not apply to LaTeX sources.
|
|
113
|
-
|
|
114
|
-
The parser identifies code, math regions and tag boundaries first, then interprets interpolations; syntax cannot be implemented by string replacement over the whole document. Markdown inside tags, nested containers, multi-line attributes and original line/column positions must be preserved.
|
|
115
|
-
|
|
116
|
-
## 4. Parameters, bindings and initial values
|
|
117
|
-
|
|
118
|
-
### 4.1 Naming and types
|
|
119
|
-
|
|
120
|
-
`bind` uses `[A-Za-z_][A-Za-z0-9_]*` and is case-sensitive. Variable types are determined by the component, not guessed from text content. `x`, `y`, `pi`, `e`, `true`, `false`, `null` and expression built-in function names are reserved.
|
|
121
|
-
|
|
122
|
-
| Component | Public value | Default initial value |
|
|
123
|
-
| --- | --- | --- |
|
|
124
|
-
| input, textarea | String | Empty string |
|
|
125
|
-
| date | Date string or empty string | Empty string |
|
|
126
|
-
| number | Number | The valid step value within range closest to 0 |
|
|
127
|
-
| slider | Number | min, with a default range of 0 to 100 |
|
|
128
|
-
| counter | Number | The valid step value within range closest to 0 |
|
|
129
|
-
| toggle, checkbox | Boolean | false |
|
|
130
|
-
| select, choices, radio-group | Option string | value of the first option |
|
|
131
|
-
| multi-select | String array of selected option values | Empty array |
|
|
132
|
-
| range-slider | Two numbers, `start` / `end` slots | start=min; end=the largest valid step not exceeding max |
|
|
133
|
-
| coordinate | Two numbers, `x` / `y` slots | The valid step value on each axis closest to 0 |
|
|
134
|
-
| table, chart with `key` | Stable row key string | Empty string (unselected) |
|
|
135
|
-
| tabs | Page string | value of the first tab |
|
|
136
|
-
| steps | Step string | value of the first step |
|
|
137
|
-
| diagram | Node ID string | id of the first node |
|
|
138
|
-
| checklist | String array of selected item IDs | Determined by the task list check marks |
|
|
139
|
-
| timer | Remaining seconds | duration, default 60 |
|
|
140
|
-
|
|
141
|
-
Scalar components use `initial` to override the default. `range-slider` and `coordinate` use `initial-start`/`initial-end` and `initial-x`/`initial-y` for their slots; `multi-select` accepts a comma-separated `initial` list of static option values. `timer` uses `duration` and `checklist` uses the check marks in its body; neither accepts `initial`. A `table` or `chart` selection accepts `initial` only together with `key`. Dates use real, valid `YYYY-MM-DD`; an empty string means not yet selected.
|
|
142
|
-
|
|
143
|
-
`bind` may be omitted. Unnamed components have independent internal state and do not derive a variable name from the tag. A control's `label` is required and may use dynamic text; it is also the control's accessible name.
|
|
144
|
-
|
|
145
|
-
### 4.2 Same-name controls and declaration order
|
|
146
|
-
|
|
147
|
-
The compiler collects bindings across the whole document before rendering, including bindings in conditional regions. Prose can reference parameters that appear later. Declarations and initial values do not change with condition truth, mount count or scroll position.
|
|
148
|
-
|
|
149
|
-
Number, text or boolean inputs of the same kind may bind the same variable and stay in sync; types must match, and numeric ranges and steps must be identical. When `select/choices/radio-group` share a variable, the value set and order must also be identical. Label text may differ.
|
|
150
|
-
|
|
151
|
-
A variable may have at most one explicit `initial`. Without an explicit initial value, the default of the first control in the source is used, and all associated constraints are validated. Later controls omitting `initial` share the existing initial value. The public state of `timer/checklist/tabs/diagram/multi-select/steps` is owned by exactly one component and does not accept a second same-name owner or writes from other controls. Each numeric slot of `range-slider` and `coordinate` is exclusive too. A `table` and a `chart` may share a selection binding only when their ordered `key` sets are identical.
|
|
152
|
-
|
|
153
|
-
Referencing an undeclared variable is an immediate error and does not silently create an empty value. Component initial values are document initialization data; showing a hidden control again does not initialize it again.
|
|
154
|
-
|
|
155
|
-
### 4.3 Updates, input drafts and reset
|
|
156
|
-
|
|
157
|
-
Valid input commits immediately and updates everything that depends on it. Composition input with a Chinese IME commits when composition ends; intermediate states such as an empty string or a minus sign in a number field remain only as an editing draft. If the value is still invalid on blur, an error is shown while other content keeps reading the last valid value.
|
|
158
|
-
|
|
159
|
-
Numeric constraints use finite numbers, `step > 0`, `min <= max`. Steps are based on min, or on 0 when min is absent, with an implementation-defined floating-point tolerance. An explicit initial outside the range or off the step is an error, not silently corrected. Default initial values are generated from constraints; when two valid values are equidistant from 0, the smaller one is used, and an error occurs when no step value is available.
|
|
160
|
-
|
|
161
|
-
Disabled controls do not accept reader input. A panel reset commits all parameters and component internal state inside it at once, triggers one consistent view update, and clears editing drafts. Displays of shared variables outside the panel change accordingly.
|
|
162
|
-
|
|
163
|
-
When a conditional region is hidden, existing state, tab selection and checklist checks are preserved. Timers in hidden regions pause and stay paused when shown again until the reader starts them. Disposing a document releases timers, subscriptions and component state.
|
|
164
|
-
|
|
165
|
-
### 4.4 Cross-field validation
|
|
166
|
-
|
|
167
|
-
```markdown
|
|
168
|
-
<number bind="people" label="Participants" initial="4" min="1" max="20">
|
|
169
|
-
<number bind="capacity" label="Room capacity" initial="3" min="1" max="20">
|
|
170
|
-
<validation when="{{ people <= capacity }}" message="Choose a room for at least {{ people }} people." fields="people capacity">
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
`validation` is a void block component with required `when`, `message` and `fields`. `when` contains one complete boolean expression. `message` is text with optional ordinary interpolations. `fields` lists distinct public writable binding names separated by whitespace; names from multi-slot controls are accepted. A rule can read controls and computed values, including values declared later in the source. Fields identify the controls associated with the rule's hint, and read-only declarations cannot be fields.
|
|
174
|
-
|
|
175
|
-
Constraints report the current consistency of a document, so readers can still edit an inconsistent plan, including one whose initial values fail a cross-field rule. Changing the participant count from four to six can temporarily exceed room capacity; changing the room then clears the hint. Individual control rules such as numeric bounds and invalid calendar dates keep their write-rejection behavior.
|
|
176
|
-
|
|
177
|
-
`runtime.validate()` returns diagnostics for all current failed rules in source order. It reports `local.validation.failed` when `when` is false and `local.validation.expression` when an expression cannot be evaluated; an expression error counts as a failure. One failed rule does not stop independent rules. The result is cached for the current runtime revision and returned as defensive copies. Edits, atomic slot updates and resets refresh calculations and validation together.
|
|
178
|
-
|
|
179
|
-
The renderer displays failed-rule hints and associates them with the corresponding controls or their accessible groups through `aria-describedby` and `aria-invalid`. Hint IDs belong to the mounted document instance, and success removes the error text. Rules in hidden content remain active, as do their bindings; hidden hints do not announce themselves. A document supports at most 100 validation rules, including hidden regions, and diagnostic messages retain the existing 2,000-character bound.
|
|
180
|
-
|
|
181
|
-
`LocalDocument.validations` contains serializable `LocalValidation` metadata. Hosts can call `runtime.validate()` at any time without changing state, and the compiled document remains transferable to a Worker with `structuredClone`.
|
|
182
|
-
|
|
183
|
-
## 5. Text interpolation and expressions
|
|
184
|
-
|
|
185
|
-
```markdown
|
|
186
|
-
People: {{ people }}.
|
|
187
|
-
Total: {{ people * 100 }} USD.
|
|
188
|
-
Billing: {{ annual ? 'annual' : 'monthly' }}.
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Interpolation can appear in paragraphs, headings, emphasis, lists, plain table cells and attributes that allow dynamic values. Strings, finite numbers and booleans display directly; null displays as empty; arrays must first be converted with functions such as `len` and are not implicitly output as JSON. Output is treated as text.
|
|
192
|
-
|
|
193
|
-
### 5.1 Expression set
|
|
194
|
-
|
|
195
|
-
| Category | Supported |
|
|
196
|
-
| --- | --- |
|
|
197
|
-
| Literals | Numbers, single- or double-quoted strings, true, false, null |
|
|
198
|
-
| Parameters | bind names declared in the document |
|
|
199
|
-
| Arithmetic | `+ - * / %`, unary plus/minus, parentheses |
|
|
200
|
-
| Comparison | `== != < <= > >=` |
|
|
201
|
-
| Logic | `!`, `&&`, `\|\|` |
|
|
202
|
-
| Conditional | `condition ? trueValue : falseValue` |
|
|
203
|
-
| Math functions | abs, sqrt, floor, ceil, round, min, max, pow, sin, cos, tan, asin, acos, atan, exp, log |
|
|
204
|
-
| Common functions | len, contains, clamp |
|
|
205
|
-
| Formatting | formatNumber, formatPercent, formatScientific, formatCurrency |
|
|
206
|
-
| Strings | trim, lower, upper, startsWith, endsWith, replace, slice |
|
|
207
|
-
| Dates | dateCompare, dateDiff |
|
|
208
|
-
| Array aggregates | sum, average, minOf, maxOf |
|
|
209
|
-
| Constants | pi, e |
|
|
210
|
-
|
|
211
|
-
Precedence runs from function calls/parentheses, unary operators, multiplication/division/remainder, addition/subtraction, relational comparison, equality comparison, logical AND, logical OR, to conditional expressions; conditional expressions are right-associative and other binary operators are left-associative. Logic and conditional expressions short-circuit.
|
|
212
|
-
|
|
213
|
-
`+` accepts two numbers or two strings. Comparisons do not implicitly convert between strings and numbers; relational comparison accepts only two numbers or two strings; logical operations and if conditions must be booleans. Expression string escapes use `\\`, `\'`, `\"`, `\n`, `\t`.
|
|
214
|
-
|
|
215
|
-
min/max accept one or more numbers; pow takes a base and an exponent; clamp takes a value, lower bound and upper bound. Other math functions take one number, trigonometric functions use radians, and log is the natural logarithm. round rounds half values toward positive infinity. len computes the number of Unicode code points in a string or the length of an array; contains checks a substring or array membership.
|
|
216
|
-
|
|
217
|
-
Multiplication in prose expressions must be written `*`; use `pow` for exponents. LaTeX math regions follow their own mathematical writing rules. Expressions have no assignment, method calls, property access, custom functions or imports, and do not provide legacy runtime contexts such as `event` or `resources`.
|
|
218
|
-
|
|
219
|
-
Pipes in GFM tables must be written `\|`, for example logical OR as `\|\|`. Table parsing handles Markdown pipe escapes first, then sends cell expressions to the evaluator.
|
|
220
|
-
|
|
221
|
-
### 5.2 Calculation errors
|
|
222
|
-
|
|
223
|
-
Division by zero, domain errors, non-finite results and type errors are shown near the corresponding content. When the parameter itself is valid, the user's new input is kept, and other independent content keeps updating; the error result shows "Unable to compute" instead of reusing an old number as a new result.
|
|
224
|
-
|
|
225
|
-
### 5.3 Host-provided external data
|
|
226
|
-
|
|
227
|
-
A document may declare read-only values supplied by the host:
|
|
228
|
-
|
|
229
|
-
```markdown
|
|
230
|
-
<external name="exchangeRate" type="number">
|
|
231
|
-
<external name="inventory" type="number">
|
|
232
|
-
<computed name="priceCny" value="{{ priceUsd * exchangeRate }}">
|
|
233
|
-
|
|
234
|
-
Price: {{ priceCny }} CNY
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
`name` follows the same identifier and reserved-name rules as bindings. `type` is one of `string`, `number`, `boolean`, `string-array` or `number-array`. Declarations must be standalone tags at the document top level, cannot repeat a control parameter or another external name, and do not appear in the rendered document or in a state file. Text interpolation, conditions, charts and computations may read them; `setParameter()` cannot write them.
|
|
238
|
-
|
|
239
|
-
The host supplies values through `externalValues` on `LocalReactiveDocument` or `runtime.setExternalValues()`. Values are validated against the declared type and the usual size budgets. When a value is missing, only expressions that read that name fail locally; independent content keeps working, and the dependent content recalculates when the value arrives. A missing value is never converted to `0`, `false` or an empty string. Static export and SSR behave the same way: pass the values into the host integration; an export does not fetch or embed them.
|
|
240
|
-
|
|
241
|
-
Top-level `computed` and `const` declarations provide named read-only values; see [5.4 Named values](#54-named-values). Short calculations can still be written in place; use declarations for intermediate results shared by prose, conditions, formulas and charts.
|
|
242
|
-
|
|
243
|
-
### 5.4 Named values
|
|
244
|
-
|
|
245
|
-
```markdown
|
|
246
|
-
<const name="unitPrice" value="{{ 12.5 }}">
|
|
247
|
-
<computed name="total" value="{{ quantity * unitPrice }}">
|
|
248
|
-
<computed name="invoice" value="{{ formatCurrency(total) }}">
|
|
249
|
-
|
|
250
|
-
<number bind="quantity" label="Quantity" initial="2" min="0" max="100">
|
|
251
|
-
|
|
252
|
-
Invoice: **{{ invoice }}**.
|
|
253
|
-
|
|
254
|
-
<if when="{{ total >= 100 }}">
|
|
255
|
-
Eligible for bulk delivery.
|
|
256
|
-
</if>
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
`computed` and `const` are invisible, void declarations. Write each on its own line at document top level; `/>` is accepted too. Both require `name` and a complete `value="{{ expression }}"`. Their values use the expression types: number, string, boolean, null, string array or numeric array. The compiler infers the type; there is no type annotation or implicit conversion.
|
|
260
|
-
|
|
261
|
-
Names follow the same identifier and reserved-name rules as `bind`. Controls, multi-slot bindings and declarations share one namespace. A declaration cannot replace another declaration or a control. Declarations inside containers are compile errors. Code fences, inline code and comments remain literal or inert.
|
|
262
|
-
|
|
263
|
-
Declarations are visible throughout the document, including before their source position. A `computed` value may read controls, constants and other computations. A `const` may read other constants and built-in constants such as `pi`; it stays independent of controls and computations. Constants have no editing or reset control.
|
|
264
|
-
|
|
265
|
-
The compiler extracts dependencies from the expression AST, including all conditional branches, and orders declarations by dependency before inferring types. Unknown names, duplicate names, self references and indirect cycles produce source-positioned errors. A cycle in an unused branch is still a compile error. Type checking uses the same operator and function rules as ordinary expressions; runtime domain errors remain possible, for example division by a control that becomes zero. Names declared by top-level `<external>` tags are valid read-only dependencies for `computed` values, text and conditions; a `const` cannot depend on external data, and external names never become writable parameters.
|
|
266
|
-
|
|
267
|
-
Use a named value anywhere an expression is accepted: prose, dynamic attributes, conditions and numeric table cells used by charts. Computable LaTeX formulas read multi-letter numeric names as `\mathrm{total}`, for example `y = \mathrm{total} x`. Formatted strings belong in labels or prose; numeric chart cells and plot parameters need the underlying number.
|
|
268
|
-
|
|
269
|
-
Each runtime owns its calculation cache. Computations are reused within a revision and refreshed after a successful control edit, atomic multi-slot edit or panel reset. Constants are evaluated at compilation and copied into each runtime. Hiding a section keeps its inputs and calculations; reset follows the existing control subtree rules.
|
|
270
|
-
|
|
271
|
-
A failed calculation propagates its expression error when a consumer reads it. The runtime never substitutes zero, null or a previous successful value. Independent consumers continue to work, and a valid input edit lets failed consumers recover. Runtime logical and conditional operators keep their short-circuit behavior, so an unvisited branch does not read its failed value. A constant with an invalid static value is a compile error.
|
|
272
|
-
|
|
273
|
-
`document.bindings` and `document.initialState` describe writable controls. `document.computations` contains serializable declaration metadata, and `document.externals` contains the read-only external declarations. `runtime.snapshot().state` also contains successful named results for the current revision; failed results are absent. Use `runtime.evaluate(name)` to read a result with its error semantics. Declarations cannot be changed through `set` or `setMany`. Returned arrays remain protected from external mutation.
|
|
274
|
-
|
|
275
|
-
Declaration diagnostics use `local.computation.*`: `placement`, `name`, `reserved`, `duplicate`, `value`, `unknown`, `cycle`, `const`, `expression` and `budget`. Expression type errors keep the existing `local.expression.*` codes, and diagnostics include source ranges, lines and columns. The graph uses an iterative dependency order, so long chains do not require recursive evaluation. Existing source, syntax-node, expression and value budgets still apply, and cycle reports are capped by the diagnostic budget.
|
|
276
|
-
|
|
277
|
-
Expression function names are reserved identifiers. A binding or declaration cannot use `sum`, `formatNumber`, `dateDiff` or any other function listed in [5.1](#51-expression-set); the compiler reports the conflict with a reserved-name diagnostic. Rename the name and its references.
|
|
278
|
-
|
|
279
|
-
### 5.5 Formatting, strings and dates
|
|
280
|
-
|
|
281
|
-
All four formatting functions return strings; optional arguments are positional.
|
|
282
|
-
|
|
283
|
-
| Function | Defaults and example |
|
|
284
|
-
| --- | --- |
|
|
285
|
-
| `formatNumber(value, digits, locale, grouping)` | `digits=2`, `locale="en-US"`, `grouping=true`; `formatNumber(1234.5)` gives `"1,234.50"` |
|
|
286
|
-
| `formatPercent(value, digits, locale)` | `digits=0`, `locale="en-US"`; `formatPercent(0.125, 1)` gives `"12.5%"` |
|
|
287
|
-
| `formatScientific(value, digits, locale)` | `digits=2`, `locale="en-US"`; `formatScientific(1234)` gives `"1.23E3"` |
|
|
288
|
-
| `formatCurrency(value, currency, digits, locale)` | `currency="USD"`, `digits=2`, `locale="en-US"`; `formatCurrency(12.5)` gives `"$12.50"` |
|
|
289
|
-
|
|
290
|
-
`digits` is an integer from 0 to 20 and fixes both minimum and maximum fraction digits, including for currencies such as JPY. `grouping` is a boolean. Supported locales are exactly `en-US`, `zh-CN`, `de-DE`, `fr-FR` and `ja-JP`; omission uses `en-US` regardless of the renderer's UI language or device settings, and an unsupported locale is an error. Currency codes are three uppercase ASCII letters accepted by `Intl.NumberFormat`; the check is syntactic and does not consult a registry of circulating currencies.
|
|
291
|
-
|
|
292
|
-
Formatting uses decimal `halfExpand` rounding: ties round away from zero, so `formatNumber(1.005)` gives `"1.01"` and `formatNumber(-1.005)` gives `"-1.01"`. Zero displays without a negative sign. Arithmetic still uses finite JavaScript numbers; `round(x)` keeps its `Math.round` rule, with ties toward positive infinity. Formatting changes presentation, not the source number.
|
|
293
|
-
|
|
294
|
-
A null value formats as an empty string. Other argument types remain strict, and strings are not converted into numbers, so guard optional dates or text explicitly before applying their functions. Locale-specific punctuation, currency symbols and spacing follow the host's `Intl` data; hosts that need byte-identical text across platforms pin their runtime and locale data.
|
|
295
|
-
|
|
296
|
-
| String function | Behavior |
|
|
297
|
-
| --- | --- |
|
|
298
|
-
| `trim(text)` | Remove leading and trailing JavaScript Unicode whitespace |
|
|
299
|
-
| `lower(text)`, `upper(text)` | Default Unicode case conversion, independent of locale |
|
|
300
|
-
| `startsWith(text, search)`, `endsWith(text, search)` | Case-sensitive literal checks; empty search matches |
|
|
301
|
-
| `replace(text, search, replacement)` | Replace every non-overlapping literal match; empty search is an error; replacement text such as `$&` stays literal |
|
|
302
|
-
| `slice(text, start, end)` | Unicode code point indices; end is exclusive and defaults to the length; negative indices count from the end; indices are integers and clamp to bounds |
|
|
303
|
-
|
|
304
|
-
These functions require strings, including when the value is null. No regular expressions or property access are available. Code points are distinct from grapheme clusters: a combined emoji or an accented letter can contain several code points. All results keep the existing string budget of 100,000 UTF-16 code units, and replacement expansion is checked before constructing an oversized result.
|
|
305
|
-
|
|
306
|
-
`dateCompare(a, b)` returns `-1`, `0` or `1`. `dateDiff(a, b, unit)` returns the signed difference **a minus b**; the default unit is `"days"`, and other units are `"hours"`, `"minutes"`, `"seconds"` and `"milliseconds"`.
|
|
307
|
-
|
|
308
|
-
Both arguments must be valid `YYYY-MM-DD` strings in years `0001` through `9999`, matching date controls. The calendar is Gregorian and leap days are validated. Each date means midnight UTC, so device timezone and daylight saving changes do not change the result: `dateDiff("2026-03-09", "2026-03-08", "hours")` is `24`. Timestamps, timezone suffixes and ambiguous regional date strings are rejected.
|
|
309
|
-
|
|
310
|
-
An empty date control contains `""`, which is an absent date rather than epoch zero. Empty or invalid dates produce a domain error, and null produces a type error. Guard optional dates explicitly:
|
|
311
|
-
|
|
312
|
-
```markdown
|
|
313
|
-
<computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
|
|
314
|
-
Days: {{ days == null ? 'Choose both dates' : formatNumber(days, 0) }}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### 5.6 Arrays and aggregates
|
|
318
|
-
|
|
319
|
-
```markdown
|
|
320
|
-
<const name="fixedFees" value="{{ [100, 20, 5] }}">
|
|
321
|
-
<computed name="fees" value="{{ [people * 80, includeKit ? people * 20 : 0] }}">
|
|
322
|
-
|
|
323
|
-
First fee: {{ fees[0] }}. Total: {{ sum(fees) }}.
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
Array literals contain only strings or only finite numbers. Expressions inside a literal can read the document's named values. Nested arrays, mixed element types, booleans and null elements are rejected. `[]` is an empty numeric array by default; a direct empty literal in a conditional branch adopts a string-array sibling's kind, so `show ? subjects : []` works for string selections. Checklist and multi-select values remain string arrays. The public type `LocalValue` gains `number[]`, and `LocalValueKind` gains `number-array`; the existing `array` kind continues to mean a string array.
|
|
327
|
-
|
|
328
|
-
Indexing is zero based: `values[0]` reads the first element. The index must be a finite safe integer. An integer outside the collection, including a negative index, returns null; a non-integer index is an error. Indexing a string or a scalar is a type error. Arrays cannot be interpolated as text; use an index, `len`, an aggregate or a data table.
|
|
329
|
-
|
|
330
|
-
`len` counts both kinds of array. `contains` accepts a string member for a string array, a number for a numeric array, and a substring for a string. Every array is bounded by 10,000 elements; array literals also consume the existing expression-length, AST-node and evaluation budgets. The total contents of a string array keep the existing character budget. Returned runtime arrays are copied, and snapshot arrays are frozen.
|
|
331
|
-
|
|
332
|
-
| Function | Result |
|
|
333
|
-
| --- | --- |
|
|
334
|
-
| `sum(values)` | Sum of a numeric array; empty input gives `0` |
|
|
335
|
-
| `average(values)` | Arithmetic mean; empty input gives null |
|
|
336
|
-
| `minOf(values)` | Smallest numeric member; empty input gives null |
|
|
337
|
-
| `maxOf(values)` | Largest numeric member; empty input gives null |
|
|
338
|
-
|
|
339
|
-
Aggregates accept numeric arrays, with no conversion of numeric-looking strings. Results use finite JavaScript numbers; an overflow in the sum or result is an expression error. `average` divides the sum by the count, so an overflowing intermediate sum is also an error. Null from an empty aggregate follows the existing nullable-expression rules, so guard it before numeric operations when needed. Scalar `min`, `max` and `round` keep their existing signatures and behavior.
|
|
340
|
-
|
|
341
|
-
## 6. Inputs and parameter panels
|
|
342
|
-
|
|
343
|
-
All input components support `label`, optional `bind`, optional scalar `initial` and dynamic `disabled`. Additional attributes are listed below; unlisted attributes are not part of this revision.
|
|
344
|
-
|
|
345
|
-
| Component | Additional attributes and defaults |
|
|
346
|
-
| --- | --- |
|
|
347
|
-
| input | type=text/email; placeholder; required=false (dynamic); min-length=0; optional max-length |
|
|
348
|
-
| textarea | placeholder; rows=4; required=false (dynamic); min-length=0; optional max-length |
|
|
349
|
-
| number | optional min/max (dynamic); step=1 |
|
|
350
|
-
| slider | min=0; max=100 (both dynamic); step=1 |
|
|
351
|
-
| range-slider | bind-start/bind-end and initial-start/initial-end; min=0; max=100; step=1; optional color |
|
|
352
|
-
| coordinate | bind-x/bind-y and initial-x/initial-y; x-min/y-min=-5; x-max/y-max=5; step=1; optional color |
|
|
353
|
-
| counter | min=0; optional max; step=1 |
|
|
354
|
-
| toggle, checkbox | Optional color |
|
|
355
|
-
| date | optional min/max dates (dynamic); required=false (dynamic) |
|
|
356
|
-
| select, choices, radio-group, multi-select | Body is one or more options; multi-select adds max-selected and uses a string-array value |
|
|
357
|
-
|
|
358
|
-
`range-slider` and `coordinate` are leaves with required `label`, optional `color` and dynamic `disabled`. Bounds and the positive step are static finite numbers. `range-slider` defaults to 0/100/1, with start=min and end=the largest valid step not exceeding max. Crossing is rejected rather than swapping endpoints. `coordinate` defaults to -5…5 on both axes, step 1, and the nearest legal zero per axis. It supports pointer dragging, keyboard control and numeric alternatives.
|
|
359
|
-
|
|
360
|
-
Each optional `bind-start`/`bind-end` or `bind-x`/`bind-y` names one exclusive numeric slot; an omitted name keeps that slot internal. `x` and `y` remain reserved parameter names. Slots initialize at compile time and reset atomically. Host APIs extend to `runtime.get(node, slot?)`, `runtime.set(node, value, slot?)` and `runtime.setMany(node, values)`. Slots are start/end for ranges and x/y for coordinates. Every write validates canonical registered slots; an invalid batch preserves the entire snapshot and revision, and existing one-value calls remain valid.
|
|
361
|
-
|
|
362
|
-
`multi-select` requires a `label` and one or more option children; `bind` is optional. Its exclusive string-array binding defaults to empty. `initial` is a comma-separated list of static values; values are nonempty, unique and comma-free. `max-selected` is a nonnegative integer, defaulting to the option count. Writes normalize to source order and obey the existing array budgets. Search and Clear are built in, and selected items remain removable at the limit. `disabled` may be dynamic; reset clears local search and restores the initial selection, while hiding preserves them. `multi-select` also accepts an optional `color`.
|
|
363
|
-
|
|
364
|
-
Selector example:
|
|
365
|
-
|
|
366
|
-
```markdown
|
|
367
|
-
<choices bind="plan" label="Usage" initial="personal">
|
|
368
|
-
<option value="personal">Personal</option>
|
|
369
|
-
<option value="team">Team</option>
|
|
370
|
-
</choices>
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
option.value is a non-empty, static, unique string; the body is the option's inline text, may contain emphasis, and must not contain another interactive component. select is a dropdown, choices is option cards, and radio-group is a radio button group; binding rules are the same.
|
|
374
|
-
|
|
375
|
-
`required`, length and email format show hints after the first blur and update with input afterwards. Controls allow an empty initial document value; hints do not produce submissions or network operations. New text with an invalid format remains a draft and does not replace the last valid public value. An empty initial value is public as an empty string until the reader fills it in.
|
|
376
|
-
|
|
377
|
-
`counter` has built-in decrement, increment and restore-initial buttons, and disables the corresponding action at range boundaries. `timer` supports label, optional bind and duration (positive integer seconds, default 60); it has built-in start, pause and reset, stops at zero, updates according to actual elapsed time, and does not accumulate timing error after switching to the background.
|
|
378
|
-
|
|
379
|
-
`panel` is a container supporting an optional title and reset (default true). It lays out vertically by default and provides restore-defaults. `reset="false"` hides the reset action. Nested panels are allowed: an inner reset affects only the inner panel, while an outer reset covers the whole subtree; child controls not yet shown in a condition are also in scope. Panel reset also restores table queries, sorting, paging, tab selection and diagram selection in the subtree.
|
|
380
|
-
|
|
381
|
-
## 7. Layout and content exploration
|
|
382
|
-
|
|
383
|
-
| Container | Attributes | Body and default behavior |
|
|
384
|
-
| --- | --- | --- |
|
|
385
|
-
| card | optional title | Regular Markdown; a content card |
|
|
386
|
-
| grid | columns=2 (integer 1–4, maximum column count) | Direct children are card; fewer columns in narrow containers, including nested grids and embedded documents |
|
|
387
|
-
| tabs | optional label, bind, initial | One or more tab, first selected by default |
|
|
388
|
-
| tab | label required, optional value | Regular Markdown |
|
|
389
|
-
| accordion | optional label | One or more disclosure |
|
|
390
|
-
| disclosure | label required; open=false | Click to expand; multiple entries can be open at once |
|
|
391
|
-
| if | when required, complete boolean interpolation | Shows Markdown and components when true |
|
|
392
|
-
| alert | optional title; tone=info/success/warning/error, default info | Regular Markdown |
|
|
393
|
-
| badge | tone=neutral/success/warning, default neutral | Inline text |
|
|
394
|
-
| tooltip | text required | Focusable inline explanatory text |
|
|
395
|
-
|
|
396
|
-
When tab has no value, `tab-1`, `tab-2` and so on are generated in source order; values in the same group must be unique. Without bind, tabs do not name page state; with bind, the current value is exposed publicly. Switching tabs preserves child content state and pauses hidden timers. The initial `open` state inside accordion is restored on reset.
|
|
397
|
-
|
|
398
|
-
When if's when is false, content is not displayed, but internal parameters are still initialized according to section 4. Unknown variables or type errors in hidden branches are still compile errors.
|
|
399
|
-
|
|
400
|
-
### 7.1 Navigation, color and guided reading
|
|
401
|
-
|
|
402
|
-
| Container or inline tag | Attributes | Body and default behavior |
|
|
403
|
-
| --- | --- | --- |
|
|
404
|
-
| jump | to required; appearance=link/button, default link; optional color | Inline Markdown; scrolls to a heading slug or explicit anchor |
|
|
405
|
-
| anchor | id required and unique | No body; marks an explicit jump target |
|
|
406
|
-
| text | color required | Inline Markdown and interpolation; sets foreground color |
|
|
407
|
-
| section | color required | Block Markdown; sets inherited foreground color without a border or background |
|
|
408
|
-
| quiz | type=choice/number, default choice; label and answer required; optional explanation and tolerance | Choice quizzes contain options; numeric quizzes have an empty body. No public bind |
|
|
409
|
-
| steps | optional label, bind and initial; exclusive string binding | One or more step children; first step selected by default |
|
|
410
|
-
| step | label required; optional value | Markdown body; omitted values become step-1, step-2 and so on |
|
|
411
|
-
|
|
412
|
-
`jump.to` is a static heading slug or explicit anchor ID, written without a leading `#`. Explicit IDs match `[A-Za-z_][A-Za-z0-9_-]*`. Duplicate anchors, heading collisions and missing targets are compile errors. DOM IDs are namespaced per rendered document. Jumps scroll and move focus, and a hidden target shows local feedback. Existing Markdown fragment links also resolve explicit anchors.
|
|
413
|
-
|
|
414
|
-
`text` and `section` require `color`. Other supported components accept an optional `color`: jump, badge, progress, slider, toggle, checkbox, select, choices, radio-group, checklist, multi-select, range-slider and coordinate. Static named colors from the shared table and `#RGB`/`#RRGGBB` are accepted. Expressions, CSS functions, variables and declarations are rejected. Text containers set foreground color, and inner values override inheritance; links and controls keep their own appearance. Other components use color for their accent, selected state or progress fill, while `tone` keeps its semantic meaning. Omitted values use the theme.
|
|
415
|
-
|
|
416
|
-
`quiz` requires `label` and `answer`. `type` defaults to `choice`, with option children and a matching answer. A numeric quiz has an empty body, a finite `answer` and a nonnegative absolute `tolerance` defaulting to 0. `explanation` is optional and supports text interpolation. Check answer, feedback and Try again are built in. Drafts and feedback stay inside the component; this revision has no `quiz` bind. Hiding preserves them and panel reset clears them. Answers are supplied in source for self-study.
|
|
417
|
-
|
|
418
|
-
`steps` accepts one or more `step` children, optional `label` and an exclusive string `bind`. `initial` defaults to the first step. Each `step` requires `label`; omitted values become `step-1`, `step-2` and so on, and values are unique within a group. Previous/Next and position are built in. Only active content is visible; all bindings still initialize, state persists between steps, and hidden timers pause. Reset restores the initial step and its subtree.
|
|
419
|
-
|
|
420
|
-
Base layout uses Markdown; images use ``, links use `[text](../address)`, and horizontal rules use `---`. Images load only after the host explicitly allows them through a URL policy; by default no image requests are made. See [Image and link policy](../integration/local-integration-en.md#image-and-link-policy) for integration. This revision does not provide author tags for row, stack, spacer, icon, image or link-button, and does not expose class/style.
|
|
421
|
-
|
|
422
|
-
### 7.2 Conditional tones
|
|
423
|
-
|
|
424
|
-
```markdown
|
|
425
|
-
<badge tone="{{ total <= budget ? 'success' : 'warning' }}">{{ formatCurrency(total) }}</badge>
|
|
426
|
-
<alert tone="{{ total <= budget ? 'info' : 'warning' }}">Review the estimate before booking.</alert>
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
`badge` accepts dynamic `tone` with `neutral`, `success` and `warning`; `alert` accepts `info`, `success`, `warning` and `error`. Static `tone` values use the same enums. A dynamic expression must have string type, and the renderer checks the returned value against the component's allowed tones. An error or unsupported value uses the default tone and a visible computation hint. CSS classes, author styles and colors remain outside this conditional API.
|
|
430
|
-
|
|
431
|
-
The enum covers info, warning, success and error emphasis while keeping theme colors and contrast under host control. Broader conditional styling is outside the author syntax.
|
|
432
|
-
|
|
433
|
-
## 8. Checklists
|
|
434
|
-
|
|
435
|
-
```markdown
|
|
436
|
-
<checklist bind="done" label="Try it out">
|
|
437
|
-
- [x] Read the source document
|
|
438
|
-
- [ ] Adjust parameters and observe the result
|
|
439
|
-
- [ ] Try it at phone width
|
|
440
|
-
</checklist>
|
|
441
|
-
|
|
442
|
-
Completed {{ len(done) }} / 3 items.
|
|
443
|
-
<progress label="Completion" value="{{ len(done) / 3 * 100 }}">
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
The checklist body is a non-empty, single-level Markdown task list, checked by the reader by default. Plain Markdown task lists remain static content. Items may contain inline Markdown but must not contain nested task lists or interactive components.
|
|
447
|
-
|
|
448
|
-
Fixed entries generate internal IDs `item-1`, `item-2` and so on in order; the public value is an array of checked IDs in source order, and `[]` when nothing is selected. Entries are not added, removed or reordered during a document instance; they are regenerated after editing the source and creating a new instance. Reset restores the initial state specified by `[x]` / `[ ]`. Supports label, optional bind and dynamic disabled. Checked item text is struck through and muted, including initial `[x]` items; unchecking restores it, and only the checked item changes.
|
|
449
|
-
|
|
450
|
-
progress is a void component; label/value are required, max defaults to 100, and value may be dynamic; max must be a positive finite number, value must be between 0 and max, and out-of-range values show a diagnostic instead of being silently clamped.
|
|
451
|
-
|
|
452
|
-
## 9. Tables and statistical charts
|
|
453
|
-
|
|
454
|
-
### 9.1 Shared data rules
|
|
455
|
-
|
|
456
|
-
The ReactiveMD table, chart and timeline components each contain one Markdown table. Headers are non-empty and unique, and every row has the same number of columns; cells may contain interpolation. The first column is usually a label, and other columns read types according to the component.
|
|
457
|
-
|
|
458
|
-
`<table>` also accepts a native HTML table body. Body structure selects the syntax; both share the rendering styles. HTML tables support merged cells and add no table interactions by default. See [HTML table compatibility](html-compatibility-en.md#two-table-syntaxes).
|
|
459
|
-
|
|
460
|
-
Plain text cells display Markdown; plain decimal or scientific-notation text cells can be read as numbers, and a single complete interpolation keeps its result type. Mixed text such as `{{ price }} USD` is a display string and cannot be used as a numeric chart column. Legend labels take the plain text of headers.
|
|
461
|
-
|
|
462
|
-
There is no need to declare a YAML array first, and remote URLs, data attributes or API return values are not accepted. Errors such as empty rows, non-numeric values or missing columns are located at the corresponding cell.
|
|
463
|
-
|
|
464
|
-
### 9.2 Enhanced tables
|
|
465
|
-
|
|
466
|
-
```markdown
|
|
467
|
-
<table label="Component catalog" page-size="3">
|
|
468
|
-
| Name | Category | Price |
|
|
469
|
-
| --- | --- | ---: |
|
|
470
|
-
| Document | Basic | 20 |
|
|
471
|
-
| Form | Input | 45 |
|
|
472
|
-
| Chart | Visual | 80 |
|
|
473
|
-
</table>
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
table supports optional label, searchable=true, sortable=true and page-size=10 (positive integer). It provides a search box, sortable headers and paging by default; paging controls are hidden when there is only one page.
|
|
477
|
-
|
|
478
|
-
`key` names a column of static, nonempty, unique text identifiers. Selection is enabled only when `key` is present, so `bind` and `initial` require it. The bound value is an empty string when no row is selected by default, and an explicit `initial` must match a row. Mouse or keyboard selection writes row identity. A table and a chart may share a selection binding only with identical ordered keys and at most one explicit initial. Sorting, searching, pagination and hidden chart legends preserve the selection; table filters still affect only that table, and components without `key` gain no implicit binding. Reset restores the initial selection along with the rest of the subtree.
|
|
479
|
-
|
|
480
|
-
Search is a case-insensitive substring match over the displayed text of all columns, trimming whitespace from the query; sorting uses the full column type, numerically for numeric columns and by Unicode code point order for text otherwise, preserving the original order of equal rows. Clicking a header cycles ascending, descending and source order. Search or sort changes return to the first page, and reactive data changes clamp the current page to the valid range. No matches shows "No matching results". These interactions affect only the table.
|
|
481
|
-
|
|
482
|
-
### 9.3 Charts
|
|
483
|
-
|
|
484
|
-
```markdown
|
|
485
|
-
<chart kind="bar" title="Cost and budget">
|
|
486
|
-
| Item | Actual | Budget |
|
|
487
|
-
| --- | ---: | ---: |
|
|
488
|
-
| Content | 120 | 150 |
|
|
489
|
-
| Visual | 230 | 200 |
|
|
490
|
-
</chart>
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
chart.kind defaults to bar and supports bar, line, area, scatter, donut and pie. Supports optional title, x, y, x-label and y-label. x/y are static header names; y may be a comma-separated list of column names, so column names cannot contain commas.
|
|
494
|
-
|
|
495
|
-
| Type | Default column rules |
|
|
496
|
-
| --- | --- |
|
|
497
|
-
| bar, line, area | First column is the horizontal axis; other columns are numeric series |
|
|
498
|
-
| scatter | First column is the numeric horizontal axis and the rest are numeric vertical axes; x/y may also specify them |
|
|
499
|
-
| donut | First column is the label and second is the value; with more than two columns, y must specify the single numeric column |
|
|
500
|
-
| pie | Uses the same table rules as donut, with solid slices to show shares |
|
|
501
|
-
|
|
502
|
-
line/area determine the horizontal axis as numeric or categorical from the full column type and connect in source order. donut/pie values must be non-negative, and a zero total shows "No share to display". Series names become legends automatically; pointer and keyboard readouts are provided by default without event logic.
|
|
503
|
-
|
|
504
|
-
Interactive default-theme charts provide themed tooltips, legend highlighting and 200ms data transitions. Line and area charts read visible series in the same row; bars read one hovered bar; scatter charts find the nearest point; pie and donut charts show values and shares of the visible total. Static mode keeps the data graphics and removes hover interaction and animation.
|
|
505
|
-
|
|
506
|
-
Numeric columns update with parameters. Calculation errors display in the corresponding chart and are not replaced with 0. With `key`, a chart exposes selection through `bind` under the same row-key rules as `table`.
|
|
507
|
-
|
|
508
|
-
### 9.4 Timelines
|
|
509
|
-
|
|
510
|
-
timeline supports optional title and unit (display text, default "minutes"), and its body is a table with either `Task`, `Start` and `Duration` columns or `事项`, `开始` and `时长` columns, plus optional `Notes` or `说明`. These column names are fixed headers; start and duration are non-negative numbers. Sorting is stable by start time, overlapping intervals are allowed, and notes are viewed with a pointer or keyboard. Table content may use interpolation.
|
|
511
|
-
|
|
512
|
-
### 9.5 Generated tables
|
|
513
|
-
|
|
514
|
-
```markdown
|
|
515
|
-
<const name="subjects" value="{{ ['mathematics', 'physics', 'chemistry'] }}">
|
|
516
|
-
|
|
517
|
-
<data-table label="Subject preparation" rows="{{ subjects }}" key="{{ item }}" max-rows="3">
|
|
518
|
-
<column label="Subject" value="{{ item }}">
|
|
519
|
-
<column label="Position" value="{{ index + 1 }}">
|
|
520
|
-
<column label="Preparation" value="{{ item == 'chemistry' ? 'Prepare materials' : 'Prepare examples' }}">
|
|
521
|
-
</data-table>
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
`data-table` is a paired block component. It requires an accessible `label`, a complete array expression in `rows`, and a complete string or number expression in `key`. Its only children are 1 to 20 void `column` declarations. A column requires a static `label` and a complete scalar `value` expression. Cells output plain text; null gives an empty cell.
|
|
525
|
-
|
|
526
|
-
Each row has two local names: `item` is the current string or number, and `index` is its current zero-based position. These names shadow same-named document values inside column expressions. Other references use the normal document environment. The source `rows` expression uses ordinary document scope.
|
|
527
|
-
|
|
528
|
-
Keys depend only on `item`, including at least one reference to it. They cannot depend on `index` or other document values. The table checks that every evaluated key is a nonempty string or finite number and is unique. Numeric and string keys have distinct identities; signed numeric zeros have the same identity. React rows retain their identities when their items reorder. For records with repeated display values, use a collection of distinct local IDs as `rows` and derive the display cells from those IDs. Duplicate or invalid keys produce a whole-table error.
|
|
529
|
-
|
|
530
|
-
`max-rows` is a static integer from 1 to 1,000, defaulting to 100. Across the document, declared row budgets may total at most 2,000 and row budgets multiplied by their column counts may total at most 10,000 cells. Hidden tables count too. Each generated table also has a budget of 100,000 UTF-16 code units for header text, cell text, error and empty placeholders, and encoded row keys. The renderer checks budgets before exposing rows; exceeding them reports an error without truncating the data.
|
|
531
|
-
|
|
532
|
-
An empty array displays the headers and an empty-state message. Failure of the row source or a key clears the table's rows and displays an error. A cell-expression failure is shown in that cell while independent cells remain readable. The component creates native table rows, not arbitrary repeated document sections or controls. Markdown tables and their existing chart inputs keep their original behavior.
|
|
533
|
-
|
|
534
|
-
## 10. LaTeX math and function plots
|
|
535
|
-
|
|
536
|
-
### 10.1 Display and plotting
|
|
537
|
-
|
|
538
|
-
KaTeX typesets formulas with bundled math fonts, producing visual HTML and MathML for assistive technology. Fonts are inlined in the standard stylesheet so previews, printing and exported single-file HTML work offline. Hosts using `reactive-md/react/unstyled` must load `reactive-md/styles.css` or supply KaTeX styles and fonts. Formula display and plot evaluation are handled separately.
|
|
539
|
-
|
|
540
|
-
Prose accepts `$...$` or `\(...\)` for inline math, and `$$...$$` or `\[...\]` for display formulas. Dollar-delimited inline math pairs on the same line and permits leading or trailing whitespace, as in `$ x $`, `$x $` and `$ x$`. Its content must include a non-whitespace character. Currency text such as `$5 and $10` stays literal; use `\$` for an explicit literal dollar sign. Backslash-delimited formulas may contain whitespace and span lines. For example, write `\(\frac{a}{b}\)` in a sentence or `\[x^2 + 1\]` as a display formula. Unclosed math delimiters are errors; an unmatched single dollar sign stays literal. Code, comments and Markdown destinations keep these delimiters literal; escape the opening backslash or use code to show an example in prose.
|
|
541
|
-
|
|
542
|
-
Standalone formulas are for layout and create no state or functions. Each `$$...$$` block inside a plot container defines one curve; the math content keeps normal LaTeX syntax and does not need `{{ }}`. Plot accepts only `$$...$$`, not `\(...\)` or `\[...\]`.
|
|
543
|
-
|
|
544
|
-
Display supports KaTeX math commands and environments, including `cases`, `aligned`, `align`, `align*`, `matrix`, `pmatrix`, `bmatrix` and `vmatrix`. Use `&` for columns and `\\` for rows. Alignment environments alternate right and left column alignment; matrices center their cells and show the corresponding delimiters. Both `align` and `aligned` belong inside math delimiters. Add explicit equation labels to display formulas with `\tag{1}`, or `\tag*{A}` to omit parentheses. Use `\displaystyle`, `\textstyle`, `\limits` and `\nolimits` to control style and limit placement.
|
|
545
|
-
|
|
546
|
-
| Display content | Example commands |
|
|
547
|
-
| --- | --- |
|
|
548
|
-
| Alphabets and text | `\mathbb{R}`, `\mathcal{F}`, `\mathscr{L}`, `\mathfrak{g}`, `\textbf{bold text}` |
|
|
549
|
-
| Binomials, annotations and boxes | `\binom{n}{k}`, `\underbrace{a+b}_{n}`, `\overrightarrow{AB}`, `\underline{x}`, `\boxed{x}` |
|
|
550
|
-
| Above/below labels and labeled arrows | `\stackrel{!}{=}`, `\underset{x}{\lim}`, `\xrightarrow[below]{above}`, `\xrightleftharpoons[k_2]{k_1}` |
|
|
551
|
-
| Logic, relations and symbols | `\implies`, `\iff`, `\not\in`, `\cong`, `\mapsto`, `\mid`, `\ll`, `\oplus`, `\varnothing`, `\therefore`, `\because`, `\triangle`, `\circ`, `\dagger`, `\vdots`, `\ddots` |
|
|
552
|
-
| Arrows, delimiters and sizes | `\rightleftharpoons`, `\longrightarrow`, `\Longleftrightarrow`, `\downarrow`, `\lfloor`, `\rfloor`, `\lceil`, `\rceil`, `\bigl(`, `\bigr)`, `\Bigg(` |
|
|
553
|
-
| Functions and congruences | `\sec`, `\csc`, `\cot`, `\sinh`, `\cosh`, `\lg`, `\pmod{n}` |
|
|
554
|
-
|
|
555
|
-
`align` numbers its rows automatically; use `align*` or `aligned` to omit automatic numbering. Numbering counters are scoped to each document.
|
|
556
|
-
|
|
557
|
-
Use mhchem notation for chemistry: `$\ce{H2O}$`, `$\ce{SO4^2-}$`, `$\ce{^{14}_{6}C}$`, `$$\ce{2 H2 + O2 -> 2 H2O}$$` or `$$\ce{A <=>[forward][reverse] B}$$`. KaTeX's mhchem extension typesets molecular subscripts, ionic charges, isotopes, coefficients, physical states, bonds and reaction arrows. Invalid or unsupported formulas produce a `local.math.display` warning and fall back to bounded source text for the whole formula. Input and conversion have resource budgets; author-defined macros, HTML, file and network entry points are disabled. These forms are available for formula display; plotting computation supports the syntax listed below.
|
|
558
|
-
|
|
559
|
-
```markdown
|
|
560
|
-
<slider bind="a" label="Amplitude" initial="1" min="0" max="5">
|
|
561
|
-
|
|
562
|
-
<plot min="-10" max="10">
|
|
563
|
-
$$ y = a \sin x + \frac{x^2}{10} $$
|
|
564
|
-
</plot>
|
|
565
|
-
```
|
|
566
|
-
|
|
567
|
-
The plot body may contain only whitespace and one or more display formula blocks. Each block defines one curve in one of four forms:
|
|
568
|
-
|
|
569
|
-
```markdown
|
|
570
|
-
<plot min="-10" max="10">
|
|
571
|
-
$$ y = a \sin x + \frac{x^2}{10} $$
|
|
572
|
-
$$ \begin{cases} x = t - \sin t \\ y = 1 - \cos t \end{cases} $$
|
|
573
|
-
$$ r = a(1 + \cos\theta) $$
|
|
574
|
-
$$ (x^2 + y^2)^2 = 2a^2(x^2 - y^2) $$
|
|
575
|
-
</plot>
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
The first block is explicit `y = f(x)`. The second is parametric: `x` and `y` are written as functions of `t`, and `t` runs from `min` to `max`; both axes fit the sampled points. Any other equation in `x` and `y` is implicit and is traced as a contour over `min` to `max` on both axes; the axes then fit the traced curve. Use multiple formula blocks for multiple curves; do not use plain line breaks as separators.
|
|
579
|
-
|
|
580
|
-
The third block is polar, `r = f(\theta)`: `min` and `max` set the angle interval in radians. Directly typed `θ` and `\theta` are equivalent and may be mixed. Both spellings are local to the curve, while other numeric parameters can read document bindings. Samples are projected to `x = r cos(θ)`, `y = r sin(θ)`, and both axes fit the result. Negative radii preserve direction; undefined radii form breaks. This example samples 1000 evenly spaced points over one full turn:
|
|
581
|
-
|
|
582
|
-
```markdown
|
|
583
|
-
<plot min="0" max="{{ 2 * pi }}" points="1000">
|
|
584
|
-
$$ r = 1 + \cos\theta $$
|
|
585
|
-
</plot>
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
plot supports min=-10, max=10 (dynamic allowed, requiring min < max), points=200 (static integer 2–2000), optional label, x-label="x" and y-label="y". Quote attribute values, as in `points="1000"`. The existing `samples` attribute remains supported; `points` takes precedence when both are supplied, and the default is 200 when both are omitted. Each plot has at most 16 curves. An explicit, parametric or polar curve requests the specified number of sample points, including both endpoints. An implicit curve uses the specified number of grid points per axis, capped at 100 and raised to at least 32, and requests the corresponding grid area. The whole document may request at most 20,000 points across all curves, including hidden regions. Curves share a computation budget, and exceeding it stops computation and reports an error. The vertical axis is determined automatically from finite sample values in the current range; if there are no valid values, an empty state is shown. Constant curves should add visible vertical-axis headroom.
|
|
589
|
-
|
|
590
|
-
### 10.2 Computable LaTeX
|
|
591
|
-
|
|
592
|
-
This revision requires plotting computation to support the following math forms. Formula layout and computation capability are validated separately; being able to lay out a formula does not mean it can be evaluated.
|
|
593
|
-
|
|
594
|
-
| Math content | Syntax |
|
|
595
|
-
| --- | --- |
|
|
596
|
-
| Numbers, four operations | `2`, `0.5`, `+`, `-`, `/`, `\cdot`, `\times` |
|
|
597
|
-
| Implicit multiplication | `2x`, `ax`, `a\sin x`, `(x+1)(x-1)` |
|
|
598
|
-
| Exponents | `x^2`, `x^{a+1}`, `e^x` |
|
|
599
|
-
| Fractions | `\frac{a}{b}`, `\dfrac{a}{b}`, `\tfrac{a}{b}` |
|
|
600
|
-
| Roots | `\sqrt{x}`, `\sqrt[3]{x}` |
|
|
601
|
-
| Grouping | `(...)`, `{...}`, `\left(...\right)` |
|
|
602
|
-
| Trigonometric functions | `\sin`, `\cos`, `\tan`, `\arcsin`, `\arccos`, `\arctan` |
|
|
603
|
-
| Exponential and logarithm | `\exp(x)`, `\ln x`, `\log x`, `\log_{2}x` |
|
|
604
|
-
| Absolute value | `\lvert x\rvert`, `\left\lvert x\right\rvert` |
|
|
605
|
-
| Other functions | `\min(a,b)`, `\max(a,b)` |
|
|
606
|
-
| Constants | `\pi`, `e` |
|
|
607
|
-
| Piecewise functions | `\begin{cases} ... \end{cases}` |
|
|
608
|
-
| Piecewise conditions | `=`, `\ne`/`\neq`, `<`, `>`, `\le`/`\leq`, `\ge`/`\geq` |
|
|
609
|
-
|
|
610
|
-
Trigonometric functions use radians; ln is the natural logarithm, log without a base is base 10 by convention, and with a subscript it uses the written base. Roots compute real numbers; odd integer roots allow negative numbers, while negative inputs to even roots are invalid samples. Absolute value accepts both paired vertical bars and `\left|...\right|`; bars must be paired, and missing boundaries are not guessed.
|
|
611
|
-
|
|
612
|
-
Multiplication must use `*` in expression contexts and may be omitted in LaTeX. LaTeX multiplication and division (including implicit multiplication) share precedence and associate left to right; exponents bind before unary minus, so `-x^2` is `-(x^2)`. `1/2x` is interpreted as `(1/2)x`; use fractions to make the denominator explicit.
|
|
613
|
-
|
|
614
|
-
A function without parentheses reads the product of the following term and ends at addition/subtraction, comparison, comma or the next function command; for example `\sin 2x` is sin(2x), `\sin x + a` is sin(x)+a, and `\sin x\cos x` is sin(x)cos(x). Use parentheses for complex arguments. `\sin^2 x` is supported and means `(sin x)^2`; inverse trigonometric functions use explicit names such as arcsin, and `\sin^{-1}` is not guessed to mean the inverse function.
|
|
615
|
-
|
|
616
|
-
`\left`, `\right`, the math spacing commands `\,`, `\;`, `\!`, `\quad` and `%` comments to end of line do not change computation. In piecewise functions, `&` separates values from conditions and `\\` separates branches; the first branch whose condition is true is used. `\text{otherwise}` may serve as the final default branch; if no branch matches, the point is undefined. Conditions support only a single comparison; express complex piecewise behavior with multiple branches.
|
|
617
|
-
|
|
618
|
-
Matrices, sums, integrals, derivatives and custom macros are not in the computable set. When these structures are encountered, keep displaying the formula and point out the command or structure that cannot be computed; do not guess a plot from another formula. Within a parametric `cases` block, `t` is the parameter and the branches may not read `x`. The math renderer must disable file, network, HTML and macro execution entry points.
|
|
619
|
-
|
|
620
|
-
### 10.3 Parameter name mapping
|
|
621
|
-
|
|
622
|
-
A single Latin letter maps to a same-name bind, for example `a` maps to `bind="a"`. Adjacent plain letters mean multiplication: `abx` is a×b×x.
|
|
623
|
-
|
|
624
|
-
Multi-letter names are written as `\mathrm{amplitude}` and read as `bind="amplitude"` as a whole. This is a Reactive MD naming convention; the command must contain a complete valid bind name, with no spaces or interpolation.
|
|
625
|
-
|
|
626
|
-
`\alpha`, `\beta`, `\gamma`, `\theta`, `\omega`, `\lambda`, `\mu` and `\sigma` map to same-name English binds. Other Greek parameters use `\mathrm{name}` for explicit references in the first version; `\pi` is fixed as the circle constant.
|
|
627
|
-
|
|
628
|
-
`x` is the plot variable and `y` is the output marker; neither can be bound to a control. Parameters must be numbers; undeclared parameters and wrong types are diagnosed before plotting.
|
|
629
|
-
|
|
630
|
-
### 10.4 Breaks, readouts and updates
|
|
631
|
-
|
|
632
|
-
Curves are recomputed when parameters change. Division by zero, non-real results and overflow points form breaks, and the two sides of a break are not connected directly. The plotting implementation must also subdivide suspected discontinuous intervals to avoid incorrect connections when asymptotes cross finite sample points.
|
|
633
|
-
|
|
634
|
-
A legend and pointer/keyboard readouts are provided by default. The curve legend uses the respective math formulas; move the pointer to the end of a curve to read that point's value.
|
|
635
|
-
|
|
636
|
-
## 11. Interactive diagrams
|
|
637
|
-
|
|
638
|
-
```markdown
|
|
639
|
-
<diagram bind="selected" initial="input" label="Reactive state flow" direction="right">
|
|
640
|
-
<node id="input" label="Input">
|
|
641
|
-
The reader changes parameters through controls.
|
|
642
|
-
</node>
|
|
643
|
-
<node id="compute" label="Compute">
|
|
644
|
-
Recompute formulas and results.
|
|
645
|
-
</node>
|
|
646
|
-
<node id="view" label="Display">
|
|
647
|
-
Update prose and charts.
|
|
648
|
-
</node>
|
|
649
|
-
<edge from="input" to="compute" label="State change">
|
|
650
|
-
<edge from="compute" to="view" label="Update result">
|
|
651
|
-
</diagram>
|
|
652
|
-
```
|
|
653
|
-
|
|
654
|
-
diagram supports optional label, bind and initial, with direction=right/down (default right). The body contains only node, edge and whitespace. At least one node is required; node requires id and label, and its body is static Markdown notes that may contain text interpolation but not interactive controls.
|
|
655
|
-
|
|
656
|
-
node.id is a `[A-Za-z_][A-Za-z0-9_-]*` unique within the current diagram. edge requires from/to and supports an optional label; both ends must exist. Fully duplicate from/to/label combinations are errors, while parallel edges with different labels are allowed. Cycles and self-loops are allowed.
|
|
657
|
-
|
|
658
|
-
Nodes are laid out automatically from relationships, with source order determining order within a layer; cycles are grouped as a whole before layout. The first version requires no coordinates and provides no author coordinate overrides.
|
|
659
|
-
|
|
660
|
-
Nodes are clickable and keyboard-selectable by default, and the selected notes appear in the diagram's detail area. With bind, the selected node id is public; without bind, selection stays inside the component. initial must point to an existing node and defaults to the first. The labels of diagram and edge, as well as node.label, support text interpolation. node also supports dynamic tone=neutral/success/warning, default neutral.
|
|
661
|
-
|
|
662
|
-
## 12. Component reference and syntax scope
|
|
663
|
-
|
|
664
|
-
| Purpose | Components |
|
|
665
|
-
| --- | --- |
|
|
666
|
-
| Parameter input | input, textarea, number, slider, range-slider, coordinate, toggle, checkbox, date, select, choices, radio-group, multi-select, option |
|
|
667
|
-
| Built-in actions | counter, timer, checklist, progress |
|
|
668
|
-
| Content organization | panel, card, grid, tabs, tab, accordion, disclosure, if |
|
|
669
|
-
| Navigation and prose | jump, anchor, text, section |
|
|
670
|
-
| Assessment and reading | quiz, steps, step |
|
|
671
|
-
| Hints | alert, badge, tooltip |
|
|
672
|
-
| Declarations and generated data | external, computed, const, validation, data-table, column |
|
|
673
|
-
| Visualization | table, chart, plot, timeline, diagram, node, edge |
|
|
674
|
-
|
|
675
|
-
49 tag names in total. `option`, `tab`, `disclosure`, `node`, `edge`, `step` and `column` are structural children of parent components. `external`, `computed`, `const` and `validation` are document declarations; they are parsed as tags but are not rendered controls. The leading `<theme>` declaration is metadata and is not counted here. Most articles only need Markdown and two or three input/display components. Plain amounts can be written directly as `{{ total }} USD`; currency formatting and statistic cards are not entry-level requirements.
|
|
676
|
-
|
|
677
|
-
This revision does not accept legacy tags such as form, submit, button, each, list, spinner, stat or value, nor set/reset action attributes or on-* event attributes. The panel reset is a fixed boolean option, not a programmable action.
|
|
678
|
-
|
|
679
|
-
## 13. Diagnostics and acceptance rules
|
|
680
|
-
|
|
681
|
-
Diagnostics include severity, category, a short explanation, source line/column and a fix suggestion. A structurally complete unknown tag region is displayed from escaped original source with a `local.component.unknown` warning; its controls and interpolations are not executed. Normal footnotes produce no unsupported-syntax warning. Other prose and interactions keep working. Component tag structures that cannot be reliably recovered, attribute or expression errors on known components, binding errors and resource budget problems still block compilation. Runtime local computation errors are isolated as described in section 5.
|
|
682
|
-
|
|
683
|
-
| Category | Example | What it should explain |
|
|
684
|
-
| --- | --- | --- |
|
|
685
|
-
| Tag structure | card unclosed, wrong nesting | The required end tag and start position |
|
|
686
|
-
| Unknown tag warning | slidr | Unknown name, spelling suggestion and local source fallback |
|
|
687
|
-
| Invalid syntax | on-click, actions configuration block | Attribute or legacy syntax not in the current mode |
|
|
688
|
-
| Binding | references seats but only seat is declared | The missing parameter and candidate names |
|
|
689
|
-
| Initial value | initial written twice for a same-name parameter | Both conflict positions |
|
|
690
|
-
| Type | using a string as an if condition | Actual type and expected boolean type |
|
|
691
|
-
| Constraint | slider initial value exceeds max | Valid range and current value |
|
|
692
|
-
| Table | numeric column contains "20 USD" | Column name, row number and that a number is required |
|
|
693
|
-
| Diagram | edge points to a nonexistent node | The missing node ID |
|
|
694
|
-
| Declaration | computed inside a container or a duplicate name | Top-level placement, the conflicting name or control |
|
|
695
|
-
| Data table | data-table without a column, or a duplicated key | Required column and unique stable key |
|
|
696
|
-
| Validation | fields names a read-only declaration | Writable public binding names |
|
|
697
|
-
| Math | integral or missing parameter in a plot | The math fragment and supported scope |
|
|
698
|
-
|
|
699
|
-
Implementation acceptance must cover:
|
|
700
|
-
|
|
701
|
-
1. Every regular example compiles according to this specification; the diagnostics example reports the expected errors it lists.
|
|
702
|
-
2. Headings, tables, lists and code inside Markdown containers parse normally; tags and interpolations inside code and comments are inactive.
|
|
703
|
-
3. Components without bind work independently; bindings across components stay in sync, and an explicit initial value is applied only once.
|
|
704
|
-
4. Forward references, conditional hiding, tab switching and panel reset follow the same state rules.
|
|
705
|
-
5. Parameter panels, checklists, local catalog search and timing operations require no scripts, configuration blocks or service calls.
|
|
706
|
-
6. Chart values preserve types, and empty data, error values and zero proportions have explicit displays.
|
|
707
|
-
7. Regular LaTeX fractions, implicit multiplication, functions, parameters and piecewise functions are computable; unsupported structures are diagnosed clearly; discontinuities are not connected incorrectly.
|
|
708
|
-
8. Diagram auto-layout, detail display and bound selection work; missing edge endpoints are errors.
|
|
709
|
-
9. Chinese IME input, keyboard operation, accessible names and 375px narrow screens work.
|
|
710
|
-
10. Document instances are independent, disposal cleans up, and no unintended network actions occur; complex or excessive math input can be halted by the execution budget.
|
|
711
|
-
|
|
712
|
-
These rules cover compiler, runtime and browser acceptance. See the [example index](../../examples/local/README.md) for example mappings and expected observations, and the [language conformance data](../../examples/conformance/README.md) for the machine-readable minimum acceptance set. Actual repository check records stay in the repository and are not part of the package.
|
|
713
|
-
|
|
714
|
-
## 14. Host components (host extension)
|
|
715
|
-
|
|
716
|
-
Host components are not part of the portable author tag set. When the host registers a schema through the `hostComponents` compile option, a document may use that tag in one of three forms: `leaf`, `inline` or `container`. Inline and container tags use a closing tag; their body follows the normal Markdown and ReactiveMD rules, and a container renderer can render its children through `ctx.render()`. Without the schema, the same tag is an unknown component and keeps the inert source fallback.
|
|
717
|
-
|
|
718
|
-
A host schema may declare an optional scalar binding for `string`, `number` or `boolean`. The component then accepts `bind`, `initial` and dynamic `disabled` implicitly and shares the built-in binding families: a `number` binding can pair with `<number>` or `<slider>` when its static `min`, `max` and `step` match. The host renderer receives the current `value`, a validating `setValue`, `disabled`, `resetToken`, resolved `props` and a `report` function. Host schemas remain plain data; the renderer is trusted host code and never enters a worker.
|
|
719
|
-
|
|
720
|
-
`<external>` read-only declarations and dynamic constraint attributes are part of the current revision; host component forms and bindings are governed by the host component protocol, not by the author syntax revision.
|
|
721
|
-
|
|
722
|
-
See [Versions and compatibility](../compatibility/compatibility-en.md) for version mapping and compatibility rules, and [Source revisions and migration](../compatibility/source-versioning-en.md) for the revision directive and migration tools.
|
|
1
|
+
# Reactive MD local interaction syntax specification
|
|
2
|
+
|
|
3
|
+
**English** · [中文](local-interaction-syntax-ch.md)
|
|
4
|
+
|
|
5
|
+
Syntax identifier: `local-draft-3`, 2026-10-31. If this is your first time with the syntax, read the [beginner guide](../guides/local-guide-en.md) first; this document is the complete specification. Hosts select local interaction mode through `compileLocal` and `LocalReactiveDocument`, see [integration notes](../integration/local-integration-en.md). See [Versions and compatibility](../compatibility/compatibility-en.md) for package version relationships, 0.x compatibility rules and migration, and [Source revisions and migration](../compatibility/source-versioning-en.md) for the optional revision directive and `reactive-md migrate`. Complete examples are in the [example index](../../examples/local/README.md).
|
|
6
|
+
|
|
7
|
+
## 1. Positioning and scope
|
|
8
|
+
|
|
9
|
+
Named values, formatting and date functions, cross-field validation, conditional tones, arrays and bounded table-row generation are part of this revision: [5.4 Named values](#54-named-values), [5.5 Formatting, strings and dates](#55-formatting-strings-and-dates), [5.6 Arrays and aggregates](#56-arrays-and-aggregates), [4.4 Cross-field validation](#44-cross-field-validation), [7.2 Conditional tones](#72-conditional-tones) and [9.5 Generated tables](#95-generated-tables).
|
|
10
|
+
|
|
11
|
+
See [Diagnostics and counting rules](diagnostics-counting-en.md) for source positions, text lengths and resource units. String `len()` and text-control length constraints count Unicode code points.
|
|
12
|
+
|
|
13
|
+
Reactive MD is for local interactive documents: authors write Markdown and place input controls; when readers adjust parameters, related text, formulas, charts and diagrams update immediately.
|
|
14
|
+
|
|
15
|
+
The base language requires only two connection rules: `bind` names an input, and `{{ expression }}` reads it elsewhere. Components handle their own selection, expansion, search, sorting, timing and reset.
|
|
16
|
+
|
|
17
|
+
This revision does not include external service calls, form submission, asynchronous resources, named actions, event handlers, programmable collection edits, general loop templates or arbitrary scripts. Legacy `state/data/computed/actions` configuration blocks are not part of this syntax. Expressions can produce string or numeric arrays; checklist and multi-select components produce string arrays. Tables can use prose Markdown or bounded local row generation through `data-table`.
|
|
18
|
+
|
|
19
|
+
By default a document only keeps in-memory state for the current instance. Reopening starts from initial values; persistence is not part of the author syntax. No language version declaration, component import or YAML is required. A document may optionally declare its revision with one `<!-- reactive-md: local-draft-3 -->` line in the prologue, before the theme and body; unversioned documents use the current revision. See [Source revisions and migration](../compatibility/source-versioning-en.md). Hosts should explicitly select draft parsing mode and must not guess by mixing old and new syntax.
|
|
20
|
+
|
|
21
|
+
Documents may select a theme with `<theme name="default">` before the body; omission uses `default`. This is static metadata, not a component. Custom themes must be registered by the host and support both color schemes; see the [theme protocol](theme-protocol-en.md).
|
|
22
|
+
|
|
23
|
+
## 2. Your first document
|
|
24
|
+
|
|
25
|
+
```markdown
|
|
26
|
+
# Cost estimate
|
|
27
|
+
|
|
28
|
+
<panel title="Adjust the plan">
|
|
29
|
+
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
30
|
+
<toggle bind="annual" label="Annual billing">
|
|
31
|
+
</panel>
|
|
32
|
+
|
|
33
|
+
Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Slider declares the number `people` with initial value 2; toggle declares the boolean `annual`, off by default. The panel provides restore-defaults by default, restoring its internal parameters at once.
|
|
37
|
+
|
|
38
|
+
When no cross-component linkage is needed, omit `bind`, for example `<counter label="People" initial="2">`. The component remains interactive; it just has no public variable.
|
|
39
|
+
|
|
40
|
+
## 3. Markdown and tags
|
|
41
|
+
|
|
42
|
+
### 3.1 Document structure
|
|
43
|
+
|
|
44
|
+
Headings, paragraphs, emphasis, links, images, quotes, lists, plain tables, inline code and code fences continue to use Markdown. Component tags may sit in a paragraph or a standalone block, depending on component type. Container contents continue to parse as Markdown; authors do not need to add a `markdown` attribute.
|
|
45
|
+
|
|
46
|
+
Code fences highlight common programming languages plus `latex` / `tex`, `cattca`, `mermaid`, `jinja` / `jinja2`, `dockerfile` / `docker` and `vue`. Vue single-file components highlight templates, JavaScript / TypeScript and CSS / SCSS separately; Cattca highlights Markdown narrative and command blocks. Mermaid fences display highlighted source. Unlabeled code is detected within a bounded set of common languages, with the detected language shown in the toolbar. Blocks without sufficient detection evidence stay plain. Use `text`, `txt`, `plaintext` or `nohighlight` to request plain text explicitly. Unknown languages and blocks longer than 20,000 characters preserve the original text. Highlighting and copying retain source whitespace.
|
|
47
|
+
|
|
48
|
+
Block component start and end tags each occupy a line. Attributes in a start tag may span multiple lines. A `>` inside a tag ends the tag only when it is outside quotes. Indentation is only for readability: container content is dedented by the common indentation and then parsed as Markdown; indentation inside code fences is preserved.
|
|
49
|
+
|
|
50
|
+
The inline components `badge`, `tooltip`, `jump` and `text` can be embedded in sentences. Other components are block components; `option`, `tab`, `disclosure`, `node`, `edge` and `step` are child components restricted to specific parent containers.
|
|
51
|
+
|
|
52
|
+
### 3.2 Two tag shapes
|
|
53
|
+
|
|
54
|
+
| Type | Form | Rules |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| Void component | `<slider bind="a" label="Amplitude">` | No end tag; a trailing `/>` is also accepted |
|
|
57
|
+
| Container with content | `<card title="Notes">` and `</card>` | Must be explicitly closed; nesting is allowed |
|
|
58
|
+
|
|
59
|
+
Void components are fixed to `input`, `textarea`, `number`, `slider`, `range-slider`, `coordinate`, `toggle`, `checkbox`, `date`, `counter`, `timer`, `progress`, `anchor` and `edge`. The declaration tags `external`, `computed`, `const` and `validation`, and the structural `column`, also have no body. Every other component listed in this revision uses paired tags. `textarea` text is set through `initial`, so it is a void component.
|
|
60
|
+
|
|
61
|
+
For example:
|
|
62
|
+
|
|
63
|
+
```markdown
|
|
64
|
+
<card title="Plan notes">
|
|
65
|
+
Price updates with **People**.
|
|
66
|
+
|
|
67
|
+
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
68
|
+
|
|
69
|
+
Total cost: {{ people * 100 }} USD.
|
|
70
|
+
</card>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Tag names and attribute names use lowercase kebab-case; an end tag must match the most recently unclosed container. Automatic closing and correction of mismatched tags are not allowed. Legacy directives such as `:::card` are not interpreted as components.
|
|
74
|
+
|
|
75
|
+
### 3.3 Attributes
|
|
76
|
+
|
|
77
|
+
Regular attribute values are enclosed in single or double quotes; boolean attributes may omit their value. Attribute order has no semantics, and duplicate attributes are errors.
|
|
78
|
+
|
|
79
|
+
| Form | Meaning |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `label="People"` | String |
|
|
82
|
+
| `max="20"` | Parsed as a number according to the component attribute definition |
|
|
83
|
+
| `required` | Boolean true |
|
|
84
|
+
| `required="false"` | Boolean false |
|
|
85
|
+
| `disabled="{{ people >= 20 }}"` | Dynamic boolean |
|
|
86
|
+
| `max="{{ rooms * 4 }}"` | Dynamic number constraint (`number`, `slider`) |
|
|
87
|
+
| `min="{{ departure }}"` | Dynamic date bound (`date`) |
|
|
88
|
+
| `required="{{ business }}"` | Dynamic required (`input`, `textarea`, `date`) |
|
|
89
|
+
| `label="Current people: {{ people }}"` | Text interpolation |
|
|
90
|
+
| `bind="people"` | Static variable name |
|
|
91
|
+
|
|
92
|
+
Omitted boolean attributes use the component default rather than always assuming false; for example `panel.reset` defaults to true.
|
|
93
|
+
|
|
94
|
+
`"`, `'`, `&`, `<` and `>` in attribute values decode to the corresponding characters; backslashes are not used to escape attribute quotes. Dynamic values for numeric and boolean attributes must be one complete interpolation and keep the original type; text attributes may contain multiple interpolations.
|
|
95
|
+
|
|
96
|
+
`bind`, `initial`, `name`, `id`, `value` (option identifier), `to`, `from`, `answer`, `kind`, field mappings and layout enums are static attributes. `min`, `max` and `required` are dynamic on `number`, `slider`, `date`, `input` and `textarea`: use one complete interpolation whose result is a number, a `YYYY-MM-DD` string (or empty string) or a boolean respectively. `step`, length limits, selector options and the range-slider/coordinate bounds remain static. Plot `min/max` may be dynamic to adjust the observed range. The `rows` attribute of `textarea` is a static row count, while `data-table.rows` is a required expression; do not confuse the two.
|
|
97
|
+
|
|
98
|
+
Dynamic constraints are checked when a value is written and when the control is displayed. Writes use the constraints in effect at that moment and still commit atomically. If another parameter narrows a range so that an existing value becomes invalid, the stored value is kept and the field shows the constraint error; it is never clamped, reset or snapped to a nearby legal value. Reducing the field to satisfy the new range, or restoring the dependency, clears the error. Dynamic `required` switching to true while the field is empty shows a hint and does not fill the field. A dynamic bound that cannot be evaluated, a dynamic `min` greater than `max`, or an invalid dynamic date bound rejects the related write and leaves state and revision unchanged. `runtime.validate()` keeps its cross-field meaning; dynamic constraint failures are enforced on writes and displayed on the field. Shared bindings must declare the same static range and step and, when a bound is dynamic, the same expression. `step` and text-length limits remain static.
|
|
99
|
+
|
|
100
|
+
Unknown components, unknown attributes, wrong positions or wrong attribute types all produce source diagnostics. Registered tags are not executed as arbitrary HTML; authors cannot use `script`, `style`, `onclick` or other script entry points.
|
|
101
|
+
|
|
102
|
+
### 3.4 Code, math and escaping
|
|
103
|
+
|
|
104
|
+
Prose such as `Array<T>`, `Map<string, number>`, `x<y` and currency `$5` or `$10` stays text. Complete formulas still use `$...$` or `$$...$$`; an unmatched single dollar sign stays literal.
|
|
105
|
+
|
|
106
|
+
The default path accepts the [P0 HTML subset](html-compatibility-en.md#p0-html-in-the-default-mode): text formatting, headings, containers, disclosures, quotations, code, lists, links and images. It produces controlled nodes and reuses the current theme and renderer. Ordinary single newlines remain Markdown soft breaks. Under the temporary routing policy, enabling author CSS, JavaScript or extended HTML sends the entire source to native HTML and stops Markdown and ReactiveMD interpretation.
|
|
107
|
+
|
|
108
|
+
Reference a footnote with `[^note]` and define it with `[^note]: Note text`. Continuation paragraphs, lists and code blocks use Markdown indentation. Definitions support Markdown and the basic HTML above. Notes appear at the end in first-reference order; repeated references share a number and each has a return link. Identifiers are case-insensitive and the first duplicate definition wins. Undefined references stay literal; unused definitions stay hidden. Controls and interpolations inside notes remain text and create no bindings or executable expressions.
|
|
109
|
+
|
|
110
|
+
Tags, interpolations and formula markers inside inline code and code fences are displayed verbatim. The source revision directive in the prologue is the recognized version comment; other Markdown comments `<!-- ... -->` produce no components or variables.
|
|
111
|
+
|
|
112
|
+
Use `\{{` in prose to display a literal `{{`, and `\<slider>` or inline code to show a tag example. These backslash escapes belong only to the Markdown context and do not apply to LaTeX sources.
|
|
113
|
+
|
|
114
|
+
The parser identifies code, math regions and tag boundaries first, then interprets interpolations; syntax cannot be implemented by string replacement over the whole document. Markdown inside tags, nested containers, multi-line attributes and original line/column positions must be preserved.
|
|
115
|
+
|
|
116
|
+
## 4. Parameters, bindings and initial values
|
|
117
|
+
|
|
118
|
+
### 4.1 Naming and types
|
|
119
|
+
|
|
120
|
+
`bind` uses `[A-Za-z_][A-Za-z0-9_]*` and is case-sensitive. Variable types are determined by the component, not guessed from text content. `x`, `y`, `pi`, `e`, `true`, `false`, `null` and expression built-in function names are reserved.
|
|
121
|
+
|
|
122
|
+
| Component | Public value | Default initial value |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| input, textarea | String | Empty string |
|
|
125
|
+
| date | Date string or empty string | Empty string |
|
|
126
|
+
| number | Number | The valid step value within range closest to 0 |
|
|
127
|
+
| slider | Number | min, with a default range of 0 to 100 |
|
|
128
|
+
| counter | Number | The valid step value within range closest to 0 |
|
|
129
|
+
| toggle, checkbox | Boolean | false |
|
|
130
|
+
| select, choices, radio-group | Option string | value of the first option |
|
|
131
|
+
| multi-select | String array of selected option values | Empty array |
|
|
132
|
+
| range-slider | Two numbers, `start` / `end` slots | start=min; end=the largest valid step not exceeding max |
|
|
133
|
+
| coordinate | Two numbers, `x` / `y` slots | The valid step value on each axis closest to 0 |
|
|
134
|
+
| table, chart with `key` | Stable row key string | Empty string (unselected) |
|
|
135
|
+
| tabs | Page string | value of the first tab |
|
|
136
|
+
| steps | Step string | value of the first step |
|
|
137
|
+
| diagram | Node ID string | id of the first node |
|
|
138
|
+
| checklist | String array of selected item IDs | Determined by the task list check marks |
|
|
139
|
+
| timer | Remaining seconds | duration, default 60 |
|
|
140
|
+
|
|
141
|
+
Scalar components use `initial` to override the default. `range-slider` and `coordinate` use `initial-start`/`initial-end` and `initial-x`/`initial-y` for their slots; `multi-select` accepts a comma-separated `initial` list of static option values. `timer` uses `duration` and `checklist` uses the check marks in its body; neither accepts `initial`. A `table` or `chart` selection accepts `initial` only together with `key`. Dates use real, valid `YYYY-MM-DD`; an empty string means not yet selected.
|
|
142
|
+
|
|
143
|
+
`bind` may be omitted. Unnamed components have independent internal state and do not derive a variable name from the tag. A control's `label` is required and may use dynamic text; it is also the control's accessible name.
|
|
144
|
+
|
|
145
|
+
### 4.2 Same-name controls and declaration order
|
|
146
|
+
|
|
147
|
+
The compiler collects bindings across the whole document before rendering, including bindings in conditional regions. Prose can reference parameters that appear later. Declarations and initial values do not change with condition truth, mount count or scroll position.
|
|
148
|
+
|
|
149
|
+
Number, text or boolean inputs of the same kind may bind the same variable and stay in sync; types must match, and numeric ranges and steps must be identical. When `select/choices/radio-group` share a variable, the value set and order must also be identical. Label text may differ.
|
|
150
|
+
|
|
151
|
+
A variable may have at most one explicit `initial`. Without an explicit initial value, the default of the first control in the source is used, and all associated constraints are validated. Later controls omitting `initial` share the existing initial value. The public state of `timer/checklist/tabs/diagram/multi-select/steps` is owned by exactly one component and does not accept a second same-name owner or writes from other controls. Each numeric slot of `range-slider` and `coordinate` is exclusive too. A `table` and a `chart` may share a selection binding only when their ordered `key` sets are identical.
|
|
152
|
+
|
|
153
|
+
Referencing an undeclared variable is an immediate error and does not silently create an empty value. Component initial values are document initialization data; showing a hidden control again does not initialize it again.
|
|
154
|
+
|
|
155
|
+
### 4.3 Updates, input drafts and reset
|
|
156
|
+
|
|
157
|
+
Valid input commits immediately and updates everything that depends on it. Composition input with a Chinese IME commits when composition ends; intermediate states such as an empty string or a minus sign in a number field remain only as an editing draft. If the value is still invalid on blur, an error is shown while other content keeps reading the last valid value.
|
|
158
|
+
|
|
159
|
+
Numeric constraints use finite numbers, `step > 0`, `min <= max`. Steps are based on min, or on 0 when min is absent, with an implementation-defined floating-point tolerance. An explicit initial outside the range or off the step is an error, not silently corrected. Default initial values are generated from constraints; when two valid values are equidistant from 0, the smaller one is used, and an error occurs when no step value is available.
|
|
160
|
+
|
|
161
|
+
Disabled controls do not accept reader input. A panel reset commits all parameters and component internal state inside it at once, triggers one consistent view update, and clears editing drafts. Displays of shared variables outside the panel change accordingly.
|
|
162
|
+
|
|
163
|
+
When a conditional region is hidden, existing state, tab selection and checklist checks are preserved. Timers in hidden regions pause and stay paused when shown again until the reader starts them. Disposing a document releases timers, subscriptions and component state.
|
|
164
|
+
|
|
165
|
+
### 4.4 Cross-field validation
|
|
166
|
+
|
|
167
|
+
```markdown
|
|
168
|
+
<number bind="people" label="Participants" initial="4" min="1" max="20">
|
|
169
|
+
<number bind="capacity" label="Room capacity" initial="3" min="1" max="20">
|
|
170
|
+
<validation when="{{ people <= capacity }}" message="Choose a room for at least {{ people }} people." fields="people capacity">
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`validation` is a void block component with required `when`, `message` and `fields`. `when` contains one complete boolean expression. `message` is text with optional ordinary interpolations. `fields` lists distinct public writable binding names separated by whitespace; names from multi-slot controls are accepted. A rule can read controls and computed values, including values declared later in the source. Fields identify the controls associated with the rule's hint, and read-only declarations cannot be fields.
|
|
174
|
+
|
|
175
|
+
Constraints report the current consistency of a document, so readers can still edit an inconsistent plan, including one whose initial values fail a cross-field rule. Changing the participant count from four to six can temporarily exceed room capacity; changing the room then clears the hint. Individual control rules such as numeric bounds and invalid calendar dates keep their write-rejection behavior.
|
|
176
|
+
|
|
177
|
+
`runtime.validate()` returns diagnostics for all current failed rules in source order. It reports `local.validation.failed` when `when` is false and `local.validation.expression` when an expression cannot be evaluated; an expression error counts as a failure. One failed rule does not stop independent rules. The result is cached for the current runtime revision and returned as defensive copies. Edits, atomic slot updates and resets refresh calculations and validation together.
|
|
178
|
+
|
|
179
|
+
The renderer displays failed-rule hints and associates them with the corresponding controls or their accessible groups through `aria-describedby` and `aria-invalid`. Hint IDs belong to the mounted document instance, and success removes the error text. Rules in hidden content remain active, as do their bindings; hidden hints do not announce themselves. A document supports at most 100 validation rules, including hidden regions, and diagnostic messages retain the existing 2,000-character bound.
|
|
180
|
+
|
|
181
|
+
`LocalDocument.validations` contains serializable `LocalValidation` metadata. Hosts can call `runtime.validate()` at any time without changing state, and the compiled document remains transferable to a Worker with `structuredClone`.
|
|
182
|
+
|
|
183
|
+
## 5. Text interpolation and expressions
|
|
184
|
+
|
|
185
|
+
```markdown
|
|
186
|
+
People: {{ people }}.
|
|
187
|
+
Total: {{ people * 100 }} USD.
|
|
188
|
+
Billing: {{ annual ? 'annual' : 'monthly' }}.
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Interpolation can appear in paragraphs, headings, emphasis, lists, plain table cells and attributes that allow dynamic values. Strings, finite numbers and booleans display directly; null displays as empty; arrays must first be converted with functions such as `len` and are not implicitly output as JSON. Output is treated as text.
|
|
192
|
+
|
|
193
|
+
### 5.1 Expression set
|
|
194
|
+
|
|
195
|
+
| Category | Supported |
|
|
196
|
+
| --- | --- |
|
|
197
|
+
| Literals | Numbers, single- or double-quoted strings, true, false, null |
|
|
198
|
+
| Parameters | bind names declared in the document |
|
|
199
|
+
| Arithmetic | `+ - * / %`, unary plus/minus, parentheses |
|
|
200
|
+
| Comparison | `== != < <= > >=` |
|
|
201
|
+
| Logic | `!`, `&&`, `\|\|` |
|
|
202
|
+
| Conditional | `condition ? trueValue : falseValue` |
|
|
203
|
+
| Math functions | abs, sqrt, floor, ceil, round, min, max, pow, sin, cos, tan, asin, acos, atan, exp, log |
|
|
204
|
+
| Common functions | len, contains, clamp |
|
|
205
|
+
| Formatting | formatNumber, formatPercent, formatScientific, formatCurrency |
|
|
206
|
+
| Strings | trim, lower, upper, startsWith, endsWith, replace, slice |
|
|
207
|
+
| Dates | dateCompare, dateDiff |
|
|
208
|
+
| Array aggregates | sum, average, minOf, maxOf |
|
|
209
|
+
| Constants | pi, e |
|
|
210
|
+
|
|
211
|
+
Precedence runs from function calls/parentheses, unary operators, multiplication/division/remainder, addition/subtraction, relational comparison, equality comparison, logical AND, logical OR, to conditional expressions; conditional expressions are right-associative and other binary operators are left-associative. Logic and conditional expressions short-circuit.
|
|
212
|
+
|
|
213
|
+
`+` accepts two numbers or two strings. Comparisons do not implicitly convert between strings and numbers; relational comparison accepts only two numbers or two strings; logical operations and if conditions must be booleans. Expression string escapes use `\\`, `\'`, `\"`, `\n`, `\t`.
|
|
214
|
+
|
|
215
|
+
min/max accept one or more numbers; pow takes a base and an exponent; clamp takes a value, lower bound and upper bound. Other math functions take one number, trigonometric functions use radians, and log is the natural logarithm. round rounds half values toward positive infinity. len computes the number of Unicode code points in a string or the length of an array; contains checks a substring or array membership.
|
|
216
|
+
|
|
217
|
+
Multiplication in prose expressions must be written `*`; use `pow` for exponents. LaTeX math regions follow their own mathematical writing rules. Expressions have no assignment, method calls, property access, custom functions or imports, and do not provide legacy runtime contexts such as `event` or `resources`.
|
|
218
|
+
|
|
219
|
+
Pipes in GFM tables must be written `\|`, for example logical OR as `\|\|`. Table parsing handles Markdown pipe escapes first, then sends cell expressions to the evaluator.
|
|
220
|
+
|
|
221
|
+
### 5.2 Calculation errors
|
|
222
|
+
|
|
223
|
+
Division by zero, domain errors, non-finite results and type errors are shown near the corresponding content. When the parameter itself is valid, the user's new input is kept, and other independent content keeps updating; the error result shows "Unable to compute" instead of reusing an old number as a new result.
|
|
224
|
+
|
|
225
|
+
### 5.3 Host-provided external data
|
|
226
|
+
|
|
227
|
+
A document may declare read-only values supplied by the host:
|
|
228
|
+
|
|
229
|
+
```markdown
|
|
230
|
+
<external name="exchangeRate" type="number">
|
|
231
|
+
<external name="inventory" type="number">
|
|
232
|
+
<computed name="priceCny" value="{{ priceUsd * exchangeRate }}">
|
|
233
|
+
|
|
234
|
+
Price: {{ priceCny }} CNY
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`name` follows the same identifier and reserved-name rules as bindings. `type` is one of `string`, `number`, `boolean`, `string-array` or `number-array`. Declarations must be standalone tags at the document top level, cannot repeat a control parameter or another external name, and do not appear in the rendered document or in a state file. Text interpolation, conditions, charts and computations may read them; `setParameter()` cannot write them.
|
|
238
|
+
|
|
239
|
+
The host supplies values through `externalValues` on `LocalReactiveDocument` or `runtime.setExternalValues()`. Values are validated against the declared type and the usual size budgets. When a value is missing, only expressions that read that name fail locally; independent content keeps working, and the dependent content recalculates when the value arrives. A missing value is never converted to `0`, `false` or an empty string. Static export and SSR behave the same way: pass the values into the host integration; an export does not fetch or embed them.
|
|
240
|
+
|
|
241
|
+
Top-level `computed` and `const` declarations provide named read-only values; see [5.4 Named values](#54-named-values). Short calculations can still be written in place; use declarations for intermediate results shared by prose, conditions, formulas and charts.
|
|
242
|
+
|
|
243
|
+
### 5.4 Named values
|
|
244
|
+
|
|
245
|
+
```markdown
|
|
246
|
+
<const name="unitPrice" value="{{ 12.5 }}">
|
|
247
|
+
<computed name="total" value="{{ quantity * unitPrice }}">
|
|
248
|
+
<computed name="invoice" value="{{ formatCurrency(total) }}">
|
|
249
|
+
|
|
250
|
+
<number bind="quantity" label="Quantity" initial="2" min="0" max="100">
|
|
251
|
+
|
|
252
|
+
Invoice: **{{ invoice }}**.
|
|
253
|
+
|
|
254
|
+
<if when="{{ total >= 100 }}">
|
|
255
|
+
Eligible for bulk delivery.
|
|
256
|
+
</if>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`computed` and `const` are invisible, void declarations. Write each on its own line at document top level; `/>` is accepted too. Both require `name` and a complete `value="{{ expression }}"`. Their values use the expression types: number, string, boolean, null, string array or numeric array. The compiler infers the type; there is no type annotation or implicit conversion.
|
|
260
|
+
|
|
261
|
+
Names follow the same identifier and reserved-name rules as `bind`. Controls, multi-slot bindings and declarations share one namespace. A declaration cannot replace another declaration or a control. Declarations inside containers are compile errors. Code fences, inline code and comments remain literal or inert.
|
|
262
|
+
|
|
263
|
+
Declarations are visible throughout the document, including before their source position. A `computed` value may read controls, constants and other computations. A `const` may read other constants and built-in constants such as `pi`; it stays independent of controls and computations. Constants have no editing or reset control.
|
|
264
|
+
|
|
265
|
+
The compiler extracts dependencies from the expression AST, including all conditional branches, and orders declarations by dependency before inferring types. Unknown names, duplicate names, self references and indirect cycles produce source-positioned errors. A cycle in an unused branch is still a compile error. Type checking uses the same operator and function rules as ordinary expressions; runtime domain errors remain possible, for example division by a control that becomes zero. Names declared by top-level `<external>` tags are valid read-only dependencies for `computed` values, text and conditions; a `const` cannot depend on external data, and external names never become writable parameters.
|
|
266
|
+
|
|
267
|
+
Use a named value anywhere an expression is accepted: prose, dynamic attributes, conditions and numeric table cells used by charts. Computable LaTeX formulas read multi-letter numeric names as `\mathrm{total}`, for example `y = \mathrm{total} x`. Formatted strings belong in labels or prose; numeric chart cells and plot parameters need the underlying number.
|
|
268
|
+
|
|
269
|
+
Each runtime owns its calculation cache. Computations are reused within a revision and refreshed after a successful control edit, atomic multi-slot edit or panel reset. Constants are evaluated at compilation and copied into each runtime. Hiding a section keeps its inputs and calculations; reset follows the existing control subtree rules.
|
|
270
|
+
|
|
271
|
+
A failed calculation propagates its expression error when a consumer reads it. The runtime never substitutes zero, null or a previous successful value. Independent consumers continue to work, and a valid input edit lets failed consumers recover. Runtime logical and conditional operators keep their short-circuit behavior, so an unvisited branch does not read its failed value. A constant with an invalid static value is a compile error.
|
|
272
|
+
|
|
273
|
+
`document.bindings` and `document.initialState` describe writable controls. `document.computations` contains serializable declaration metadata, and `document.externals` contains the read-only external declarations. `runtime.snapshot().state` also contains successful named results for the current revision; failed results are absent. Use `runtime.evaluate(name)` to read a result with its error semantics. Declarations cannot be changed through `set` or `setMany`. Returned arrays remain protected from external mutation.
|
|
274
|
+
|
|
275
|
+
Declaration diagnostics use `local.computation.*`: `placement`, `name`, `reserved`, `duplicate`, `value`, `unknown`, `cycle`, `const`, `expression` and `budget`. Expression type errors keep the existing `local.expression.*` codes, and diagnostics include source ranges, lines and columns. The graph uses an iterative dependency order, so long chains do not require recursive evaluation. Existing source, syntax-node, expression and value budgets still apply, and cycle reports are capped by the diagnostic budget.
|
|
276
|
+
|
|
277
|
+
Expression function names are reserved identifiers. A binding or declaration cannot use `sum`, `formatNumber`, `dateDiff` or any other function listed in [5.1](#51-expression-set); the compiler reports the conflict with a reserved-name diagnostic. Rename the name and its references.
|
|
278
|
+
|
|
279
|
+
### 5.5 Formatting, strings and dates
|
|
280
|
+
|
|
281
|
+
All four formatting functions return strings; optional arguments are positional.
|
|
282
|
+
|
|
283
|
+
| Function | Defaults and example |
|
|
284
|
+
| --- | --- |
|
|
285
|
+
| `formatNumber(value, digits, locale, grouping)` | `digits=2`, `locale="en-US"`, `grouping=true`; `formatNumber(1234.5)` gives `"1,234.50"` |
|
|
286
|
+
| `formatPercent(value, digits, locale)` | `digits=0`, `locale="en-US"`; `formatPercent(0.125, 1)` gives `"12.5%"` |
|
|
287
|
+
| `formatScientific(value, digits, locale)` | `digits=2`, `locale="en-US"`; `formatScientific(1234)` gives `"1.23E3"` |
|
|
288
|
+
| `formatCurrency(value, currency, digits, locale)` | `currency="USD"`, `digits=2`, `locale="en-US"`; `formatCurrency(12.5)` gives `"$12.50"` |
|
|
289
|
+
|
|
290
|
+
`digits` is an integer from 0 to 20 and fixes both minimum and maximum fraction digits, including for currencies such as JPY. `grouping` is a boolean. Supported locales are exactly `en-US`, `zh-CN`, `de-DE`, `fr-FR` and `ja-JP`; omission uses `en-US` regardless of the renderer's UI language or device settings, and an unsupported locale is an error. Currency codes are three uppercase ASCII letters accepted by `Intl.NumberFormat`; the check is syntactic and does not consult a registry of circulating currencies.
|
|
291
|
+
|
|
292
|
+
Formatting uses decimal `halfExpand` rounding: ties round away from zero, so `formatNumber(1.005)` gives `"1.01"` and `formatNumber(-1.005)` gives `"-1.01"`. Zero displays without a negative sign. Arithmetic still uses finite JavaScript numbers; `round(x)` keeps its `Math.round` rule, with ties toward positive infinity. Formatting changes presentation, not the source number.
|
|
293
|
+
|
|
294
|
+
A null value formats as an empty string. Other argument types remain strict, and strings are not converted into numbers, so guard optional dates or text explicitly before applying their functions. Locale-specific punctuation, currency symbols and spacing follow the host's `Intl` data; hosts that need byte-identical text across platforms pin their runtime and locale data.
|
|
295
|
+
|
|
296
|
+
| String function | Behavior |
|
|
297
|
+
| --- | --- |
|
|
298
|
+
| `trim(text)` | Remove leading and trailing JavaScript Unicode whitespace |
|
|
299
|
+
| `lower(text)`, `upper(text)` | Default Unicode case conversion, independent of locale |
|
|
300
|
+
| `startsWith(text, search)`, `endsWith(text, search)` | Case-sensitive literal checks; empty search matches |
|
|
301
|
+
| `replace(text, search, replacement)` | Replace every non-overlapping literal match; empty search is an error; replacement text such as `$&` stays literal |
|
|
302
|
+
| `slice(text, start, end)` | Unicode code point indices; end is exclusive and defaults to the length; negative indices count from the end; indices are integers and clamp to bounds |
|
|
303
|
+
|
|
304
|
+
These functions require strings, including when the value is null. No regular expressions or property access are available. Code points are distinct from grapheme clusters: a combined emoji or an accented letter can contain several code points. All results keep the existing string budget of 100,000 UTF-16 code units, and replacement expansion is checked before constructing an oversized result.
|
|
305
|
+
|
|
306
|
+
`dateCompare(a, b)` returns `-1`, `0` or `1`. `dateDiff(a, b, unit)` returns the signed difference **a minus b**; the default unit is `"days"`, and other units are `"hours"`, `"minutes"`, `"seconds"` and `"milliseconds"`.
|
|
307
|
+
|
|
308
|
+
Both arguments must be valid `YYYY-MM-DD` strings in years `0001` through `9999`, matching date controls. The calendar is Gregorian and leap days are validated. Each date means midnight UTC, so device timezone and daylight saving changes do not change the result: `dateDiff("2026-03-09", "2026-03-08", "hours")` is `24`. Timestamps, timezone suffixes and ambiguous regional date strings are rejected.
|
|
309
|
+
|
|
310
|
+
An empty date control contains `""`, which is an absent date rather than epoch zero. Empty or invalid dates produce a domain error, and null produces a type error. Guard optional dates explicitly:
|
|
311
|
+
|
|
312
|
+
```markdown
|
|
313
|
+
<computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
|
|
314
|
+
Days: {{ days == null ? 'Choose both dates' : formatNumber(days, 0) }}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### 5.6 Arrays and aggregates
|
|
318
|
+
|
|
319
|
+
```markdown
|
|
320
|
+
<const name="fixedFees" value="{{ [100, 20, 5] }}">
|
|
321
|
+
<computed name="fees" value="{{ [people * 80, includeKit ? people * 20 : 0] }}">
|
|
322
|
+
|
|
323
|
+
First fee: {{ fees[0] }}. Total: {{ sum(fees) }}.
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Array literals contain only strings or only finite numbers. Expressions inside a literal can read the document's named values. Nested arrays, mixed element types, booleans and null elements are rejected. `[]` is an empty numeric array by default; a direct empty literal in a conditional branch adopts a string-array sibling's kind, so `show ? subjects : []` works for string selections. Checklist and multi-select values remain string arrays. The public type `LocalValue` gains `number[]`, and `LocalValueKind` gains `number-array`; the existing `array` kind continues to mean a string array.
|
|
327
|
+
|
|
328
|
+
Indexing is zero based: `values[0]` reads the first element. The index must be a finite safe integer. An integer outside the collection, including a negative index, returns null; a non-integer index is an error. Indexing a string or a scalar is a type error. Arrays cannot be interpolated as text; use an index, `len`, an aggregate or a data table.
|
|
329
|
+
|
|
330
|
+
`len` counts both kinds of array. `contains` accepts a string member for a string array, a number for a numeric array, and a substring for a string. Every array is bounded by 10,000 elements; array literals also consume the existing expression-length, AST-node and evaluation budgets. The total contents of a string array keep the existing character budget. Returned runtime arrays are copied, and snapshot arrays are frozen.
|
|
331
|
+
|
|
332
|
+
| Function | Result |
|
|
333
|
+
| --- | --- |
|
|
334
|
+
| `sum(values)` | Sum of a numeric array; empty input gives `0` |
|
|
335
|
+
| `average(values)` | Arithmetic mean; empty input gives null |
|
|
336
|
+
| `minOf(values)` | Smallest numeric member; empty input gives null |
|
|
337
|
+
| `maxOf(values)` | Largest numeric member; empty input gives null |
|
|
338
|
+
|
|
339
|
+
Aggregates accept numeric arrays, with no conversion of numeric-looking strings. Results use finite JavaScript numbers; an overflow in the sum or result is an expression error. `average` divides the sum by the count, so an overflowing intermediate sum is also an error. Null from an empty aggregate follows the existing nullable-expression rules, so guard it before numeric operations when needed. Scalar `min`, `max` and `round` keep their existing signatures and behavior.
|
|
340
|
+
|
|
341
|
+
## 6. Inputs and parameter panels
|
|
342
|
+
|
|
343
|
+
All input components support `label`, optional `bind`, optional scalar `initial` and dynamic `disabled`. Additional attributes are listed below; unlisted attributes are not part of this revision.
|
|
344
|
+
|
|
345
|
+
| Component | Additional attributes and defaults |
|
|
346
|
+
| --- | --- |
|
|
347
|
+
| input | type=text/email; placeholder; required=false (dynamic); min-length=0; optional max-length |
|
|
348
|
+
| textarea | placeholder; rows=4; required=false (dynamic); min-length=0; optional max-length |
|
|
349
|
+
| number | optional min/max (dynamic); step=1 |
|
|
350
|
+
| slider | min=0; max=100 (both dynamic); step=1 |
|
|
351
|
+
| range-slider | bind-start/bind-end and initial-start/initial-end; min=0; max=100; step=1; optional color |
|
|
352
|
+
| coordinate | bind-x/bind-y and initial-x/initial-y; x-min/y-min=-5; x-max/y-max=5; step=1; optional color |
|
|
353
|
+
| counter | min=0; optional max; step=1 |
|
|
354
|
+
| toggle, checkbox | Optional color |
|
|
355
|
+
| date | optional min/max dates (dynamic); required=false (dynamic) |
|
|
356
|
+
| select, choices, radio-group, multi-select | Body is one or more options; multi-select adds max-selected and uses a string-array value |
|
|
357
|
+
|
|
358
|
+
`range-slider` and `coordinate` are leaves with required `label`, optional `color` and dynamic `disabled`. Bounds and the positive step are static finite numbers. `range-slider` defaults to 0/100/1, with start=min and end=the largest valid step not exceeding max. Crossing is rejected rather than swapping endpoints. `coordinate` defaults to -5…5 on both axes, step 1, and the nearest legal zero per axis. It supports pointer dragging, keyboard control and numeric alternatives.
|
|
359
|
+
|
|
360
|
+
Each optional `bind-start`/`bind-end` or `bind-x`/`bind-y` names one exclusive numeric slot; an omitted name keeps that slot internal. `x` and `y` remain reserved parameter names. Slots initialize at compile time and reset atomically. Host APIs extend to `runtime.get(node, slot?)`, `runtime.set(node, value, slot?)` and `runtime.setMany(node, values)`. Slots are start/end for ranges and x/y for coordinates. Every write validates canonical registered slots; an invalid batch preserves the entire snapshot and revision, and existing one-value calls remain valid.
|
|
361
|
+
|
|
362
|
+
`multi-select` requires a `label` and one or more option children; `bind` is optional. Its exclusive string-array binding defaults to empty. `initial` is a comma-separated list of static values; values are nonempty, unique and comma-free. `max-selected` is a nonnegative integer, defaulting to the option count. Writes normalize to source order and obey the existing array budgets. Search and Clear are built in, and selected items remain removable at the limit. `disabled` may be dynamic; reset clears local search and restores the initial selection, while hiding preserves them. `multi-select` also accepts an optional `color`.
|
|
363
|
+
|
|
364
|
+
Selector example:
|
|
365
|
+
|
|
366
|
+
```markdown
|
|
367
|
+
<choices bind="plan" label="Usage" initial="personal">
|
|
368
|
+
<option value="personal">Personal</option>
|
|
369
|
+
<option value="team">Team</option>
|
|
370
|
+
</choices>
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
option.value is a non-empty, static, unique string; the body is the option's inline text, may contain emphasis, and must not contain another interactive component. select is a dropdown, choices is option cards, and radio-group is a radio button group; binding rules are the same.
|
|
374
|
+
|
|
375
|
+
`required`, length and email format show hints after the first blur and update with input afterwards. Controls allow an empty initial document value; hints do not produce submissions or network operations. New text with an invalid format remains a draft and does not replace the last valid public value. An empty initial value is public as an empty string until the reader fills it in.
|
|
376
|
+
|
|
377
|
+
`counter` has built-in decrement, increment and restore-initial buttons, and disables the corresponding action at range boundaries. `timer` supports label, optional bind and duration (positive integer seconds, default 60); it has built-in start, pause and reset, stops at zero, updates according to actual elapsed time, and does not accumulate timing error after switching to the background.
|
|
378
|
+
|
|
379
|
+
`panel` is a container supporting an optional title and reset (default true). It lays out vertically by default and provides restore-defaults. `reset="false"` hides the reset action. Nested panels are allowed: an inner reset affects only the inner panel, while an outer reset covers the whole subtree; child controls not yet shown in a condition are also in scope. Panel reset also restores table queries, sorting, paging, tab selection and diagram selection in the subtree.
|
|
380
|
+
|
|
381
|
+
## 7. Layout and content exploration
|
|
382
|
+
|
|
383
|
+
| Container | Attributes | Body and default behavior |
|
|
384
|
+
| --- | --- | --- |
|
|
385
|
+
| card | optional title | Regular Markdown; a content card |
|
|
386
|
+
| grid | columns=2 (integer 1–4, maximum column count) | Direct children are card; fewer columns in narrow containers, including nested grids and embedded documents |
|
|
387
|
+
| tabs | optional label, bind, initial | One or more tab, first selected by default |
|
|
388
|
+
| tab | label required, optional value | Regular Markdown |
|
|
389
|
+
| accordion | optional label | One or more disclosure |
|
|
390
|
+
| disclosure | label required; open=false | Click to expand; multiple entries can be open at once |
|
|
391
|
+
| if | when required, complete boolean interpolation | Shows Markdown and components when true |
|
|
392
|
+
| alert | optional title; tone=info/success/warning/error, default info | Regular Markdown |
|
|
393
|
+
| badge | tone=neutral/success/warning, default neutral | Inline text |
|
|
394
|
+
| tooltip | text required | Focusable inline explanatory text |
|
|
395
|
+
|
|
396
|
+
When tab has no value, `tab-1`, `tab-2` and so on are generated in source order; values in the same group must be unique. Without bind, tabs do not name page state; with bind, the current value is exposed publicly. Switching tabs preserves child content state and pauses hidden timers. The initial `open` state inside accordion is restored on reset.
|
|
397
|
+
|
|
398
|
+
When if's when is false, content is not displayed, but internal parameters are still initialized according to section 4. Unknown variables or type errors in hidden branches are still compile errors.
|
|
399
|
+
|
|
400
|
+
### 7.1 Navigation, color and guided reading
|
|
401
|
+
|
|
402
|
+
| Container or inline tag | Attributes | Body and default behavior |
|
|
403
|
+
| --- | --- | --- |
|
|
404
|
+
| jump | to required; appearance=link/button, default link; optional color | Inline Markdown; scrolls to a heading slug or explicit anchor |
|
|
405
|
+
| anchor | id required and unique | No body; marks an explicit jump target |
|
|
406
|
+
| text | color required | Inline Markdown and interpolation; sets foreground color |
|
|
407
|
+
| section | color required | Block Markdown; sets inherited foreground color without a border or background |
|
|
408
|
+
| quiz | type=choice/number, default choice; label and answer required; optional explanation and tolerance | Choice quizzes contain options; numeric quizzes have an empty body. No public bind |
|
|
409
|
+
| steps | optional label, bind and initial; exclusive string binding | One or more step children; first step selected by default |
|
|
410
|
+
| step | label required; optional value | Markdown body; omitted values become step-1, step-2 and so on |
|
|
411
|
+
|
|
412
|
+
`jump.to` is a static heading slug or explicit anchor ID, written without a leading `#`. Explicit IDs match `[A-Za-z_][A-Za-z0-9_-]*`. Duplicate anchors, heading collisions and missing targets are compile errors. DOM IDs are namespaced per rendered document. Jumps scroll and move focus, and a hidden target shows local feedback. Existing Markdown fragment links also resolve explicit anchors.
|
|
413
|
+
|
|
414
|
+
`text` and `section` require `color`. Other supported components accept an optional `color`: jump, badge, progress, slider, toggle, checkbox, select, choices, radio-group, checklist, multi-select, range-slider and coordinate. Static named colors from the shared table and `#RGB`/`#RRGGBB` are accepted. Expressions, CSS functions, variables and declarations are rejected. Text containers set foreground color, and inner values override inheritance; links and controls keep their own appearance. Other components use color for their accent, selected state or progress fill, while `tone` keeps its semantic meaning. Omitted values use the theme.
|
|
415
|
+
|
|
416
|
+
`quiz` requires `label` and `answer`. `type` defaults to `choice`, with option children and a matching answer. A numeric quiz has an empty body, a finite `answer` and a nonnegative absolute `tolerance` defaulting to 0. `explanation` is optional and supports text interpolation. Check answer, feedback and Try again are built in. Drafts and feedback stay inside the component; this revision has no `quiz` bind. Hiding preserves them and panel reset clears them. Answers are supplied in source for self-study.
|
|
417
|
+
|
|
418
|
+
`steps` accepts one or more `step` children, optional `label` and an exclusive string `bind`. `initial` defaults to the first step. Each `step` requires `label`; omitted values become `step-1`, `step-2` and so on, and values are unique within a group. Previous/Next and position are built in. Only active content is visible; all bindings still initialize, state persists between steps, and hidden timers pause. Reset restores the initial step and its subtree.
|
|
419
|
+
|
|
420
|
+
Base layout uses Markdown; images use ``, links use `[text](../address)`, and horizontal rules use `---`. Images load only after the host explicitly allows them through a URL policy; by default no image requests are made. See [Image and link policy](../integration/local-integration-en.md#image-and-link-policy) for integration. This revision does not provide author tags for row, stack, spacer, icon, image or link-button, and does not expose class/style.
|
|
421
|
+
|
|
422
|
+
### 7.2 Conditional tones
|
|
423
|
+
|
|
424
|
+
```markdown
|
|
425
|
+
<badge tone="{{ total <= budget ? 'success' : 'warning' }}">{{ formatCurrency(total) }}</badge>
|
|
426
|
+
<alert tone="{{ total <= budget ? 'info' : 'warning' }}">Review the estimate before booking.</alert>
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
`badge` accepts dynamic `tone` with `neutral`, `success` and `warning`; `alert` accepts `info`, `success`, `warning` and `error`. Static `tone` values use the same enums. A dynamic expression must have string type, and the renderer checks the returned value against the component's allowed tones. An error or unsupported value uses the default tone and a visible computation hint. CSS classes, author styles and colors remain outside this conditional API.
|
|
430
|
+
|
|
431
|
+
The enum covers info, warning, success and error emphasis while keeping theme colors and contrast under host control. Broader conditional styling is outside the author syntax.
|
|
432
|
+
|
|
433
|
+
## 8. Checklists
|
|
434
|
+
|
|
435
|
+
```markdown
|
|
436
|
+
<checklist bind="done" label="Try it out">
|
|
437
|
+
- [x] Read the source document
|
|
438
|
+
- [ ] Adjust parameters and observe the result
|
|
439
|
+
- [ ] Try it at phone width
|
|
440
|
+
</checklist>
|
|
441
|
+
|
|
442
|
+
Completed {{ len(done) }} / 3 items.
|
|
443
|
+
<progress label="Completion" value="{{ len(done) / 3 * 100 }}">
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
The checklist body is a non-empty, single-level Markdown task list, checked by the reader by default. Plain Markdown task lists remain static content. Items may contain inline Markdown but must not contain nested task lists or interactive components.
|
|
447
|
+
|
|
448
|
+
Fixed entries generate internal IDs `item-1`, `item-2` and so on in order; the public value is an array of checked IDs in source order, and `[]` when nothing is selected. Entries are not added, removed or reordered during a document instance; they are regenerated after editing the source and creating a new instance. Reset restores the initial state specified by `[x]` / `[ ]`. Supports label, optional bind and dynamic disabled. Checked item text is struck through and muted, including initial `[x]` items; unchecking restores it, and only the checked item changes.
|
|
449
|
+
|
|
450
|
+
progress is a void component; label/value are required, max defaults to 100, and value may be dynamic; max must be a positive finite number, value must be between 0 and max, and out-of-range values show a diagnostic instead of being silently clamped.
|
|
451
|
+
|
|
452
|
+
## 9. Tables and statistical charts
|
|
453
|
+
|
|
454
|
+
### 9.1 Shared data rules
|
|
455
|
+
|
|
456
|
+
The ReactiveMD table, chart and timeline components each contain one Markdown table. Headers are non-empty and unique, and every row has the same number of columns; cells may contain interpolation. The first column is usually a label, and other columns read types according to the component.
|
|
457
|
+
|
|
458
|
+
`<table>` also accepts a native HTML table body. Body structure selects the syntax; both share the rendering styles. HTML tables support merged cells and add no table interactions by default. See [HTML table compatibility](html-compatibility-en.md#two-table-syntaxes).
|
|
459
|
+
|
|
460
|
+
Plain text cells display Markdown; plain decimal or scientific-notation text cells can be read as numbers, and a single complete interpolation keeps its result type. Mixed text such as `{{ price }} USD` is a display string and cannot be used as a numeric chart column. Legend labels take the plain text of headers.
|
|
461
|
+
|
|
462
|
+
There is no need to declare a YAML array first, and remote URLs, data attributes or API return values are not accepted. Errors such as empty rows, non-numeric values or missing columns are located at the corresponding cell.
|
|
463
|
+
|
|
464
|
+
### 9.2 Enhanced tables
|
|
465
|
+
|
|
466
|
+
```markdown
|
|
467
|
+
<table label="Component catalog" page-size="3">
|
|
468
|
+
| Name | Category | Price |
|
|
469
|
+
| --- | --- | ---: |
|
|
470
|
+
| Document | Basic | 20 |
|
|
471
|
+
| Form | Input | 45 |
|
|
472
|
+
| Chart | Visual | 80 |
|
|
473
|
+
</table>
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
table supports optional label, searchable=true, sortable=true and page-size=10 (positive integer). It provides a search box, sortable headers and paging by default; paging controls are hidden when there is only one page.
|
|
477
|
+
|
|
478
|
+
`key` names a column of static, nonempty, unique text identifiers. Selection is enabled only when `key` is present, so `bind` and `initial` require it. The bound value is an empty string when no row is selected by default, and an explicit `initial` must match a row. Mouse or keyboard selection writes row identity. A table and a chart may share a selection binding only with identical ordered keys and at most one explicit initial. Sorting, searching, pagination and hidden chart legends preserve the selection; table filters still affect only that table, and components without `key` gain no implicit binding. Reset restores the initial selection along with the rest of the subtree.
|
|
479
|
+
|
|
480
|
+
Search is a case-insensitive substring match over the displayed text of all columns, trimming whitespace from the query; sorting uses the full column type, numerically for numeric columns and by Unicode code point order for text otherwise, preserving the original order of equal rows. Clicking a header cycles ascending, descending and source order. Search or sort changes return to the first page, and reactive data changes clamp the current page to the valid range. No matches shows "No matching results". These interactions affect only the table.
|
|
481
|
+
|
|
482
|
+
### 9.3 Charts
|
|
483
|
+
|
|
484
|
+
```markdown
|
|
485
|
+
<chart kind="bar" title="Cost and budget">
|
|
486
|
+
| Item | Actual | Budget |
|
|
487
|
+
| --- | ---: | ---: |
|
|
488
|
+
| Content | 120 | 150 |
|
|
489
|
+
| Visual | 230 | 200 |
|
|
490
|
+
</chart>
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
chart.kind defaults to bar and supports bar, line, area, scatter, donut and pie. Supports optional title, x, y, x-label and y-label. x/y are static header names; y may be a comma-separated list of column names, so column names cannot contain commas.
|
|
494
|
+
|
|
495
|
+
| Type | Default column rules |
|
|
496
|
+
| --- | --- |
|
|
497
|
+
| bar, line, area | First column is the horizontal axis; other columns are numeric series |
|
|
498
|
+
| scatter | First column is the numeric horizontal axis and the rest are numeric vertical axes; x/y may also specify them |
|
|
499
|
+
| donut | First column is the label and second is the value; with more than two columns, y must specify the single numeric column |
|
|
500
|
+
| pie | Uses the same table rules as donut, with solid slices to show shares |
|
|
501
|
+
|
|
502
|
+
line/area determine the horizontal axis as numeric or categorical from the full column type and connect in source order. donut/pie values must be non-negative, and a zero total shows "No share to display". Series names become legends automatically; pointer and keyboard readouts are provided by default without event logic.
|
|
503
|
+
|
|
504
|
+
Interactive default-theme charts provide themed tooltips, legend highlighting and 200ms data transitions. Line and area charts read visible series in the same row; bars read one hovered bar; scatter charts find the nearest point; pie and donut charts show values and shares of the visible total. Static mode keeps the data graphics and removes hover interaction and animation.
|
|
505
|
+
|
|
506
|
+
Numeric columns update with parameters. Calculation errors display in the corresponding chart and are not replaced with 0. With `key`, a chart exposes selection through `bind` under the same row-key rules as `table`.
|
|
507
|
+
|
|
508
|
+
### 9.4 Timelines
|
|
509
|
+
|
|
510
|
+
timeline supports optional title and unit (display text, default "minutes"), and its body is a table with either `Task`, `Start` and `Duration` columns or `事项`, `开始` and `时长` columns, plus optional `Notes` or `说明`. These column names are fixed headers; start and duration are non-negative numbers. Sorting is stable by start time, overlapping intervals are allowed, and notes are viewed with a pointer or keyboard. Table content may use interpolation.
|
|
511
|
+
|
|
512
|
+
### 9.5 Generated tables
|
|
513
|
+
|
|
514
|
+
```markdown
|
|
515
|
+
<const name="subjects" value="{{ ['mathematics', 'physics', 'chemistry'] }}">
|
|
516
|
+
|
|
517
|
+
<data-table label="Subject preparation" rows="{{ subjects }}" key="{{ item }}" max-rows="3">
|
|
518
|
+
<column label="Subject" value="{{ item }}">
|
|
519
|
+
<column label="Position" value="{{ index + 1 }}">
|
|
520
|
+
<column label="Preparation" value="{{ item == 'chemistry' ? 'Prepare materials' : 'Prepare examples' }}">
|
|
521
|
+
</data-table>
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
`data-table` is a paired block component. It requires an accessible `label`, a complete array expression in `rows`, and a complete string or number expression in `key`. Its only children are 1 to 20 void `column` declarations. A column requires a static `label` and a complete scalar `value` expression. Cells output plain text; null gives an empty cell.
|
|
525
|
+
|
|
526
|
+
Each row has two local names: `item` is the current string or number, and `index` is its current zero-based position. These names shadow same-named document values inside column expressions. Other references use the normal document environment. The source `rows` expression uses ordinary document scope.
|
|
527
|
+
|
|
528
|
+
Keys depend only on `item`, including at least one reference to it. They cannot depend on `index` or other document values. The table checks that every evaluated key is a nonempty string or finite number and is unique. Numeric and string keys have distinct identities; signed numeric zeros have the same identity. React rows retain their identities when their items reorder. For records with repeated display values, use a collection of distinct local IDs as `rows` and derive the display cells from those IDs. Duplicate or invalid keys produce a whole-table error.
|
|
529
|
+
|
|
530
|
+
`max-rows` is a static integer from 1 to 1,000, defaulting to 100. Across the document, declared row budgets may total at most 2,000 and row budgets multiplied by their column counts may total at most 10,000 cells. Hidden tables count too. Each generated table also has a budget of 100,000 UTF-16 code units for header text, cell text, error and empty placeholders, and encoded row keys. The renderer checks budgets before exposing rows; exceeding them reports an error without truncating the data.
|
|
531
|
+
|
|
532
|
+
An empty array displays the headers and an empty-state message. Failure of the row source or a key clears the table's rows and displays an error. A cell-expression failure is shown in that cell while independent cells remain readable. The component creates native table rows, not arbitrary repeated document sections or controls. Markdown tables and their existing chart inputs keep their original behavior.
|
|
533
|
+
|
|
534
|
+
## 10. LaTeX math and function plots
|
|
535
|
+
|
|
536
|
+
### 10.1 Display and plotting
|
|
537
|
+
|
|
538
|
+
KaTeX typesets formulas with bundled math fonts, producing visual HTML and MathML for assistive technology. Fonts are inlined in the standard stylesheet so previews, printing and exported single-file HTML work offline. Hosts using `reactive-md/react/unstyled` must load `reactive-md/styles.css` or supply KaTeX styles and fonts. Formula display and plot evaluation are handled separately.
|
|
539
|
+
|
|
540
|
+
Prose accepts `$...$` or `\(...\)` for inline math, and `$$...$$` or `\[...\]` for display formulas. Dollar-delimited inline math pairs on the same line and permits leading or trailing whitespace, as in `$ x $`, `$x $` and `$ x$`. Its content must include a non-whitespace character. Currency text such as `$5 and $10` stays literal; use `\$` for an explicit literal dollar sign. Backslash-delimited formulas may contain whitespace and span lines. For example, write `\(\frac{a}{b}\)` in a sentence or `\[x^2 + 1\]` as a display formula. Unclosed math delimiters are errors; an unmatched single dollar sign stays literal. Code, comments and Markdown destinations keep these delimiters literal; escape the opening backslash or use code to show an example in prose.
|
|
541
|
+
|
|
542
|
+
Standalone formulas are for layout and create no state or functions. Each `$$...$$` block inside a plot container defines one curve; the math content keeps normal LaTeX syntax and does not need `{{ }}`. Plot accepts only `$$...$$`, not `\(...\)` or `\[...\]`.
|
|
543
|
+
|
|
544
|
+
Display supports KaTeX math commands and environments, including `cases`, `aligned`, `align`, `align*`, `matrix`, `pmatrix`, `bmatrix` and `vmatrix`. Use `&` for columns and `\\` for rows. Alignment environments alternate right and left column alignment; matrices center their cells and show the corresponding delimiters. Both `align` and `aligned` belong inside math delimiters. Add explicit equation labels to display formulas with `\tag{1}`, or `\tag*{A}` to omit parentheses. Use `\displaystyle`, `\textstyle`, `\limits` and `\nolimits` to control style and limit placement.
|
|
545
|
+
|
|
546
|
+
| Display content | Example commands |
|
|
547
|
+
| --- | --- |
|
|
548
|
+
| Alphabets and text | `\mathbb{R}`, `\mathcal{F}`, `\mathscr{L}`, `\mathfrak{g}`, `\textbf{bold text}` |
|
|
549
|
+
| Binomials, annotations and boxes | `\binom{n}{k}`, `\underbrace{a+b}_{n}`, `\overrightarrow{AB}`, `\underline{x}`, `\boxed{x}` |
|
|
550
|
+
| Above/below labels and labeled arrows | `\stackrel{!}{=}`, `\underset{x}{\lim}`, `\xrightarrow[below]{above}`, `\xrightleftharpoons[k_2]{k_1}` |
|
|
551
|
+
| Logic, relations and symbols | `\implies`, `\iff`, `\not\in`, `\cong`, `\mapsto`, `\mid`, `\ll`, `\oplus`, `\varnothing`, `\therefore`, `\because`, `\triangle`, `\circ`, `\dagger`, `\vdots`, `\ddots` |
|
|
552
|
+
| Arrows, delimiters and sizes | `\rightleftharpoons`, `\longrightarrow`, `\Longleftrightarrow`, `\downarrow`, `\lfloor`, `\rfloor`, `\lceil`, `\rceil`, `\bigl(`, `\bigr)`, `\Bigg(` |
|
|
553
|
+
| Functions and congruences | `\sec`, `\csc`, `\cot`, `\sinh`, `\cosh`, `\lg`, `\pmod{n}` |
|
|
554
|
+
|
|
555
|
+
`align` numbers its rows automatically; use `align*` or `aligned` to omit automatic numbering. Numbering counters are scoped to each document.
|
|
556
|
+
|
|
557
|
+
Use mhchem notation for chemistry: `$\ce{H2O}$`, `$\ce{SO4^2-}$`, `$\ce{^{14}_{6}C}$`, `$$\ce{2 H2 + O2 -> 2 H2O}$$` or `$$\ce{A <=>[forward][reverse] B}$$`. KaTeX's mhchem extension typesets molecular subscripts, ionic charges, isotopes, coefficients, physical states, bonds and reaction arrows. Invalid or unsupported formulas produce a `local.math.display` warning and fall back to bounded source text for the whole formula. Input and conversion have resource budgets; author-defined macros, HTML, file and network entry points are disabled. These forms are available for formula display; plotting computation supports the syntax listed below.
|
|
558
|
+
|
|
559
|
+
```markdown
|
|
560
|
+
<slider bind="a" label="Amplitude" initial="1" min="0" max="5">
|
|
561
|
+
|
|
562
|
+
<plot min="-10" max="10">
|
|
563
|
+
$$ y = a \sin x + \frac{x^2}{10} $$
|
|
564
|
+
</plot>
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
The plot body may contain only whitespace and one or more display formula blocks. Each block defines one curve in one of four forms:
|
|
568
|
+
|
|
569
|
+
```markdown
|
|
570
|
+
<plot min="-10" max="10">
|
|
571
|
+
$$ y = a \sin x + \frac{x^2}{10} $$
|
|
572
|
+
$$ \begin{cases} x = t - \sin t \\ y = 1 - \cos t \end{cases} $$
|
|
573
|
+
$$ r = a(1 + \cos\theta) $$
|
|
574
|
+
$$ (x^2 + y^2)^2 = 2a^2(x^2 - y^2) $$
|
|
575
|
+
</plot>
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
The first block is explicit `y = f(x)`. The second is parametric: `x` and `y` are written as functions of `t`, and `t` runs from `min` to `max`; both axes fit the sampled points. Any other equation in `x` and `y` is implicit and is traced as a contour over `min` to `max` on both axes; the axes then fit the traced curve. Use multiple formula blocks for multiple curves; do not use plain line breaks as separators.
|
|
579
|
+
|
|
580
|
+
The third block is polar, `r = f(\theta)`: `min` and `max` set the angle interval in radians. Directly typed `θ` and `\theta` are equivalent and may be mixed. Both spellings are local to the curve, while other numeric parameters can read document bindings. Samples are projected to `x = r cos(θ)`, `y = r sin(θ)`, and both axes fit the result. Negative radii preserve direction; undefined radii form breaks. This example samples 1000 evenly spaced points over one full turn:
|
|
581
|
+
|
|
582
|
+
```markdown
|
|
583
|
+
<plot min="0" max="{{ 2 * pi }}" points="1000">
|
|
584
|
+
$$ r = 1 + \cos\theta $$
|
|
585
|
+
</plot>
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
plot supports min=-10, max=10 (dynamic allowed, requiring min < max), points=200 (static integer 2–2000), optional label, x-label="x" and y-label="y". Quote attribute values, as in `points="1000"`. The existing `samples` attribute remains supported; `points` takes precedence when both are supplied, and the default is 200 when both are omitted. Each plot has at most 16 curves. An explicit, parametric or polar curve requests the specified number of sample points, including both endpoints. An implicit curve uses the specified number of grid points per axis, capped at 100 and raised to at least 32, and requests the corresponding grid area. The whole document may request at most 20,000 points across all curves, including hidden regions. Curves share a computation budget, and exceeding it stops computation and reports an error. The vertical axis is determined automatically from finite sample values in the current range; if there are no valid values, an empty state is shown. Constant curves should add visible vertical-axis headroom.
|
|
589
|
+
|
|
590
|
+
### 10.2 Computable LaTeX
|
|
591
|
+
|
|
592
|
+
This revision requires plotting computation to support the following math forms. Formula layout and computation capability are validated separately; being able to lay out a formula does not mean it can be evaluated.
|
|
593
|
+
|
|
594
|
+
| Math content | Syntax |
|
|
595
|
+
| --- | --- |
|
|
596
|
+
| Numbers, four operations | `2`, `0.5`, `+`, `-`, `/`, `\cdot`, `\times` |
|
|
597
|
+
| Implicit multiplication | `2x`, `ax`, `a\sin x`, `(x+1)(x-1)` |
|
|
598
|
+
| Exponents | `x^2`, `x^{a+1}`, `e^x` |
|
|
599
|
+
| Fractions | `\frac{a}{b}`, `\dfrac{a}{b}`, `\tfrac{a}{b}` |
|
|
600
|
+
| Roots | `\sqrt{x}`, `\sqrt[3]{x}` |
|
|
601
|
+
| Grouping | `(...)`, `{...}`, `\left(...\right)` |
|
|
602
|
+
| Trigonometric functions | `\sin`, `\cos`, `\tan`, `\arcsin`, `\arccos`, `\arctan` |
|
|
603
|
+
| Exponential and logarithm | `\exp(x)`, `\ln x`, `\log x`, `\log_{2}x` |
|
|
604
|
+
| Absolute value | `\lvert x\rvert`, `\left\lvert x\right\rvert` |
|
|
605
|
+
| Other functions | `\min(a,b)`, `\max(a,b)` |
|
|
606
|
+
| Constants | `\pi`, `e` |
|
|
607
|
+
| Piecewise functions | `\begin{cases} ... \end{cases}` |
|
|
608
|
+
| Piecewise conditions | `=`, `\ne`/`\neq`, `<`, `>`, `\le`/`\leq`, `\ge`/`\geq` |
|
|
609
|
+
|
|
610
|
+
Trigonometric functions use radians; ln is the natural logarithm, log without a base is base 10 by convention, and with a subscript it uses the written base. Roots compute real numbers; odd integer roots allow negative numbers, while negative inputs to even roots are invalid samples. Absolute value accepts both paired vertical bars and `\left|...\right|`; bars must be paired, and missing boundaries are not guessed.
|
|
611
|
+
|
|
612
|
+
Multiplication must use `*` in expression contexts and may be omitted in LaTeX. LaTeX multiplication and division (including implicit multiplication) share precedence and associate left to right; exponents bind before unary minus, so `-x^2` is `-(x^2)`. `1/2x` is interpreted as `(1/2)x`; use fractions to make the denominator explicit.
|
|
613
|
+
|
|
614
|
+
A function without parentheses reads the product of the following term and ends at addition/subtraction, comparison, comma or the next function command; for example `\sin 2x` is sin(2x), `\sin x + a` is sin(x)+a, and `\sin x\cos x` is sin(x)cos(x). Use parentheses for complex arguments. `\sin^2 x` is supported and means `(sin x)^2`; inverse trigonometric functions use explicit names such as arcsin, and `\sin^{-1}` is not guessed to mean the inverse function.
|
|
615
|
+
|
|
616
|
+
`\left`, `\right`, the math spacing commands `\,`, `\;`, `\!`, `\quad` and `%` comments to end of line do not change computation. In piecewise functions, `&` separates values from conditions and `\\` separates branches; the first branch whose condition is true is used. `\text{otherwise}` may serve as the final default branch; if no branch matches, the point is undefined. Conditions support only a single comparison; express complex piecewise behavior with multiple branches.
|
|
617
|
+
|
|
618
|
+
Matrices, sums, integrals, derivatives and custom macros are not in the computable set. When these structures are encountered, keep displaying the formula and point out the command or structure that cannot be computed; do not guess a plot from another formula. Within a parametric `cases` block, `t` is the parameter and the branches may not read `x`. The math renderer must disable file, network, HTML and macro execution entry points.
|
|
619
|
+
|
|
620
|
+
### 10.3 Parameter name mapping
|
|
621
|
+
|
|
622
|
+
A single Latin letter maps to a same-name bind, for example `a` maps to `bind="a"`. Adjacent plain letters mean multiplication: `abx` is a×b×x.
|
|
623
|
+
|
|
624
|
+
Multi-letter names are written as `\mathrm{amplitude}` and read as `bind="amplitude"` as a whole. This is a Reactive MD naming convention; the command must contain a complete valid bind name, with no spaces or interpolation.
|
|
625
|
+
|
|
626
|
+
`\alpha`, `\beta`, `\gamma`, `\theta`, `\omega`, `\lambda`, `\mu` and `\sigma` map to same-name English binds. Other Greek parameters use `\mathrm{name}` for explicit references in the first version; `\pi` is fixed as the circle constant.
|
|
627
|
+
|
|
628
|
+
`x` is the plot variable and `y` is the output marker; neither can be bound to a control. Parameters must be numbers; undeclared parameters and wrong types are diagnosed before plotting.
|
|
629
|
+
|
|
630
|
+
### 10.4 Breaks, readouts and updates
|
|
631
|
+
|
|
632
|
+
Curves are recomputed when parameters change. Division by zero, non-real results and overflow points form breaks, and the two sides of a break are not connected directly. The plotting implementation must also subdivide suspected discontinuous intervals to avoid incorrect connections when asymptotes cross finite sample points.
|
|
633
|
+
|
|
634
|
+
A legend and pointer/keyboard readouts are provided by default. The curve legend uses the respective math formulas; move the pointer to the end of a curve to read that point's value.
|
|
635
|
+
|
|
636
|
+
## 11. Interactive diagrams
|
|
637
|
+
|
|
638
|
+
```markdown
|
|
639
|
+
<diagram bind="selected" initial="input" label="Reactive state flow" direction="right">
|
|
640
|
+
<node id="input" label="Input">
|
|
641
|
+
The reader changes parameters through controls.
|
|
642
|
+
</node>
|
|
643
|
+
<node id="compute" label="Compute">
|
|
644
|
+
Recompute formulas and results.
|
|
645
|
+
</node>
|
|
646
|
+
<node id="view" label="Display">
|
|
647
|
+
Update prose and charts.
|
|
648
|
+
</node>
|
|
649
|
+
<edge from="input" to="compute" label="State change">
|
|
650
|
+
<edge from="compute" to="view" label="Update result">
|
|
651
|
+
</diagram>
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
diagram supports optional label, bind and initial, with direction=right/down (default right). The body contains only node, edge and whitespace. At least one node is required; node requires id and label, and its body is static Markdown notes that may contain text interpolation but not interactive controls.
|
|
655
|
+
|
|
656
|
+
node.id is a `[A-Za-z_][A-Za-z0-9_-]*` unique within the current diagram. edge requires from/to and supports an optional label; both ends must exist. Fully duplicate from/to/label combinations are errors, while parallel edges with different labels are allowed. Cycles and self-loops are allowed.
|
|
657
|
+
|
|
658
|
+
Nodes are laid out automatically from relationships, with source order determining order within a layer; cycles are grouped as a whole before layout. The first version requires no coordinates and provides no author coordinate overrides.
|
|
659
|
+
|
|
660
|
+
Nodes are clickable and keyboard-selectable by default, and the selected notes appear in the diagram's detail area. With bind, the selected node id is public; without bind, selection stays inside the component. initial must point to an existing node and defaults to the first. The labels of diagram and edge, as well as node.label, support text interpolation. node also supports dynamic tone=neutral/success/warning, default neutral.
|
|
661
|
+
|
|
662
|
+
## 12. Component reference and syntax scope
|
|
663
|
+
|
|
664
|
+
| Purpose | Components |
|
|
665
|
+
| --- | --- |
|
|
666
|
+
| Parameter input | input, textarea, number, slider, range-slider, coordinate, toggle, checkbox, date, select, choices, radio-group, multi-select, option |
|
|
667
|
+
| Built-in actions | counter, timer, checklist, progress |
|
|
668
|
+
| Content organization | panel, card, grid, tabs, tab, accordion, disclosure, if |
|
|
669
|
+
| Navigation and prose | jump, anchor, text, section |
|
|
670
|
+
| Assessment and reading | quiz, steps, step |
|
|
671
|
+
| Hints | alert, badge, tooltip |
|
|
672
|
+
| Declarations and generated data | external, computed, const, validation, data-table, column |
|
|
673
|
+
| Visualization | table, chart, plot, timeline, diagram, node, edge |
|
|
674
|
+
|
|
675
|
+
49 tag names in total. `option`, `tab`, `disclosure`, `node`, `edge`, `step` and `column` are structural children of parent components. `external`, `computed`, `const` and `validation` are document declarations; they are parsed as tags but are not rendered controls. The leading `<theme>` declaration is metadata and is not counted here. Most articles only need Markdown and two or three input/display components. Plain amounts can be written directly as `{{ total }} USD`; currency formatting and statistic cards are not entry-level requirements.
|
|
676
|
+
|
|
677
|
+
This revision does not accept legacy tags such as form, submit, button, each, list, spinner, stat or value, nor set/reset action attributes or on-* event attributes. The panel reset is a fixed boolean option, not a programmable action.
|
|
678
|
+
|
|
679
|
+
## 13. Diagnostics and acceptance rules
|
|
680
|
+
|
|
681
|
+
Diagnostics include severity, category, a short explanation, source line/column and a fix suggestion. A structurally complete unknown tag region is displayed from escaped original source with a `local.component.unknown` warning; its controls and interpolations are not executed. Normal footnotes produce no unsupported-syntax warning. Other prose and interactions keep working. Component tag structures that cannot be reliably recovered, attribute or expression errors on known components, binding errors and resource budget problems still block compilation. Runtime local computation errors are isolated as described in section 5.
|
|
682
|
+
|
|
683
|
+
| Category | Example | What it should explain |
|
|
684
|
+
| --- | --- | --- |
|
|
685
|
+
| Tag structure | card unclosed, wrong nesting | The required end tag and start position |
|
|
686
|
+
| Unknown tag warning | slidr | Unknown name, spelling suggestion and local source fallback |
|
|
687
|
+
| Invalid syntax | on-click, actions configuration block | Attribute or legacy syntax not in the current mode |
|
|
688
|
+
| Binding | references seats but only seat is declared | The missing parameter and candidate names |
|
|
689
|
+
| Initial value | initial written twice for a same-name parameter | Both conflict positions |
|
|
690
|
+
| Type | using a string as an if condition | Actual type and expected boolean type |
|
|
691
|
+
| Constraint | slider initial value exceeds max | Valid range and current value |
|
|
692
|
+
| Table | numeric column contains "20 USD" | Column name, row number and that a number is required |
|
|
693
|
+
| Diagram | edge points to a nonexistent node | The missing node ID |
|
|
694
|
+
| Declaration | computed inside a container or a duplicate name | Top-level placement, the conflicting name or control |
|
|
695
|
+
| Data table | data-table without a column, or a duplicated key | Required column and unique stable key |
|
|
696
|
+
| Validation | fields names a read-only declaration | Writable public binding names |
|
|
697
|
+
| Math | integral or missing parameter in a plot | The math fragment and supported scope |
|
|
698
|
+
|
|
699
|
+
Implementation acceptance must cover:
|
|
700
|
+
|
|
701
|
+
1. Every regular example compiles according to this specification; the diagnostics example reports the expected errors it lists.
|
|
702
|
+
2. Headings, tables, lists and code inside Markdown containers parse normally; tags and interpolations inside code and comments are inactive.
|
|
703
|
+
3. Components without bind work independently; bindings across components stay in sync, and an explicit initial value is applied only once.
|
|
704
|
+
4. Forward references, conditional hiding, tab switching and panel reset follow the same state rules.
|
|
705
|
+
5. Parameter panels, checklists, local catalog search and timing operations require no scripts, configuration blocks or service calls.
|
|
706
|
+
6. Chart values preserve types, and empty data, error values and zero proportions have explicit displays.
|
|
707
|
+
7. Regular LaTeX fractions, implicit multiplication, functions, parameters and piecewise functions are computable; unsupported structures are diagnosed clearly; discontinuities are not connected incorrectly.
|
|
708
|
+
8. Diagram auto-layout, detail display and bound selection work; missing edge endpoints are errors.
|
|
709
|
+
9. Chinese IME input, keyboard operation, accessible names and 375px narrow screens work.
|
|
710
|
+
10. Document instances are independent, disposal cleans up, and no unintended network actions occur; complex or excessive math input can be halted by the execution budget.
|
|
711
|
+
|
|
712
|
+
These rules cover compiler, runtime and browser acceptance. See the [example index](../../examples/local/README.md) for example mappings and expected observations, and the [language conformance data](../../examples/conformance/README.md) for the machine-readable minimum acceptance set. Actual repository check records stay in the repository and are not part of the package.
|
|
713
|
+
|
|
714
|
+
## 14. Host components (host extension)
|
|
715
|
+
|
|
716
|
+
Host components are not part of the portable author tag set. When the host registers a schema through the `hostComponents` compile option, a document may use that tag in one of three forms: `leaf`, `inline` or `container`. Inline and container tags use a closing tag; their body follows the normal Markdown and ReactiveMD rules, and a container renderer can render its children through `ctx.render()`. Without the schema, the same tag is an unknown component and keeps the inert source fallback.
|
|
717
|
+
|
|
718
|
+
A host schema may declare an optional scalar binding for `string`, `number` or `boolean`. The component then accepts `bind`, `initial` and dynamic `disabled` implicitly and shares the built-in binding families: a `number` binding can pair with `<number>` or `<slider>` when its static `min`, `max` and `step` match. The host renderer receives the current `value`, a validating `setValue`, `disabled`, `resetToken`, resolved `props` and a `report` function. Host schemas remain plain data; the renderer is trusted host code and never enters a worker.
|
|
719
|
+
|
|
720
|
+
`<external>` read-only declarations and dynamic constraint attributes are part of the current revision; host component forms and bindings are governed by the host component protocol, not by the author syntax revision.
|
|
721
|
+
|
|
722
|
+
See [Versions and compatibility](../compatibility/compatibility-en.md) for version mapping and compatibility rules, and [Source revisions and migration](../compatibility/source-versioning-en.md) for the revision directive and migration tools.
|