figdown 0.1.8 → 0.3.0
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/.claude-plugin/plugin.json +1 -1
- package/dist/figdown.js +971 -169
- package/dist/figdown.mjs +971 -169
- package/examples/evpn-fabric.svg +3 -4
- package/examples/showcase/arp-resolution.svg +1 -1
- package/examples/showcase/ethernet-frame.svg +1 -1
- package/examples/showcase/l2-forwarding-logic.svg +9 -9
- package/examples/showcase/tcp-handshake.svg +1 -1
- package/examples/showcase/tcp-header.svg +1 -1
- package/examples/showcase/tcp-state-machine.svg +77 -55
- package/guide/expressing.md +30 -18
- package/guide/layout.md +19 -19
- package/guide/showcase.md +62 -56
- package/package.json +2 -2
- package/skill/figdown/SKILL.md +30 -4
- package/skill/figdown/figdown.html +1030 -194
- package/skill/figdown/reference/experimental/block.md +60 -0
- package/skill/figdown/reference/experimental/chart.md +32 -0
- package/skill/figdown/reference/experimental/flowchart.md +148 -20
- package/skill/figdown/reference/experimental/statechart.md +138 -0
- package/skill/figdown/reference/experimental/timing.md +1 -1
- package/skill/figdown/reference/experimental/topology.md +148 -22
- package/skill/figdown/reference/reading.md +25 -1
- package/skill/figdown/reference/scene.md +78 -10
- package/skill/figdown/reference/experimental/constructs.md +0 -90
package/dist/figdown.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// figdown.mjs — FigDown embeddable library (0.
|
|
1
|
+
// figdown.mjs — FigDown embeddable library (0.3.0)
|
|
2
2
|
// GENERATED FILE, DO NOT EDIT. Built from editor/figdown.html.
|
|
3
3
|
// Regenerate with: node tools/make-lib.js
|
|
4
4
|
'use strict';
|
|
5
|
-
var VERSION = "0.
|
|
5
|
+
var VERSION = "0.3.0";
|
|
6
6
|
|
|
7
7
|
// ---- engine (extracted verbatim from editor/figdown.html) ----
|
|
8
8
|
var __engine = (function () {
|
|
@@ -16,13 +16,56 @@ const SHAPES = ['box','rounded','circle','ellipse','diamond','cylinder'];
|
|
|
16
16
|
// input to that promise, and under core §13 a 0.x renderer may differ from
|
|
17
17
|
// the next — which makes the recorded version the only thing that can
|
|
18
18
|
// explain a diff between two renderings of one source.
|
|
19
|
-
const FIGDOWN_VERSION = '0.
|
|
19
|
+
const FIGDOWN_VERSION = '0.3.0';
|
|
20
|
+
// `STATECHART-GENRE-SCOPE`: the language number moved for the first time. The dev
|
|
21
|
+
// counter does NOT reset (core §13.0.4 — `N` counts source states of the
|
|
22
|
+
// engine and only ever increases), so 0.1 is followed by
|
|
23
|
+
// 0.2, not by 0.2.
|
|
24
|
+
//
|
|
25
|
+
// LANGUAGE VERSIONS THIS ENGINE ACCEPTS (core §13.7 second bullet: an engine
|
|
26
|
+
// MUST state this, and stating the release version alone does not satisfy
|
|
27
|
+
// it). Declared here, in ONE place, so the header check and the documented
|
|
28
|
+
// interface cannot drift:
|
|
29
|
+
// `DRAWN-ANNOTATION-FORM`: `figdown 0.3` joins the set. `note=` is a NEW OPTION KEY,
|
|
30
|
+
// and core §13.0 makes a new key a `Y` change and not a `Z` one — "`Z`: Bug
|
|
31
|
+
// fixes only. No new features. The language does not move." Shipping `note=`
|
|
32
|
+
// under `v0.2.z` would make `figdown 0.2` name two different languages: the one
|
|
33
|
+
// `v0.2.0` published and the one with `note=`. So the language number moves.
|
|
34
|
+
const LANG_VERSIONS = ['0.1', '0.2', '0.3'];
|
|
35
|
+
// Genres per declared language version. `Y` never removes (core §13.0), so
|
|
36
|
+
// each row is a superset of the one above it, and `figdown 0.1 <anything>`
|
|
37
|
+
// resolves against exactly the list it resolved against before `STATECHART-GENRE-SCOPE`.
|
|
38
|
+
const GENRES_BY_VERSION = {
|
|
39
|
+
'0.1': ['block','topology','flowchart','bitfield','table','timing'],
|
|
40
|
+
'0.2': ['block','topology','flowchart','bitfield','table','timing','statechart'],
|
|
41
|
+
'0.3': ['block','topology','flowchart','bitfield','table','timing','statechart']
|
|
42
|
+
};
|
|
43
|
+
// The version an OPTION KEY first becomes legal in — the `CONNECTOR_MIN_VERSION`
|
|
44
|
+
// device, applied to the option namespace. `DRAWN-ANNOTATION-FORM`: `note=` is gated on the
|
|
45
|
+
// declared version, and the gate's reason is specific to THIS key rather than
|
|
46
|
+
// generic to new keys. `note=` has a PRIOR MEANING on the record: it was the
|
|
47
|
+
// retired spelling of `description=` (`DESCRIPTION-KEY-SPELLING`) and its retirement
|
|
48
|
+
// diagnostic actively told authors to write `description=` for a tooltip.
|
|
49
|
+
// Accepting it silently under a `figdown 0.2` header would repaint a document
|
|
50
|
+
// whose author meant a never-drawn tooltip as one that puts ink on the page —
|
|
51
|
+
// core §13.0.1's named hazard, "a figure that looks right and means something
|
|
52
|
+
// else". A key that had never been spelled before would carry no such risk.
|
|
53
|
+
const OPT_MIN_VERSION={note:'0.3'};
|
|
54
|
+
// True when the document's declared version is older than the key's own.
|
|
55
|
+
// A document with no parsable header has already been diagnosed on line 1, so
|
|
56
|
+
// an absent version never gates a second time.
|
|
57
|
+
const belowOptVersion=(key,ver)=>{
|
|
58
|
+
const need=OPT_MIN_VERSION[key];
|
|
59
|
+
if(!need||!ver) return false;
|
|
60
|
+
const i=LANG_VERSIONS.indexOf(ver), j=LANG_VERSIONS.indexOf(need);
|
|
61
|
+
return i>=0 && j>=0 && i<j;
|
|
62
|
+
};
|
|
20
63
|
// Retired shape VALUES keep a named diagnostic (PROCESS §5(d)), the same way
|
|
21
64
|
// retired option keys do: `cloud` was the one value that named a domain
|
|
22
65
|
// (the internet cloud) in an enum the language keeps purely geometric
|
|
23
66
|
// (`SHAPE-ENUM-VOCABULARY`/`EXTERNAL-EDGE-ENDPOINTS`), so it was removed rather than demoted.
|
|
24
67
|
const RETIRED_SHAPES = {
|
|
25
|
-
cloud: 'shape=cloud has been retired: use shape=ellipse and put the meaning in the label or a class= (shapes are pure geometry, `SHAPE-ENUM-VOCABULARY`) (MIGRATIONS)'
|
|
68
|
+
cloud: 'shape=cloud has been retired: use shape=ellipse and put the meaning in the label or a class= (shapes are pure geometry, `SHAPE-ENUM-VOCABULARY`) (MIGRATIONS 0.1)'
|
|
26
69
|
};
|
|
27
70
|
// Colors are CSS hex (#rgb / #rrggbb) or CSS named colors (spec §1) — the
|
|
28
71
|
// 147 CSS/SVG color keywords (lowercase) plus `transparent`. Anything else
|
|
@@ -200,7 +243,7 @@ function splitList(t,off){
|
|
|
200
243
|
// - a key=value token with an unregistered key is an "unknown option"
|
|
201
244
|
// line error (`UNKNOWN-OPTION-DEGRADATION`) — except inside timing `signal` lanes, where bare
|
|
202
245
|
// tokens may contain '=' and stay positional (laneMode).
|
|
203
|
-
// `fill` was registered here until
|
|
246
|
+
// `fill` was registered here until 0.1 solely to power a retired
|
|
204
247
|
// migration diagnostic on the old `line` directive; it left the registry with
|
|
205
248
|
// the `fill` → `band` KEYWORD rename, and 0.1 gave the word back to the
|
|
206
249
|
// option-key namespace as the primary presentation key (`color=` → `fill=`).
|
|
@@ -215,11 +258,11 @@ function splitList(t,off){
|
|
|
215
258
|
// time the language gains no replacement — v0.1 has no author-facing label
|
|
216
259
|
// colour at all (the default is derived, `LABEL-COLOUR-SOURCE`; the owner-level key that could
|
|
217
260
|
// be added today is the wrong shape, core §9 `ANNOTATION-LOCATOR-SPLIT`). It stays registered so
|
|
218
|
-
// the message can name BOTH eras: a `color=` written
|
|
219
|
-
// the FILL, one written meant the LABEL, and only a human
|
|
261
|
+
// the message can name BOTH eras: a `color=` written in one era meant
|
|
262
|
+
// the FILL, one written in another meant the LABEL, and only a human
|
|
220
263
|
// knows which document this is. `text` and `z` stay registered
|
|
221
264
|
// as RETIRED keys so each rename gets a named diagnostic. `offset` replaces
|
|
222
|
-
// `threshold at=` (the directive was spelled `guide` until
|
|
265
|
+
// `threshold at=` (the directive was spelled `guide` until 0.1);
|
|
223
266
|
// `at` stays live on `pin`.
|
|
224
267
|
// 0.1: `level` stays registered as a RETIRED key — the construct was
|
|
225
268
|
// DELETED (`CHART-LEVEL-KEY`), and a registered-but-retired key is the only way the
|
|
@@ -250,7 +293,7 @@ const OPT_KEYS=new Set(['kind','type','shape','fill','color','stroke','text','in
|
|
|
250
293
|
// - `external` is NEVER drawn (`EXTERNAL-EDGE-ENDPOINTS`) — no fill, no border, no dash; only its
|
|
251
294
|
// label exists, so it takes `text=` (plus `plane=`, organizational exactly
|
|
252
295
|
// as on a node);
|
|
253
|
-
// - `band` carried NO label channel at all until
|
|
296
|
+
// - `band` carried NO label channel at all until 0.1 (`BAND-LABEL-STATUS`); it now
|
|
254
297
|
// takes a mandatory quoted label, so `color=` applies to it like any
|
|
255
298
|
// other labelled element;
|
|
256
299
|
// - typed blocks (`bitfield`/`table`/`timing`) stack in document order OUTSIDE
|
|
@@ -269,21 +312,48 @@ const OPT_KEYS=new Set(['kind','type','shape','fill','color','stroke','text','in
|
|
|
269
312
|
// the key existed only because there was no label to colour.
|
|
270
313
|
const DIRECTIVE_OPTS={
|
|
271
314
|
figdown:[],
|
|
272
|
-
|
|
315
|
+
// `DRAWN-ANNOTATION-FORM`: `title` gains its FIRST option key. It took one
|
|
316
|
+
// positional string and nothing else until now, and the key
|
|
317
|
+
// it gains carries the figure-level annotation — 14% of the measured demand,
|
|
318
|
+
// 10 instances that name no single element ("Total: 2 blocks × 8 ways × 1k
|
|
319
|
+
// sets = 16,384 entries", a four-signal legend, a TODO about the figure).
|
|
320
|
+
// The figure HAS a declaration line, so attachment-by-position reaches it and
|
|
321
|
+
// no standalone keyword is needed. `UNIVERSAL-CORE-KEYWORDS` fixes what `title` MEANS across genres;
|
|
322
|
+
// it is not a bar on the directive taking options, so the key exists in every
|
|
323
|
+
// genre at once, which is correct — every genre has figures.
|
|
324
|
+
title:['note'],
|
|
325
|
+
node:['shape','fill','stroke','style','class','in','width','height','note'],
|
|
273
326
|
// `FLOWCHART-ROLE-KEYWORDS`: the three flowchart role keywords take EXACTLY the
|
|
274
327
|
// option keys `node` takes — they ARE nodes, with a role recorded. Listing
|
|
275
328
|
// `width`/`height` mirrors `node` so the same "use a pin line" diagnostic
|
|
276
329
|
// fires rather than a bare `unknown option`.
|
|
277
|
-
process:['shape','fill','stroke','style','class','in','
|
|
278
|
-
decision:['shape','fill','stroke','style','class','in','
|
|
279
|
-
terminator:['shape','fill','stroke','style','class','in','
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
330
|
+
process:['shape','fill','stroke','style','class','in','width','height','note'],
|
|
331
|
+
decision:['shape','fill','stroke','style','class','in','width','height','note'],
|
|
332
|
+
terminator:['shape','fill','stroke','style','class','in','width','height','note'],
|
|
333
|
+
// `GENRE-NODE-SPELLING`: `state` IS `node` under `statechart` — a rename, not a
|
|
334
|
+
// new directive, so it takes `node`'s keys exactly and nothing more.
|
|
335
|
+
state:['shape','fill','stroke','style','class','in','width','height','note'],
|
|
336
|
+
group:['fill','stroke','style','gap','class','note'],
|
|
337
|
+
// `PAINT-ORDER-CONSTRUCT`: `external` now takes NO option key at all. `plane=`
|
|
338
|
+
// was its only one — it is never drawn (`EXTERNAL-EDGE-ENDPOINTS`), so it has no fill, no border
|
|
339
|
+
// and no dash to set — and the withdrawal of `plane=` empties the row. An
|
|
340
|
+
// empty array is the declaration: every key falls through to the generic
|
|
341
|
+
// `external does not take <k>=`.
|
|
342
|
+
external:[],
|
|
343
|
+
edge:['style','class','fill','stroke','label','taillabel','headlabel','note'],
|
|
344
|
+
// `GENRE-CONNECTOR-SPELLING`/`GENRE-NODE-SPELLING`: same rename argument — the connector's option set is one set
|
|
345
|
+
// under three spellings, listed three times only because the tables are
|
|
346
|
+
// keyed by the surface word an author actually wrote.
|
|
347
|
+
flowline:['style','class','fill','stroke','label','taillabel','headlabel','note'],
|
|
348
|
+
transition:['style','class','fill','stroke','label','taillabel','headlabel','note'],
|
|
349
|
+
// `PAINT-ORDER-CONSTRUCT`: the `plane` row is GONE, not emptied — the keyword is
|
|
350
|
+
// withdrawn from the language, so it has no acceptor row at all, the shape
|
|
351
|
+
// `path`/`routing` left behind. `z-index=` goes with it: it
|
|
352
|
+
// was legal on `plane` and on nothing else.
|
|
353
|
+
flow:[], rank:[],
|
|
354
|
+
bundle:['fill','stroke','style'],
|
|
355
|
+
threshold:['in','at','offset','fill','stroke','style'],
|
|
356
|
+
band:['in','extend','fill','stroke','style','from','to'],
|
|
287
357
|
// `ELEMENT-GEOMETRY-DIRECTIVE`: `size` merged into `pin`. ONE directive carries an
|
|
288
358
|
// element's whole DECLARED geometry — `at=` places it, `width=`/`height=`
|
|
289
359
|
// extend it — and one model object records it. All three keys are optional
|
|
@@ -294,7 +364,7 @@ const DIRECTIVE_OPTS={
|
|
|
294
364
|
// derives its geometry from its content).
|
|
295
365
|
pin:['at','width','height'],
|
|
296
366
|
layout:[],
|
|
297
|
-
'class':['fill','stroke','style'
|
|
367
|
+
'class':['fill','stroke','style'],
|
|
298
368
|
// 0.1: `class=` is NOT accepted on the typed-block OPENERS. The
|
|
299
369
|
// normative registry (core §10) lists its acceptors as node/group/edge/
|
|
300
370
|
// field/cell — the block openers were an engine-only extra with 0 uses in
|
|
@@ -318,7 +388,7 @@ const DIRECTIVE_OPTS={
|
|
|
318
388
|
// the field is ONE ELEMENT of a repeated run and gives the run's index
|
|
319
389
|
// range; the engine derives the elision row and the index labels from it,
|
|
320
390
|
// exactly as it derives the dash and the caption from `present=`.
|
|
321
|
-
field:['fill','stroke','class','description','present','index'], 'break':[],
|
|
391
|
+
field:['fill','stroke','class','description','present','index','note'], 'break':[],
|
|
322
392
|
cell:['fill','stroke','class'], width:[],
|
|
323
393
|
signal:['data','fill','stroke'], gap:[]
|
|
324
394
|
};
|
|
@@ -362,14 +432,14 @@ const ENUM_OPT_KEYS=['shape','style','numbering','extend','type'];
|
|
|
362
432
|
// `color=` sets the TEXT — and once `color=` is live again the engine can no
|
|
363
433
|
// longer diagnose a pre-0.1 document at all.
|
|
364
434
|
const RETIRED_OPT_KEYS={
|
|
365
|
-
w:'w= has been renamed: use width= (SVG, CSS, DOT, mxGraph and D2 all spell it in full — no standard abbreviates it) (MIGRATIONS)',
|
|
366
|
-
h:'h= has been renamed: use height= (SVG, CSS, DOT, mxGraph and D2 all spell it in full — no standard abbreviates it) (MIGRATIONS)',
|
|
367
|
-
dir:'dir= has been renamed: use extend= (HTML\'s dir= is text writing direction; this one says which way the band extends from its anchor) (MIGRATIONS)',
|
|
368
|
-
text:'text= has been retired: v0.1 has NO label-colour key — the label colour is DERIVED from the fill it sits on (core §5), and the owner-level key that could replace it would colour an edge\'s [tail]/[mid]/[head] labels identically, which is the wrong shape (core §9 `ANNOTATION-LOCATOR-SPLIT`). Delete the key; if the distinction was knowledge, write it in the label or a class= meaning (§5, `PRESENTATION-AS-MEANING-CARRIER`) (MIGRATIONS)',
|
|
435
|
+
w:'w= has been renamed: use width= (SVG, CSS, DOT, mxGraph and D2 all spell it in full — no standard abbreviates it) (MIGRATIONS 0.1)',
|
|
436
|
+
h:'h= has been renamed: use height= (SVG, CSS, DOT, mxGraph and D2 all spell it in full — no standard abbreviates it) (MIGRATIONS 0.1)',
|
|
437
|
+
dir:'dir= has been renamed: use extend= (HTML\'s dir= is text writing direction; this one says which way the band extends from its anchor) (MIGRATIONS 0.1)',
|
|
438
|
+
text:'text= has been retired: v0.1 has NO label-colour key — the label colour is DERIVED from the fill it sits on (core §5), and the owner-level key that could replace it would colour an edge\'s [tail]/[mid]/[head] labels identically, which is the wrong shape (core §9 `ANNOTATION-LOCATOR-SPLIT`). Delete the key; if the distinction was knowledge, write it in the label or a class= meaning (§5, `PRESENTATION-AS-MEANING-CARRIER`) (MIGRATIONS 0.1)',
|
|
369
439
|
// `COLOUR-KEY-STATUS`. This is the ONLY key in the language whose diagnostic
|
|
370
440
|
// must name two eras and refuse to choose between them: the same six
|
|
371
|
-
// characters meant the FILL
|
|
372
|
-
//
|
|
441
|
+
// characters meant the FILL in one era and the LABEL
|
|
442
|
+
// in another, and no engine can tell the two source files apart. Retiring
|
|
373
443
|
// the key is what makes the difference DIAGNOSABLE at all — while it was
|
|
374
444
|
// live, a pre-0.1 document parsed and drew a legal, wrong figure in
|
|
375
445
|
// silence.
|
|
@@ -384,10 +454,19 @@ const RETIRED_OPT_KEYS={
|
|
|
384
454
|
// those observables, says plainly when a file has neither, and cites the
|
|
385
455
|
// release only as a MIGRATIONS lookup. Same rule as the migration tool's
|
|
386
456
|
// `color=` family, which reads the same evidence to decide its refusals.
|
|
387
|
-
color:'color= has been retired: the same six characters set the box FILL in one era of this language and the LABEL colour in another, and this line does not say which — which is why the key is gone rather than renamed. READ IT OFF THE REST OF THE DOCUMENT. A file that also writes fill= cannot be from the FILL era (the two keys never coexisted), so its color= was a LABEL colour: delete it and let the derived default apply (core §5). A file still writing the spellings that were retired before the LABEL era (w= h= unit= via= dir= kind= layer= boundary wrap optional) cannot be from that era, so its color= was a FILL: write fill= instead. A file with NEITHER carries no evidence at all, and the two readings then differ only in what was DRAWN — as a FILL the value painted the box interior, as a LABEL colour it painted only the text. If the colour carried meaning, put that meaning in the label or a class= (§5, `PRESENTATION-AS-MEANING-CARRIER`). tools/migrate-figdown.js reads this evidence for you and REFUSES the wrong --color-means=fill|text (MIGRATIONS)',
|
|
457
|
+
color:'color= has been retired: the same six characters set the box FILL in one era of this language and the LABEL colour in another, and this line does not say which — which is why the key is gone rather than renamed. READ IT OFF THE REST OF THE DOCUMENT. A file that also writes fill= cannot be from the FILL era (the two keys never coexisted), so its color= was a LABEL colour: delete it and let the derived default apply (core §5). A file still writing the spellings that were retired before the LABEL era (w= h= unit= via= dir= kind= layer= boundary wrap optional) cannot be from that era, so its color= was a FILL: write fill= instead. A file with NEITHER carries no evidence at all, and the two readings then differ only in what was DRAWN — as a FILL the value painted the box interior, as a LABEL colour it painted only the text. If the colour carried meaning, put that meaning in the label or a class= (§5, `PRESENTATION-AS-MEANING-CARRIER`). tools/migrate-figdown.js reads this evidence for you and REFUSES the wrong --color-means=fill|text (MIGRATIONS 0.1)',
|
|
388
458
|
kind:'kind= has been renamed: on a node use shape= (geometric; the label text carries the device semantics — MIGRATIONS 0.1), on a chart use type= (Vega, Chart.js and ECharts all spell the chart-type key "type" — MIGRATIONS 0.1). One spelling was retired on node and live on plot at the same time, inside one namespace; 0.1 closed that.',
|
|
389
|
-
layer
|
|
390
|
-
|
|
459
|
+
// `PAINT-ORDER-CONSTRUCT`: `layer=` was renamed `plane=`, and
|
|
460
|
+
// `plane=` has since been WITHDRAWN, so this message can no longer end at
|
|
461
|
+
// the rename — the `route`→`path` precedent, where a message
|
|
462
|
+
// pointing at a spelling that no longer exists had to state the whole chain.
|
|
463
|
+
layer:'layer= has been WITHDRAWN: it was renamed plane=, and plane= was withdrawn with the `plane` keyword (`PAINT-ORDER-CONSTRUCT`). There is no replacement spelling. Delete the key: everything paints in one plane, in document order. If the element is on a distinct logical layer of the SUBJECT — an overlay, a control plane — say so with a class= whose label states it, which is where that meaning belongs (core §5, `PRESENTATION-AS-MEANING-CARRIER`) (MIGRATIONS 0.3)',
|
|
464
|
+
labels:'labels= has been renamed: use data= (WaveDrom\'s own key for exactly this is `data`, "an array of signal labels" — one per value cell of the lane) (MIGRATIONS 0.1)',
|
|
465
|
+
// `PAINT-ORDER-CONSTRUCT`. `plane=` referenced a declared `plane`; with the
|
|
466
|
+
// keyword withdrawn from every genre the key would keep exactly ONE legal
|
|
467
|
+
// value — the implicit `base` — so it is withdrawn with it rather than left
|
|
468
|
+
// as a key that can only ever restate the default.
|
|
469
|
+
plane:'plane= has been WITHDRAWN with the `plane` keyword (`PAINT-ORDER-CONSTRUCT`): the construct is removed from the language, not renamed, so there is no spelling to migrate to. `plane=` named a declared plane, and with no way to declare one the key had a single legal value — `base`, the implicit plane every element is already on. Delete the key. What it did was PAINT ORDER, and paint order is document order: a later line paints on top. The measurement: stripping `plane` and `plane=` from examples/evpn-fabric.fd left the drawn SVG byte-identical but for one `data-edge` index, because the overlay meaning was carried by `class=overlay` throughout — which is where a logical layer of the SUBJECT belongs (core §5, `PRESENTATION-AS-MEANING-CARRIER`) (MIGRATIONS 0.3)',
|
|
391
470
|
// 0.1 (`EDGE-GEOMETRY-CONSTRUCTS`). These six keys end in a WITHDRAWAL, not a rename, so
|
|
392
471
|
// their messages have a shape no earlier retirement in this table has: they
|
|
393
472
|
// name no replacement spelling, because there is none. `via=`/`src=`/`dst=`
|
|
@@ -401,28 +480,94 @@ const RETIRED_OPT_KEYS={
|
|
|
401
480
|
tailport:'tailport= has been WITHDRAWN with the `path` directive (`EDGE-GEOMETRY-CONSTRUCTS`): the construct is removed from the language, not renamed, so there is no spelling to migrate to. Attachment to a named site addressed by semantic role IS inside the stable prior-art intersection; FigDown\'s realisation was not (a fraction on the EDGE is mxGraph-only, and written-order attachment has zero prior art in any surveyed system). Restoring it needs an edge-identity construct first. Delete the line; the edge draws under auto layout. The decision and its evidence: MIGRATIONS 0.1, core §9 `EDGE-IDENTITY-AND-GEOMETRY`, decisions/registry.md',
|
|
402
481
|
headport:'headport= has been WITHDRAWN with the `path` directive (`EDGE-GEOMETRY-CONSTRUCTS`): the construct is removed from the language, not renamed, so there is no spelling to migrate to. Attachment to a named site addressed by semantic role IS inside the stable prior-art intersection; FigDown\'s realisation was not (a fraction on the EDGE is mxGraph-only, and written-order attachment has zero prior art in any surveyed system). Restoring it needs an edge-identity construct first. Delete the line; the edge draws under auto layout. The decision and its evidence: MIGRATIONS 0.1, core §9 `EDGE-IDENTITY-AND-GEOMETRY`, decisions/registry.md',
|
|
403
482
|
routing:'routing= has been WITHDRAWN with the `path` directive (`EDGE-GEOMETRY-CONSTRUCTS`): the construct is removed from the language, not renamed, so there is no spelling to migrate to. The per-edge routing SCOPE was inside the stable prior-art intersection and is deliberately lost with its host line — an override needs an edge to address, and FigDown has no edge-identity construct. Delete the line. The decision and its evidence: MIGRATIONS 0.1, core §9 `EDGE-IDENTITY-AND-GEOMETRY`, decisions/registry.md',
|
|
404
|
-
unit:'unit= has been renamed: use word= (RFC 2360 §3.1: "a sequence of long words in network byte order, with each word horizontal on the page"; RFC 791 §3.1 measures the header in "32 bit words". Mermaid names the identical setting bitsPerRow — semantically right, camelCase barred. `unit=32` also inverts count-vs-unit, reading as "the unit is 32", and C\'s "unit" is the addressable storage unit, not the row width) (MIGRATIONS)',
|
|
405
|
-
|
|
406
|
-
//
|
|
407
|
-
//
|
|
408
|
-
|
|
409
|
-
|
|
483
|
+
unit:'unit= has been renamed: use word= (RFC 2360 §3.1: "a sequence of long words in network byte order, with each word horizontal on the page"; RFC 791 §3.1 measures the header in "32 bit words". Mermaid names the identical setting bitsPerRow — semantically right, camelCase barred. `unit=32` also inverts count-vs-unit, reading as "the unit is 32", and C\'s "unit" is the addressable storage unit, not the row width) (MIGRATIONS 0.1)',
|
|
484
|
+
// `PAINT-ORDER-CONSTRUCT`: `z-index=` itself. Its ONLY acceptor was `plane`, so
|
|
485
|
+
// with the keyword withdrawn the key has no directive left to sit on. Left
|
|
486
|
+
// in OPT_KEYS with no acceptor row it would have produced `<directive> does
|
|
487
|
+
// not take z-index=` — true, but it tells an author holding a 0.2 document
|
|
488
|
+
// that they picked the wrong host, when in fact there is no host. RULE 6.2
|
|
489
|
+
// placement: the spelling left the LANGUAGE, so it is reported wherever it
|
|
490
|
+
// appears.
|
|
491
|
+
'z-index':'z-index= has been WITHDRAWN with the `plane` keyword (`PAINT-ORDER-CONSTRUCT`): it was legal on `plane` and on nothing else, so it left with its only acceptor. There is no replacement spelling and no other directive to move it to. Delete the key: paint order is document order, and a later line paints on top (MIGRATIONS 0.3)',
|
|
492
|
+
z:'z= has been WITHDRAWN: it was renamed z-index=, and z-index= was withdrawn with the `plane` keyword (`PAINT-ORDER-CONSTRUCT`) — it was legal on `plane` and on nothing else. There is no replacement spelling. Delete the key: paint order is document order, a later line paints on top (MIGRATIONS 0.3)',
|
|
493
|
+
// `note` was HERE (`DESCRIPTION-KEY-SPELLING`) until this release (`DRAWN-ANNOTATION-FORM`), and its
|
|
494
|
+
// row is gone because the key is LIVE again — SYNTAX-STYLE RULE 4.9
|
|
495
|
+
// obligation 3 forbids leaving the retirement message standing past the
|
|
496
|
+
// revival, on the ground that a message telling an author to write
|
|
497
|
+
// `description=` where `note=` is now the correct key is worse than no
|
|
498
|
+
// message: it is the language actively misinforming its user. What replaces
|
|
499
|
+
// it is not silence but two NARROWER messages — NOTE_VERSION for a document
|
|
500
|
+
// that declares a language version older than the key, and NOTE_ON_FIELD for
|
|
501
|
+
// the one directive that keeps refusing it. See OPT_MIN_VERSION above.
|
|
502
|
+
level:'level= has been DELETED, not renamed: it drew a reference plane through a 3-D bar chart, has zero uses in either downstream corpus and zero 3-D bar charts to draw it on, was the only construct whose caption the ENGINE wrote rather than the author, and its parseFloat grammar uniquely accepted 1e3 where every other number in the language is \\d+(\\.\\d+)? — delete the key (MIGRATIONS 0.1)'
|
|
410
503
|
};
|
|
504
|
+
// `DRAWN-ANNOTATION-FORM`. The two messages that REPLACE the `note=` retirement
|
|
505
|
+
// diagnostic. SYNTAX-STYLE RULE 4.9 obligation 3 requires the retirement
|
|
506
|
+
// message to be reversed in the same release that revives the spelling, and
|
|
507
|
+
// "reversed" does not mean "deleted": each of the two situations the old
|
|
508
|
+
// message used to cover keeps a named diagnostic of its own.
|
|
509
|
+
//
|
|
510
|
+
// (a) The document declares a language version older than the key. The gate is
|
|
511
|
+
// `KEYWORD-RENAME-SCOPE`'s device — name the version, offer the one-step fix — and its
|
|
512
|
+
// reason is stated in the message because `note=`'s prior meaning is what
|
|
513
|
+
// makes the gate necessary rather than merely tidy.
|
|
514
|
+
const NOTE_VERSION=(have)=>
|
|
515
|
+
'note= requires figdown 0.3 (this document declares '+have+'): under figdown '+
|
|
516
|
+
have+' the spelling is still the RETIRED one that meant description=, and an '+
|
|
517
|
+
'engine that accepted it here would repaint a tooltip as ink — a figure that '+
|
|
518
|
+
'looks right and means something else (core §13.0.1). note= is the DRAWN '+
|
|
519
|
+
'annotation: an explanation the human reader must SEE. Raise the header to '+
|
|
520
|
+
'figdown 0.3, or write description= if you meant prose only a machine reads '+
|
|
521
|
+
'(MIGRATIONS 0.3)';
|
|
522
|
+
// (b) The directive is `field`, which refuses the key at EVERY version. The
|
|
523
|
+
// bitfield genre already has `description=` for machine-facing prose, and
|
|
524
|
+
// no measured figure needs a DRAWN per-field aside — granting a directive
|
|
525
|
+
// both keys with no evidence spends the distinction before anyone needs it.
|
|
526
|
+
// The message states the distinction rather than naming a replacement,
|
|
527
|
+
// because `description=` is not a replacement: it reaches a different
|
|
528
|
+
// reader.
|
|
529
|
+
const NOTE_ON_FIELD=
|
|
530
|
+
'note= draws and is not accepted on field; use description= for prose a '+
|
|
531
|
+
'machine reads. The two keys divide by AUDIENCE, not by length: description= '+
|
|
532
|
+
'reaches the reading agent as an SVG <title> and puts no ink on the page, '+
|
|
533
|
+
'while note= is an explanation the human must see. A field\'s presence '+
|
|
534
|
+
'condition is present=, not either of them (MIGRATIONS 0.3)';
|
|
411
535
|
// `PLANE-KEYWORD-SPELLING`: the keyword `plane`/`plane=` was spelled `layer`/`layer=`.
|
|
412
|
-
|
|
536
|
+
// `PAINT-ORDER-CONSTRUCT`: `plane` is WITHDRAWN, so `layer`'s message states the
|
|
537
|
+
// whole chain and ends where `route`'s does — the precedent,
|
|
538
|
+
// when `path` was withdrawn out from under the spelling `route` pointed at.
|
|
539
|
+
// `PAINT-ORDER-CONSTRUCT`: `plane` is WITHDRAWN from the language. The construct
|
|
540
|
+
// left because every genre that could write it lost it at once, and for two
|
|
541
|
+
// different reasons that happen to converge:
|
|
542
|
+
// - `block` and `flowchart` had ZERO authored uses. Every authored use in
|
|
543
|
+
// the tree was a `topology` document.
|
|
544
|
+
// - `topology` had two, and they are the worst domain collision measured in
|
|
545
|
+
// the language: in networking a PLANE is the control / data / management
|
|
546
|
+
// partition of a device — one of the first distinctions the field teaches
|
|
547
|
+
// — and `topology` is precisely the genre network engineers author in.
|
|
548
|
+
// `examples/evpn-fabric.fd` showed the trap already closed: it wrote
|
|
549
|
+
// `plane overlay "VXLAN tunnels" z-index=2`, where `overlay` is itself a
|
|
550
|
+
// networking term, so the line read as a network-architectural assertion
|
|
551
|
+
// and was in fact a paint order.
|
|
552
|
+
// What replaced it was already there. Stripping both writings from that file
|
|
553
|
+
// left the drawn SVG byte-identical apart from one `data-edge` index, because
|
|
554
|
+
// `class=overlay` carried the meaning the whole time.
|
|
555
|
+
const WITHDRAWN_PLANE_WHERE=' The decision and its evidence: MIGRATIONS 0.3, decisions/registry.md.';
|
|
556
|
+
const RETIRED_PLANE='plane has been WITHDRAWN from the language (`PAINT-ORDER-CONSTRUCT`) — removed, not renamed, so there is no replacement spelling. It declared a DRAWING LAYER (a z-order), and in the genre that actually used it "plane" means the control / data / management partition of a network device, so the one word said the wrong thing to exactly the readers who write the figure. Delete the line and delete every plane= that referenced it: paint order is document order, a later line paints on top. If the elements form a logical layer of the SUBJECT, that is a class= whose label states it (core §5, `PRESENTATION-AS-MEANING-CARRIER`) — which is what the two authored uses were already doing alongside it.'+WITHDRAWN_PLANE_WHERE;
|
|
557
|
+
const RETIRED_LAYER='layer has been WITHDRAWN: it was renamed plane, and plane was withdrawn from the language (`PAINT-ORDER-CONSTRUCT`). There is no replacement spelling. Delete the line: everything paints in one plane and paint order is document order (a later line paints on top). A logical layer of the SUBJECT — an overlay, a control plane — is a class= whose label says so (core §5, `PRESENTATION-AS-MEANING-CARRIER`).'+WITHDRAWN_PLANE_WHERE;
|
|
413
558
|
// `THRESHOLD-KEYWORD-SPELLING`: the scene keyword `guide` became `threshold`.
|
|
414
|
-
const RETIRED_GUIDE='guide has been renamed: use threshold (in Illustrator, Inkscape, Figma and draw.io a "guide" is an author-only construction line that is NEVER rendered, while FigDown\'s is drawn output — an INVERTED name, which `UNSAFE-DEFAULT-ELIMINATION` rates worse than an unfamiliar one, and no counter-example was found where "guide" names rendered output. `guide` was also a FigDown coinage, and `SIZE-AND-DIRECTION-KEY-NAMING` makes coining a last resort; `threshold` comes whole from Grafana, whose "Show thresholds" render option offers "As lines", "As filled regions" and "As filled regions and lines" — FigDown\'s marker + region pair, split the same way — with IETF RED/AQM as the secondary source (RFC 2309: "Two RED parameters, minth (minimum threshold) and maxth (maximum threshold)"; RFC 7567: "an AQM algorithm configured with a threshold"). 78% of the measured corpus marks are thresholds; target/mean/reference marks: 0) (MIGRATIONS)';
|
|
559
|
+
const RETIRED_GUIDE='guide has been renamed: use threshold (in Illustrator, Inkscape, Figma and draw.io a "guide" is an author-only construction line that is NEVER rendered, while FigDown\'s is drawn output — an INVERTED name, which `UNSAFE-DEFAULT-ELIMINATION` rates worse than an unfamiliar one, and no counter-example was found where "guide" names rendered output. `guide` was also a FigDown coinage, and `SIZE-AND-DIRECTION-KEY-NAMING` makes coining a last resort; `threshold` comes whole from Grafana, whose "Show thresholds" render option offers "As lines", "As filled regions" and "As filled regions and lines" — FigDown\'s marker + region pair, split the same way — with IETF RED/AQM as the secondary source (RFC 2309: "Two RED parameters, minth (minimum threshold) and maxth (maximum threshold)"; RFC 7567: "an AQM algorithm configured with a threshold"). 78% of the measured corpus marks are thresholds; target/mean/reference marks: 0) (MIGRATIONS 0.1)';
|
|
415
560
|
// `EXTERNAL-ENDPOINT-NAMING`: the scene keyword `boundary` became `external`.
|
|
416
|
-
const RETIRED_BOUNDARY='boundary has been renamed: use external (it declares an external I/O endpoint — the spec\'s own words — while UML\'s «boundary» is an INTERNAL interface object, C4\'s System_Boundary is a dashed grouping container FigDown already spells `group`, and BPMN\'s Boundary Event is a third meaning) (MIGRATIONS)';
|
|
561
|
+
const RETIRED_BOUNDARY='boundary has been renamed: use external (it declares an external I/O endpoint — the spec\'s own words — while UML\'s «boundary» is an INTERNAL interface object, C4\'s System_Boundary is a dashed grouping container FigDown already spells `group`, and BPMN\'s Boundary Event is a third meaning) (MIGRATIONS 0.1)';
|
|
417
562
|
// `ROW-BREAK-NAMING`: the `bitfield` child keyword `wrap` became `break`.
|
|
418
|
-
const RETIRED_WRAP='wrap has been renamed: use break (in CSS and typography `wrap` is AUTOMATIC reflow — a mode — while this directive is an EXPLICIT row break, an event; CSS Fragmentation calls it "a forced break … explicitly indicated by the … author", HTML spells it `br`) (MIGRATIONS)';
|
|
563
|
+
const RETIRED_WRAP='wrap has been renamed: use break (in CSS and typography `wrap` is AUTOMATIC reflow — a mode — while this directive is an EXPLICIT row break, an event; CSS Fragmentation calls it "a forced break … explicitly indicated by the … author", HTML spells it `br`) (MIGRATIONS 0.1)';
|
|
419
564
|
// `PRESENCE-FLAG-SPELLING`: the 0.1 rename `optional` -> `conditional` (`PRESENCE-FLAG-SPELLING`)
|
|
420
565
|
// is REVERTED. `conditional` has zero attestation as a wire-format field
|
|
421
566
|
// marker and zero uses in the downstream corpus, while "optional" appears in
|
|
422
567
|
// 34 downstream field LABELS — authors wrote the word in the label precisely
|
|
423
568
|
// because the keyword no longer said it. The MODEL key moves with the surface
|
|
424
569
|
// (`NORMATIVE-SEMANTIC-MODEL`): it is `optional` again on both sides.
|
|
425
|
-
const RETIRED_FIELD_CONDITIONAL='the field flag "conditional" has been retired: write present="<the condition>" (or present="" if the condition is not stated). "conditional" was attested as a wire-format field marker nowhere — zero hits in RFC 2784, ASN.1 X.680, draft-mcquistin-augmented-ascii-diagrams, SystemRDL, IP-XACT, Kaitai Struct and protobuf — and the flag it briefly replaced, "optional", is retired too: an option key carrying the CONDITION says what a bare flag could not (MIGRATIONS)';
|
|
570
|
+
const RETIRED_FIELD_CONDITIONAL='the field flag "conditional" has been retired: write present="<the condition>" (or present="" if the condition is not stated). "conditional" was attested as a wire-format field marker nowhere — zero hits in RFC 2784, ASN.1 X.680, draft-mcquistin-augmented-ascii-diagrams, SystemRDL, IP-XACT, Kaitai Struct and protobuf — and the flag it briefly replaced, "optional", is retired too: an option key carrying the CONDITION says what a bare flag could not (MIGRATIONS 0.1)';
|
|
426
571
|
// `PRESENCE-CONDITION-EXPRESSION`: the positional flag `optional` becomes the option key
|
|
427
572
|
// `present=`, whose VALUE is the presence condition. A bare flag could say
|
|
428
573
|
// only THAT a field is conditional; every RFC that draws one also states WHY
|
|
@@ -431,7 +576,7 @@ const RETIRED_FIELD_CONDITIONAL='the field flag "conditional" has been retired:
|
|
|
431
576
|
// prose the model may not read. `present` is the attested spelling: X.680
|
|
432
577
|
// PRESENT, IP-XACT isPresent, SystemRDL ispresent, RFC 2784 "present only
|
|
433
578
|
// if", draft-mcquistin "present only when".
|
|
434
|
-
const RETIRED_FIELD_OPTIONAL='the field flag "optional" has been retired and replaced by an option key that carries the CONDITION: write present="<the condition>" (e.g. field "Checksum" 16 present="C = 1"), or present="" when the condition is not stated. The bare flag could say only THAT the field was conditional, so the condition had to live in note= — invisible to the human reading the figure, and prose the model may not parse (`BITFIELD-CONDITIONAL-OFFSETS`). present= DRAWS: the field stays dashed and a stated condition becomes a caption under the block (MIGRATIONS)';
|
|
579
|
+
const RETIRED_FIELD_OPTIONAL='the field flag "optional" has been retired and replaced by an option key that carries the CONDITION: write present="<the condition>" (e.g. field "Checksum" 16 present="C = 1"), or present="" when the condition is not stated. The bare flag could say only THAT the field was conditional, so the condition had to live in the field\'s documentation prose — the key spelled note= at the time and description= — where it was invisible to the human reading the figure, and prose the model may not parse (`BITFIELD-CONDITIONAL-OFFSETS`). (Today\'s note= is a different key: it is the DRAWN annotation revived, it is refused on field, and it is not where a presence condition belongs either.) present= DRAWS: the field stays dashed and a stated condition becomes a caption under the block (MIGRATIONS 0.1)';
|
|
435
580
|
// `TIMING-GENRE-NAMING`: the EXPERIMENTAL genre `wave` became `timing`, both as
|
|
436
581
|
// the header genre token and as the block opener. The old name was WaveDrom's
|
|
437
582
|
// MEMBER KEY, not its figure name: in WaveJSON `signal` is the root object and
|
|
@@ -448,8 +593,8 @@ const RETIRED_FIELD_OPTIONAL='the field flag "optional" has been retired and rep
|
|
|
448
593
|
// to know that the keys survive unchanged and only their carrier moved.
|
|
449
594
|
// RULE 6.2 placement: the spelling left the LANGUAGE, so this fires wherever
|
|
450
595
|
// it appears at line start, in every genre, ahead of the `GENRE-KEYWORD-ALLOWLIST` allowlist.
|
|
451
|
-
const RETIRED_SIZE='size has been retired: its keys moved onto pin — write pin <id> width=<px> height=<px> (one directive carries an element\'s whole declared geometry: at= places it, width=/height= extend it; all three keys are optional and a pin with none of them declares nothing) (MIGRATIONS)';
|
|
452
|
-
const RETIRED_WAVE='wave has been renamed: use timing (in WaveJSON `signal` is the root object and `wave` is a PROPERTY of one signal — its lane activity string — so `wave` named a member key, not a figure kind; WaveDrom\'s own name for the figure is "Digital Timing Diagram", "timing diagram" is the datasheet/JEDEC term for it, and UML 2.5.1\'s Timing Diagram is the same concept. The rename frees `wave` for the lane) (MIGRATIONS)';
|
|
596
|
+
const RETIRED_SIZE='size has been retired: its keys moved onto pin — write pin <id> width=<px> height=<px> (one directive carries an element\'s whole declared geometry: at= places it, width=/height= extend it; all three keys are optional and a pin with none of them declares nothing) (MIGRATIONS 0.1)';
|
|
597
|
+
const RETIRED_WAVE='wave has been renamed: use timing (in WaveJSON `signal` is the root object and `wave` is a PROPERTY of one signal — its lane activity string — so `wave` named a member key, not a figure kind; WaveDrom\'s own name for the figure is "Digital Timing Diagram", "timing diagram" is the datasheet/JEDEC term for it, and UML 2.5.1\'s Timing Diagram is the same concept. The rename frees `wave` for the lane) (MIGRATIONS 0.1)';
|
|
453
598
|
// `EDGE-GEOMETRY-CONSTRUCTS`: `path` and `routing` are WITHDRAWN from the language.
|
|
454
599
|
// These two diagnostics are a NEW SHAPE for this table. Every retirement
|
|
455
600
|
// before them named a replacement spelling — `size` named `pin`, `guide` named
|
|
@@ -463,19 +608,19 @@ const RETIRED_WAVE='wave has been renamed: use timing (in WaveJSON `signal` is t
|
|
|
463
608
|
// not "use X"), says what an author should do instead (delete the line and let
|
|
464
609
|
// auto layout draw it, with the content-zone means named), and points at where
|
|
465
610
|
// the decision is RECORDED so the reasoning is one lookup away.
|
|
466
|
-
const WITHDRAWN_WHERE=' The decision and its evidence: MIGRATIONS 0.1, core §9 `EDGE-IDENTITY-AND-GEOMETRY`, decisions/registry.md';
|
|
611
|
+
const WITHDRAWN_WHERE=' The decision and its evidence: MIGRATIONS 0.1, core §9 `EDGE-IDENTITY-AND-GEOMETRY`, decisions/registry.md.';
|
|
467
612
|
const RETIRED_PATH='path has been WITHDRAWN from the language (`EDGE-GEOMETRY-CONSTRUCTS`) — removed, not renamed, so there is no replacement spelling. A prior-art study of Visio, draw.io/mxGraph, Graphviz and ELK found author waypoints OUTSIDE the stable intersection: only 2 of the 4 model them, and those 2 disagree on what happens when an endpoint moves. The dock realisation was outside it too — written-order attachment has zero prior art in any surveyed system. Delete the line: the edge draws under auto layout, and `rank`, `flow`, declaration order and `pin` are the content-zone means of shaping it.'+WITHDRAWN_WHERE;
|
|
468
613
|
const RETIRED_ROUTING='routing has been WITHDRAWN from the language (`EDGE-GEOMETRY-CONSTRUCTS`) — removed, not renamed, so there is no replacement spelling. Two routing modes and two scopes ARE inside the stable prior-art intersection, so the need is recognised and its shape is known; what is missing is the evidence and the implementation (6 of the 8 in-repo `routing=orthogonal` writings were provable no-ops, and downstream adoption was zero), and the per-edge scope cannot be restored without an edge-identity construct FigDown does not have. Delete the line; the edges draw straight.'+WITHDRAWN_WHERE;
|
|
469
614
|
// `TIMING-LANE-ALPHABET`: the timing lane digits `2`-`9` left the closed alphabet.
|
|
470
|
-
const RETIRED_LANE_DIGIT='timing lane digits 2-9 have been retired: write "=" for a data cell and name it in data= (WaveDrom defines 2..9 as "value with color N" and "=" as "value (default color 2)" — the same brick with a palette index, while FigDown drew the digit character itself as the box label and consumed no data entry, so the two readings of one lane differed silently) (MIGRATIONS)';
|
|
615
|
+
const RETIRED_LANE_DIGIT='timing lane digits 2-9 have been retired: write "=" for a data cell and name it in data= (WaveDrom defines 2..9 as "value with color N" and "=" as "value (default color 2)" — the same brick with a palette index, while FigDown drew the digit character itself as the box label and consumed no data entry, so the two readings of one lane differed silently) (MIGRATIONS 0.1)';
|
|
471
616
|
// 0.1 (§8.4): `edge`, `threshold` and `bundle` have NO interior, so
|
|
472
617
|
// `fill=` and `stroke=` named the SAME channel and `stroke=` won silently —
|
|
473
618
|
// two keys for one channel, resolved by an undocumented precedence that
|
|
474
619
|
// produced a legal, wrong figure whenever both were written (16 lines in
|
|
475
620
|
// this repository, 3 of them writing both on one line). Same defect shape as
|
|
476
621
|
// the retired `color=`; same cure, a named diagnostic.
|
|
477
|
-
const NO_INTERIOR=new Set(['edge','threshold','bundle']);
|
|
478
|
-
const FILL_NO_INTERIOR=k=>k+' has no interior, so fill= and stroke= name the same channel (stroke= won silently) — write stroke= (MIGRATIONS)';
|
|
622
|
+
const NO_INTERIOR=new Set(['edge','flowline','transition','threshold','bundle']);
|
|
623
|
+
const FILL_NO_INTERIOR=k=>k+' has no interior, so fill= and stroke= name the same channel (stroke= won silently) — write stroke= (MIGRATIONS 0.1)';
|
|
479
624
|
// `STYLE-KEY-SCOPE`: `style=` left these three directives (it stays live on
|
|
480
625
|
// node/group/edge/class/bundle/threshold/band). The generic
|
|
481
626
|
// "<directive> does not take style=" would be true but would not say why, and
|
|
@@ -486,11 +631,11 @@ const FILL_NO_INTERIOR=k=>k+' has no interior, so fill= and stroke= name the sam
|
|
|
486
631
|
// are closed here the way every other one-channel-two-keys collision in this
|
|
487
632
|
// language was closed — a named line error, not a precedence rule. A
|
|
488
633
|
// precedence rule is what `STYLE-KEY-SCOPE` had just finished removing from `field`.
|
|
489
|
-
const CELL_HL_ON_CELL='highlight is a ROW mark and takes the single-valued row form (cell <row> highlight) — on a cell address it was SILENTLY DISCARDED and never reached the model, while the cell fill drew. A row tint and a cell fill paint the same channel, so writing both for one cell has no honest resolution: tint the row (cell <row> highlight) or paint the cell (cell (<row>,<col>) fill=…/class=…), not both (MIGRATIONS)';
|
|
490
|
-
const CELL_HL_ROW_CONFLICT=(r,c)=>'cell ('+r+','+c+') resolves to a fill on row '+r+', which is highlighted — the cell fill overrides the row tint, so the model says "row '+r+' is highlighted" while the drawing shows only part of the row tinted (`PRESENTATION-AS-MEANING-CARRIER`: presentation may render meaning, never delete it). Drop the row highlight, or move the cell fill to a row that carries none (MIGRATIONS)';
|
|
634
|
+
const CELL_HL_ON_CELL='highlight is a ROW mark and takes the single-valued row form (cell <row> highlight) — on a cell address it was SILENTLY DISCARDED and never reached the model, while the cell fill drew. A row tint and a cell fill paint the same channel, so writing both for one cell has no honest resolution: tint the row (cell <row> highlight) or paint the cell (cell (<row>,<col>) fill=…/class=…), not both (MIGRATIONS 0.1)';
|
|
635
|
+
const CELL_HL_ROW_CONFLICT=(r,c)=>'cell ('+r+','+c+') resolves to a fill on row '+r+', which is highlighted — the cell fill overrides the row tint, so the model says "row '+r+' is highlighted" while the drawing shows only part of the row tinted (`PRESENTATION-AS-MEANING-CARRIER`: presentation may render meaning, never delete it). Drop the row highlight, or move the cell fill to a row that carries none (MIGRATIONS 0.1)';
|
|
491
636
|
const NO_ITEM_STYLE=new Set(['field','cell','signal']);
|
|
492
637
|
const STYLE_NO_ITEM=k=>k+' does not take style= — '+(k==='field'
|
|
493
|
-
? 'on a field the dash IS conditional presence (`present=`, spelled `optional` until
|
|
638
|
+
? 'on a field the dash IS conditional presence (`present=`, spelled `optional` until 0.1), and style=solid erased it while the model still recorded the field as conditionally present (`PRESENTATION-AS-MEANING-CARRIER`: presentation may render meaning, never be its only carrier)'
|
|
494
639
|
: 'a dash on one '+k+' carried no meaning the block does not already carry, and 0 documents outside this repository wrote it')
|
|
495
640
|
// `DESCRIPTION-KEY-SPELLING` corrected the second half of this message. It used to
|
|
496
641
|
// offer `note=` as a place to put knowledge, which was wrong twice over:
|
|
@@ -499,7 +644,7 @@ const STYLE_NO_ITEM=k=>k+' does not take style= — '+(k==='field'
|
|
|
499
644
|
// human, which is the same defect `STYLE-KEY-SCOPE` exists to close. The two channels
|
|
500
645
|
// that DRAW are the name/label and a `class` meaning (which also earns a
|
|
501
646
|
// legend entry).
|
|
502
|
-
+'. Delete the key; if the distinction is knowledge, write it in the name/label or in a class= meaning — both of which DRAW; description= is documentation prose and produces no ink beyond a tooltip (MIGRATIONS)';
|
|
647
|
+
+'. Delete the key; if the distinction is knowledge, write it in the name/label or in a class= meaning — both of which DRAW; description= is documentation prose and produces no ink beyond a tooltip (MIGRATIONS 0.1)';
|
|
503
648
|
function splitOpts(toks, laneMode){
|
|
504
649
|
// a repeated option key on one line is a line error, never
|
|
505
650
|
// silent last-wins. `dup` names the first key that appeared twice.
|
|
@@ -549,7 +694,7 @@ const ID_RE=/^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
|
549
694
|
// `a`+`x--b`) and the greedy member regex silently committed to the first,
|
|
550
695
|
// making the second unreachable and undiagnosed — RULE 6.3 says malformed
|
|
551
696
|
// input is an error, never a guess. Zero ids in either corpus contain `--`.
|
|
552
|
-
const DD_ID='"--" is not allowed inside an id — it is the link operator (edge a -- b, bundle t1 a--b); write a single "-" or "_" (MIGRATIONS)';
|
|
697
|
+
const DD_ID='"--" is not allowed inside an id — it is the link operator (edge a -- b, bundle t1 a--b); write a single "-" or "_" (MIGRATIONS 0.1)';
|
|
553
698
|
// `QUOTED-IDS`: ONE wording for every id position. It covers both
|
|
554
699
|
// halves of the defect it closes — a needlessly quoted legal id
|
|
555
700
|
// (`node "a"`, silently accepted before) and a quoted token that is not a
|
|
@@ -568,7 +713,7 @@ const DD_ID='"--" is not allowed inside an id — it is the link operator (edge
|
|
|
568
713
|
// old failure named the wrong thing (`node a Cache miss` reported
|
|
569
714
|
// `unexpected argument "miss"` — a surplus argument, when the defect was a
|
|
570
715
|
// missing quote).
|
|
571
|
-
const Q_WHY='whitespace also separates positionals, so a bare token cannot express a phrase (MIGRATIONS)';
|
|
716
|
+
const Q_WHY='whitespace also separates positionals, so a bare token cannot express a phrase (MIGRATIONS 0.1)';
|
|
572
717
|
const ID_RULE='ids are bare and match [A-Za-z_][A-Za-z0-9_-]* — text with spaces or punctuation belongs in the label: node <id> "your text"';
|
|
573
718
|
// isId: the whole id test, used at every id position in the language.
|
|
574
719
|
const isId=v=>typeof v==='string'&&ID_RE.test(v)&&!v.includes('--');
|
|
@@ -756,9 +901,55 @@ function parseIndexRange(v){
|
|
|
756
901
|
const CORE_KW=['figdown','title','layout'];
|
|
757
902
|
const LAYOUT_KW=['pin']; // `LAYOUT-ZONE-NAMESPACE`, NORMATIVE — the whole namespace
|
|
758
903
|
const GENRE_FREE_KW=CORE_KW.concat(LAYOUT_KW);
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
904
|
+
// `GENRE-CONNECTOR-SPELLING`/`GENRE-NODE-SPELLING`: the NODE and CONNECTOR spellings are per genre, so
|
|
905
|
+
// they are NOT in the shared list — every scene genre concats its own two.
|
|
906
|
+
//
|
|
907
|
+
// `SUBJECT-VOCABULARY-SCOPE`: SUBJECT VOCABULARY IS PER GENRE, AND THERE IS NO SHARED
|
|
908
|
+
// LIST OF IT. `SCENE_KW_TOP` and `SCENE_EXP_KW` are gone. They held the words
|
|
909
|
+
// that say what a figure is OF — `group`, `external`, `threshold`, `band`,
|
|
910
|
+
// `bundle`, `plane` — in one array concatenated into four genres, which is
|
|
911
|
+
// the same defect core §3's "scene keywords" sentence recorded: an
|
|
912
|
+
// INTERSECTION written down as if it were a namespace. Under `GENRE-VOCABULARY-OBLIGATION` a genre owns
|
|
913
|
+
// its words, so each scene genre now names its own subject vocabulary in its
|
|
914
|
+
// own array below. Two arrays agreeing is TWO DECLARATIONS that agree today,
|
|
915
|
+
// never one declaration inherited, and either may be withdrawn, renamed or
|
|
916
|
+
// constrained without touching the other.
|
|
917
|
+
//
|
|
918
|
+
// What stays shared, and why that is not a contradiction:
|
|
919
|
+
// - `class` is STYLING declaration and `flow`/`rank` are LAYOUT INTENT.
|
|
920
|
+
// None of the three describes a referent, so no genre's domain holds a
|
|
921
|
+
// competing meaning for them and no genre can independently earn or lose
|
|
922
|
+
// one. They are nearer `LAYOUT-ZONE-NAMESPACE`'s genre-independent layout namespace than `GENRE-VOCABULARY-OBLIGATION`.
|
|
923
|
+
// - `bitfield`/`table`/`timing`/`chart` are `GENRE-COMPOSITION` REGION OPENERS: composition,
|
|
924
|
+
// not subject vocabulary. The region's own namespace is the nested
|
|
925
|
+
// genre's.
|
|
926
|
+
const SCENE_STYLE_KW=['class','flow','rank'];
|
|
927
|
+
const SCENE_REGION_KW=['bitfield','table','timing','chart'];
|
|
928
|
+
const SCENE_HOST_KW=GENRE_FREE_KW.concat(SCENE_STYLE_KW, SCENE_REGION_KW);
|
|
929
|
+
// --- Each scene genre's OWN subject vocabulary. One array per genre. ---
|
|
930
|
+
// `block` (NORMATIVE): `group` and `external` are normative; `threshold` and
|
|
931
|
+
// `band` are EXPERIMENTAL and are the `GENRE-EARNING-THRESHOLD` INTERIM scalar-marker pair, held here
|
|
932
|
+
// deliberately unfrozen so the future scalar-marker genre can name them once
|
|
933
|
+
// WITH a scale. They are not renamed now — a rename would hand that genre a
|
|
934
|
+
// retired word.
|
|
935
|
+
const BLOCK_SUBJECT_KW=['group','external','threshold','band'];
|
|
936
|
+
// `topology` (EXPERIMENTAL): `bundle` is the one construct whose domain
|
|
937
|
+
// reading and drawn reading are the same reading — a LAG (IEEE 802.1AX), an
|
|
938
|
+
// ECMP set, an EVPN Ethernet Segment. `group`/`external` keep their block
|
|
939
|
+
// spellings because every networking synonym is more taken (`zone` DNS and
|
|
940
|
+
// firewall, `cluster` RFC 4456, `domain` RFC 7926, `area` OSPF, `site` EVPN)
|
|
941
|
+
// and their collisions are SOFT — the picture contradicts the wrong reading.
|
|
942
|
+
const TOPOLOGY_SUBJECT_KW=['group','external','bundle'];
|
|
943
|
+
// `flowchart` (EXPERIMENTAL): `external` only — the off-page terminus, ISO
|
|
944
|
+
// 5807 §9.4.2 *Terminator* being ISO's word for the concept and already this
|
|
945
|
+
// genre's live keyword, so the spelling stays. `group` had one occurrence in
|
|
946
|
+
// the whole tree and it was this genre's own reference figure.
|
|
947
|
+
const FLOWCHART_SUBJECT_KW=['external'];
|
|
948
|
+
// `statechart` (EXPERIMENTAL): NONE, and the empty array is the declaration.
|
|
949
|
+
// Three authored statechart figures, all transcribed from RFCs, reach for
|
|
950
|
+
// none of the six; `external` is additionally UML 2.5.1 §14's own
|
|
951
|
+
// `TransitionKind` literal and is reserved for it (`RESERVED-SPELLINGS`).
|
|
952
|
+
const STATECHART_SUBJECT_KW=[];
|
|
762
953
|
// `FLOWCHART-ROLE-KEYWORDS`: the flowchart ROLE vocabulary — the FIRST exercise of
|
|
763
954
|
// `GENRE-NAMESPACE` `GENRE-VOCABULARY-OBLIGATION` ("a genre owns its words"). These three are legal ONLY under
|
|
764
955
|
// `figdown 0.1 flowchart`; `GENRE-NAMESPACE`'s allowlist is what makes `decision x` a line
|
|
@@ -772,10 +963,163 @@ const FLOWCHART_ROLE_KW=['process','decision','terminator'];
|
|
|
772
963
|
// only its default drawing, and `shape=` on the same line overrides the
|
|
773
964
|
// drawing without touching the role (§12.7).
|
|
774
965
|
const ROLE_SHAPE={process:'box',decision:'diamond',terminator:'rounded'};
|
|
966
|
+
|
|
967
|
+
// `GENRE-CONNECTOR-SPELLING`/`GENRE-NODE-SPELLING`: PER-GENRE NODE AND CONNECTOR SPELLINGS.
|
|
968
|
+
// Each scene genre takes the word its own domain uses for the line between
|
|
969
|
+
// two things, and for the thing itself. The criterion is THE TERM THE DOMAIN
|
|
970
|
+
// ACTUALLY USES, not the standard's exact orthography (see the vocabulary
|
|
971
|
+
// rows: `flowline` carries the same ISO-clause verification debt
|
|
972
|
+
// `terminator` does, recorded rather than claimed away).
|
|
973
|
+
//
|
|
974
|
+
// block / topology node edge (DOT, unchanged)
|
|
975
|
+
// flowchart node flowline (ISO 5807)
|
|
976
|
+
// statechart state transition (OMG UML 2.5.1 §14)
|
|
977
|
+
//
|
|
978
|
+
// The ASYMMETRY is deliberate and is the whole of `GENRE-CONNECTOR-SPELLING` vs `GENRE-NODE-SPELLING`: `node`
|
|
979
|
+
// STAYS in `flowchart`, because there a stage can have a role THE SOURCE
|
|
980
|
+
// DOES NOT STATE, and `node` is the only spelling for that — forcing
|
|
981
|
+
// `process` would make the transcriber assert what the source never said.
|
|
982
|
+
// `statechart` has exactly ONE kind of node, so nothing can be left unstated
|
|
983
|
+
// and `state` loses nothing. `BARE-NODE-MEANING` CORRECTS the reason this
|
|
984
|
+
// comment used to give ("ISO has ~ten symbol kinds and we carry three"): a
|
|
985
|
+
// symbol this genre cannot spell is a COVERAGE GAP in FigDown, not a state
|
|
986
|
+
// of the figure, and `node` is not its spelling — see
|
|
987
|
+
// the project’s working record for the coverage ledger.
|
|
988
|
+
const GENRE_NODE_KW={block:'node',topology:'node',flowchart:'node',statechart:'state'};
|
|
989
|
+
const GENRE_CONNECTOR_KW={block:'edge',topology:'edge',flowchart:'flowline',statechart:'transition'};
|
|
990
|
+
const NODE_SPELLINGS=new Set(['node','state']);
|
|
991
|
+
const CONNECTOR_SPELLINGS=new Set(['edge','flowline','transition']);
|
|
992
|
+
// `KEYWORD-RENAME-SCOPE`: the flowchart rename is GATED BY THE DECLARED LANGUAGE
|
|
993
|
+
// VERSION, because `GENRE-CONNECTOR-SPELLING` applied it to `figdown 0.1` and that BROKE documents
|
|
994
|
+
// legal at v0.1.8 — `figdown 0.1 flowchart` + `edge` stopped parsing, with
|
|
995
|
+
// nothing recording the break as a decision. Under core §13.0 only X removes,
|
|
996
|
+
// so 0.1 keeps its spelling:
|
|
997
|
+
//
|
|
998
|
+
// figdown 0.1 flowchart `edge` legal, `flowline` is a VERSION error
|
|
999
|
+
// figdown 0.2 flowchart `flowline` legal, `edge` is the WRONG_WORD error
|
|
1000
|
+
//
|
|
1001
|
+
// Two spellings inside ONE version is what the no-alias rule (`IDENTITY-ASSERTION`)
|
|
1002
|
+
// forbids; two spellings across VERSIONS is ordinary language evolution, and
|
|
1003
|
+
// each version accepts exactly one. `statechart` needs no gate of its own —
|
|
1004
|
+
// the GENRE requires 0.2 (GENRES_BY_VERSION), so `state`/`transition` cannot
|
|
1005
|
+
// be reached from a 0.1 document at all.
|
|
1006
|
+
const GENRE_CONNECTOR_KW_AT={
|
|
1007
|
+
'0.1':{block:'edge',topology:'edge',flowchart:'edge'},
|
|
1008
|
+
'0.2':GENRE_CONNECTOR_KW
|
|
1009
|
+
};
|
|
1010
|
+
const connectorKwAt=(genre,ver)=>
|
|
1011
|
+
((GENRE_CONNECTOR_KW_AT[ver]||GENRE_CONNECTOR_KW)[genre])||undefined;
|
|
1012
|
+
// The version a connector spelling FIRST becomes legal in, so the diagnostic
|
|
1013
|
+
// can name it the way the genre gate already names `figdown 0.2`.
|
|
1014
|
+
const CONNECTOR_MIN_VERSION={flowline:'0.2',transition:'0.2'};
|
|
1015
|
+
const WRONG_VERSION_WORD=(surf,want,genre,need,have)=>
|
|
1016
|
+
'"'+surf+'" requires figdown '+need+' (this document declares '+have+'): '+
|
|
1017
|
+
'under figdown '+have+' genre '+genre+' spells this "'+want+'". The rename is '+
|
|
1018
|
+
'gated by the language version — a figdown '+have+' document keeps the spelling it '+
|
|
1019
|
+
'was written with (core §13.0: only a MAJOR version removes) — so raise the header '+
|
|
1020
|
+
'to figdown '+need+' or write "'+want+'" (MIGRATIONS 0.2)';
|
|
1021
|
+
// Why each genre's word is its word — quoted in the diagnostic, because
|
|
1022
|
+
// "not allowed in genre X" tells an author nothing about what to write.
|
|
1023
|
+
const WORD_WHY={
|
|
1024
|
+
edge:'a block or topology figure is a graph, and `edge` is the graph word (DOT)',
|
|
1025
|
+
flowline:'the connecting line in a flowchart is a FLOWLINE — the term the flowchart domain commonly uses for the symbol ISO 5807 §9.3.1 names "Line"',
|
|
1026
|
+
transition:'the connecting line in a statechart is a TRANSITION — the term UML 2.5.1 §14 uses for it',
|
|
1027
|
+
node:'this genre has more kinds of thing than it has words for, so `node` is the general one',
|
|
1028
|
+
state:'a statechart has exactly ONE kind of node and it is a STATE (UML 2.5.1 §14)'
|
|
1029
|
+
};
|
|
1030
|
+
// The named diagnostic `GENRE-CONNECTOR-SPELLING`/`GENRE-NODE-SPELLING` owe: it says WHICH word this genre uses and
|
|
1031
|
+
// WHY, and it names the migration, because every connector line in a
|
|
1032
|
+
// reclassified document has to be rewritten (the cost `GENRE-CONNECTOR-SPELLING` accepted).
|
|
1033
|
+
const WRONG_WORD=(surf,want,genre)=>
|
|
1034
|
+
'"'+surf+'" is not the word genre '+genre+' uses for this — write "'+want+'": '+WORD_WHY[want]+
|
|
1035
|
+
'. Each scene genre takes the term its own domain uses (block/topology `node` `edge`, flowchart `node` `flowline`, statechart `state` `transition`) — run tools/migrate-figdown.js to rewrite it (MIGRATIONS 0.2)';
|
|
1036
|
+
// `SCENE-KEYWORD-MEMBERSHIP`: a word WITHDRAWN FROM ONE GENRE is not an unknown word,
|
|
1037
|
+
// and `"threshold" is not allowed in genre topology` would send an author
|
|
1038
|
+
// looking for a typo. Each cell below was legal until this release and states
|
|
1039
|
+
// WHY that genre no longer declares it — the ruling's own ground, per cell,
|
|
1040
|
+
// because the grounds differ and a single sentence could not carry them.
|
|
1041
|
+
// Every one of these withdrawals was FREE: `topology`, `flowchart` and
|
|
1042
|
+
// `statechart` are EXPERIMENTAL genres outside the compatibility promise, and
|
|
1043
|
+
// in `block` the two withdrawn words were EXPERIMENTAL keywords (`EDGE-GEOMETRY-CONSTRUCTS` precedent:
|
|
1044
|
+
// experimental withdrawal, no gate, no rewrite owed).
|
|
1045
|
+
const WITHDREW_AT=' (withdrawn, `SCENE-KEYWORD-MEMBERSHIP`; MIGRATIONS 0.3)';
|
|
1046
|
+
const GENRE_WITHDRAWN={
|
|
1047
|
+
block:{
|
|
1048
|
+
bundle:'`bundle` is now declared by `topology` only. It had ZERO authored uses under `block` — every authored link bundle in the corpus is a topology document — and the construct is defined by a REFERENT that only that genre has: a LAG (IEEE 802.1AX), an ECMP set, an EVPN Ethernet Segment. Under `block` it was a ring around parallel edges with nothing to name.'
|
|
1049
|
+
},
|
|
1050
|
+
topology:{
|
|
1051
|
+
threshold:'`threshold` is now declared by `block` only. It had ZERO occurrences under `topology` in the whole corpus, and in this genre\'s domain a threshold is a QUEUE DEPTH WITH A NUMERIC VALUE (RFC 2309 minth/maxth, RFC 7567) — while FigDown\'s takes no value= and its offset= is a fraction of the target\'s rendered extent, not a quantity. Author the figure as `block`, where the `GENRE-EARNING-THRESHOLD` scalar-marker evidence lives.',
|
|
1052
|
+
band:'`band` is now declared by `block` only. Its two occurrences under `topology` were both conformance fixtures, never a figure anyone needed, and in this genre a BAND is a frequency band — radio, wireless, microwave, optical transport — which is exactly the kind of figure a topology document draws. Author the figure as `block`.'
|
|
1053
|
+
},
|
|
1054
|
+
flowchart:{
|
|
1055
|
+
group:'`flowchart` no longer declares `group`. Its one occurrence in the corpus was this genre\'s own reference figure, which exists to demonstrate every form of every keyword — so citing it as evidence of need is circular. There were no authored uses.',
|
|
1056
|
+
threshold:'`flowchart` no longer declares `threshold`. Zero occurrences, and the construct does not apply: a threshold is a labelled reference value drawn at a percentage of the target\'s RENDERED EXTENT, and a process box\'s extent is an artifact of its label length, so the line asserts nothing a reader can read.',
|
|
1057
|
+
band:'`flowchart` no longer declares `band`. Zero occurrences, and a band is a RANGE over that same meaningless extent.',
|
|
1058
|
+
bundle:'`flowchart` no longer declares `bundle`. Zero occurrences, and parallel flowlines between the same two stages are different CONDITIONS; drawing a ring round them hides what the figure is for.'
|
|
1059
|
+
},
|
|
1060
|
+
statechart:{
|
|
1061
|
+
group:'`statechart` declares NO subject vocabulary at all. UML\'s grouping construct is the COMPOSITE STATE and its REGIONS, and under the single-source-vocabulary rule a statechart that needed grouping should take UML 2.5.1 §14\'s word for it — declared in this genre\'s own document — rather than inherit another genre\'s.',
|
|
1062
|
+
external:'`statechart` declares NO subject vocabulary at all, and `external` is additionally RESERVED here: UML 2.5.1 §14 defines TransitionKind as `external | internal | local`, so in this genre\'s own source standard "external" already names A TRANSITION THAT EXITS AND RE-ENTERS ITS SOURCE STATE. FigDown\'s `external` means an endpoint outside the figure that is never drawn — same word, same genre, same standard, unrelated meanings.',
|
|
1063
|
+
threshold:'`statechart` declares NO subject vocabulary at all. A state has no extent that means anything — its box is sized by its label — so a reference value drawn 60% down it asserts nothing.',
|
|
1064
|
+
band:'`statechart` declares NO subject vocabulary at all, and a band is a range over that same meaningless extent.',
|
|
1065
|
+
bundle:'`statechart` declares NO subject vocabulary at all, and here `bundle` is an ANTI-FEATURE: two transitions between the same pair of states are two different TRIGGERS, and the trigger is the whole content of the arc. Bundling them draws away exactly what the figure is for.'
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
const WITHDRAWN_FROM_GENRE=(kw,genre)=>
|
|
1069
|
+
'"'+kw+'" is not allowed in genre '+genre+' — it was WITHDRAWN from this genre, not misspelled: '+
|
|
1070
|
+
GENRE_WITHDRAWN[genre][kw]+
|
|
1071
|
+
' Subject vocabulary is per genre (core §3, `GENRE-VOCABULARY-OBLIGATION`): a spelling accepted by several genres is several '+
|
|
1072
|
+
'independent declarations, and this genre\'s was withdrawn without touching any other\'s.'+WITHDREW_AT;
|
|
1073
|
+
// `MEMBERSHIP-KEY-ACCEPTANCE`: THE OPTION-KEY HALF OF `SCENE-KEYWORD-MEMBERSHIP`. A per-genre withdrawal can
|
|
1074
|
+
// strand an option KEY as easily as it strands a keyword: `in=` states
|
|
1075
|
+
// membership and its ONLY value domain is the id of a containing `group`, so
|
|
1076
|
+
// once `SCENE-KEYWORD-MEMBERSHIP` stopped `flowchart` and `statechart` from declaring a `group` the
|
|
1077
|
+
// key stayed accepted with nothing it could name. The measured symptom was
|
|
1078
|
+
// `process a "A" in=g` answering `unknown group "g"` with NO spelling that
|
|
1079
|
+
// succeeds — a dangling reference every author reaches by writing the key at
|
|
1080
|
+
// all. The other acceptors of `in=` in the language are `threshold` and
|
|
1081
|
+
// `band`, whose domain `MARKER-TARGET-KINDS` widened to REGION ids; neither is a keyword of
|
|
1082
|
+
// either genre since `SCENE-KEYWORD-MEMBERSHIP`, and the widening never reached `node`, so a
|
|
1083
|
+
// `flowchart` document that declares `table q` still answers `unknown group
|
|
1084
|
+
// "q"` for `node a "A" in=q`. Nothing in either genre was left un-stranded,
|
|
1085
|
+
// which is why the withdrawal is by KEY here and not directive by directive.
|
|
1086
|
+
//
|
|
1087
|
+
// The grounds differ per genre and are stated per cell, as `SCENE-KEYWORD-MEMBERSHIP`'s are:
|
|
1088
|
+
// `flowchart`'s is that every value is a dead end, `statechart`'s is that the
|
|
1089
|
+
// spelling is RESERVED for a different domain. Both genres are EXPERIMENTAL,
|
|
1090
|
+
// so both withdrawals are free — the `EDGE-GEOMETRY-CONSTRUCTS` precedent, no gate and no rewrite
|
|
1091
|
+
// owed — which is also what makes re-adding `in=` to `statechart` later with
|
|
1092
|
+
// a `state`-id domain cost nothing.
|
|
1093
|
+
const WITHDREW_OPT_AT=' (withdrawn, `MEMBERSHIP-KEY-ACCEPTANCE`; MIGRATIONS 0.3)';
|
|
1094
|
+
const GENRE_WITHDRAWN_OPT={
|
|
1095
|
+
flowchart:{
|
|
1096
|
+
in:'`flowchart` no longer accepts `in=`. Its only value domain was the id of a containing `group`, and this genre has not declared `group` (`SCENE-KEYWORD-MEMBERSHIP`) — so EVERY value was a dead end: `in=x` answered `unknown group "x"` and no spelling succeeded. An unknown-option error that names the reason beats a dangling reference no author can satisfy. What expresses membership TODAY is `class=`: declare `class ingress "Ingress phase"` and write `class=ingress` on each stage — it earns a legend entry and applies to every member at once. Containment in a flowchart is an OPEN question and the construct the need is waiting on is a swimlane, not a box (spec/genres/experimental/flowchart.md, What is excluded).'
|
|
1097
|
+
},
|
|
1098
|
+
statechart:{
|
|
1099
|
+
in:'`statechart` no longer accepts `in=`, and the spelling is RESERVED rather than merely dropped. This genre declares NO subject vocabulary (`SUBJECT-VOCABULARY-SCOPE`), so the `group` id that was `in=`\'s only value domain cannot exist here and every value was a dead end. The reason for withdrawing rather than leaving it is the RESERVATION: `in=`\'s future domain in this genre is a STATE id — UML 2.5.1 §14.2.3.4 composite states would arrive as nesting on `state`, through this exact key — so a live key with a group-id domain taught the WRONG model using the very spelling reserved for the right one. Delete the key: a category shared by several states is a `class=` meaning. `in=` is expected back with a state-id domain when composite-state nesting is earned (`MEMBERSHIP-KEY-ACCEPTANCE`).'
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
const WITHDRAWN_OPT_FROM_GENRE=(key,genre)=>
|
|
1103
|
+
key+'= is not allowed in genre '+genre+' — it was WITHDRAWN from this genre, not misspelled: '+
|
|
1104
|
+
GENRE_WITHDRAWN_OPT[genre][key]+
|
|
1105
|
+
' An option key is per genre for the same reason a keyword is (core §3, `GENRE-VOCABULARY-OBLIGATION`): the key is accepted '+
|
|
1106
|
+
'by the directive AND by the genre, and this genre\'s acceptance was withdrawn without touching any other\'s.'+
|
|
1107
|
+
WITHDREW_OPT_AT;
|
|
775
1108
|
const GENRE_KW={
|
|
776
|
-
block:new Set(SCENE_HOST_KW),
|
|
777
|
-
topology:new Set(SCENE_HOST_KW),
|
|
778
|
-
flowchart:new Set(SCENE_HOST_KW.concat(FLOWCHART_ROLE_KW)),
|
|
1109
|
+
block:new Set(SCENE_HOST_KW.concat(BLOCK_SUBJECT_KW, ['node','edge'])),
|
|
1110
|
+
topology:new Set(SCENE_HOST_KW.concat(TOPOLOGY_SUBJECT_KW, ['node','edge'])),
|
|
1111
|
+
flowchart:new Set(SCENE_HOST_KW.concat(FLOWCHART_SUBJECT_KW, ['node','flowline'], FLOWCHART_ROLE_KW)),
|
|
1112
|
+
// `STATECHART-GENRE-SCOPE`: `statechart` added no keyword of its own — it was the
|
|
1113
|
+
// scene host set and nothing else. `GENRE-NODE-SPELLING` gives it its two: the
|
|
1114
|
+
// scene host set with `state` and `transition` in the slots `node` and
|
|
1115
|
+
// `edge` occupy elsewhere. It still does NOT inherit `process`/`decision`/
|
|
1116
|
+
// `terminator`: those are flowchart's words (`GENRE-NAMESPACE` `GENRE-VOCABULARY-OBLIGATION`), and a `decision` in a
|
|
1117
|
+
// statechart is a category error, not a shorthand. The allowlist is what
|
|
1118
|
+
// makes that a line error with no extra code.
|
|
1119
|
+
// `SUBJECT-VOCABULARY-SCOPE`: its subject vocabulary is the empty array above, so
|
|
1120
|
+
// `state` + `transition` + core + layout + styling + region openers is now
|
|
1121
|
+
// the WHOLE of what a statechart document may write at top level.
|
|
1122
|
+
statechart:new Set(SCENE_HOST_KW.concat(STATECHART_SUBJECT_KW, ['state','transition'])),
|
|
779
1123
|
bitfield:new Set(GENRE_FREE_KW.concat(['class','bitfield'])),
|
|
780
1124
|
// chart is experimental and attaches to a table id in the same document
|
|
781
1125
|
table:new Set(GENRE_FREE_KW.concat(['class','table','chart'])),
|
|
@@ -838,7 +1182,10 @@ function parseOne(text){
|
|
|
838
1182
|
// `EMPTY-LABEL-STATE`: `title` and a plane label start ABSENT (null), never as an empty
|
|
839
1183
|
// string — an author who writes `title ""` has made a distinction the model
|
|
840
1184
|
// must keep, and the implicit `base` plane wrote no label at all.
|
|
841
|
-
|
|
1185
|
+
// `DRAWN-ANNOTATION-FORM`: `note` sits beside `title` and starts ABSENT (null), on
|
|
1186
|
+
// `EMPTY-LABEL-STATE`'s rule for `title` itself — an author who writes `note=""` has made
|
|
1187
|
+
// a distinction the model must keep.
|
|
1188
|
+
const doc={title:null,note:null,nodes:[],groups:[],edges:[],planes:[{id:'base',label:null,z:0}],
|
|
842
1189
|
flow:'right',ranks:[],pins:{},blocks:[],trunks:[],thresholds:[],bands:[],
|
|
843
1190
|
classes:[],boundaries:[]};
|
|
844
1191
|
const nodeIds=new Set(), groupIds=new Set(), planeIds=new Set(['base']), classIds=new Set(),
|
|
@@ -878,8 +1225,13 @@ function parseOne(text){
|
|
|
878
1225
|
// operator into halves: -[x]- -[x]-> <-[x]- <-[x]->. Bracket content:
|
|
879
1226
|
// balanced brackets nest verbatim ([flags[3:0]] just works); ["..."] takes
|
|
880
1227
|
// the standard quoted-string escapes for unbalanced brackets / \n.
|
|
881
|
-
|
|
882
|
-
|
|
1228
|
+
// `GENRE-CONNECTOR-SPELLING`/`GENRE-NODE-SPELLING`: `kw` is the SURFACE spelling the author wrote —
|
|
1229
|
+
// `edge`, `flowline` or `transition`. One scanner, three words: every
|
|
1230
|
+
// message names the word on the line, and nothing downstream of here knows
|
|
1231
|
+
// the difference (the model records a connector, not a spelling).
|
|
1232
|
+
function parseEdgeLine(s,n,kw){
|
|
1233
|
+
kw=kw||'edge';
|
|
1234
|
+
let i=kw.length; // past the connector keyword
|
|
883
1235
|
const ws=()=>{ while(i<s.length&&/\s/.test(s[i])) i++; };
|
|
884
1236
|
// `LINK-OPERATOR-IN-IDS`: a hyphen is an id character only when it is NOT
|
|
885
1237
|
// followed by a second one, because `--` is the link operator. This is
|
|
@@ -927,7 +1279,7 @@ function parseOne(text){
|
|
|
927
1279
|
ws();
|
|
928
1280
|
if(s[i]==='"'){ err(n,ID_RULE); return; }
|
|
929
1281
|
const a=readId();
|
|
930
|
-
if(!a){ err(n, idHere()?ID_RULE:'
|
|
1282
|
+
if(!a){ err(n, idHere()?ID_RULE:kw+' needs <id> ->|<-|--|<-> <id>'); return; }
|
|
931
1283
|
if(idHere()){ err(n,ID_RULE); return; }
|
|
932
1284
|
ws(); let tail=null;
|
|
933
1285
|
if(s[i]==='['){ const r=readLbl(); if(r.error){ err(n,r.error); return; } tail=r.v; }
|
|
@@ -935,7 +1287,7 @@ function parseOne(text){
|
|
|
935
1287
|
let lh=null;
|
|
936
1288
|
if(s.startsWith('<-',i)){ lh='<-'; i+=2; }
|
|
937
1289
|
else if(s[i]==='-'){ lh='-'; i++; }
|
|
938
|
-
else { err(n,'
|
|
1290
|
+
else { err(n,kw+' needs an operator: -> <- -- <-> (a [mid] label splits it: -[x]->)'); return; }
|
|
939
1291
|
let mid=null, op=null;
|
|
940
1292
|
if(s[i]==='['){
|
|
941
1293
|
const r=readLbl(); if(r.error){ err(n,r.error); return; } mid=r.v;
|
|
@@ -947,14 +1299,14 @@ function parseOne(text){
|
|
|
947
1299
|
} else {
|
|
948
1300
|
if(s[i]==='-'){ op='--'; i++; }
|
|
949
1301
|
else if(s[i]==='>'){ op='->'; i++; }
|
|
950
|
-
else { err(n,'
|
|
1302
|
+
else { err(n,kw+' needs an operator: -> <- -- <->'); return; }
|
|
951
1303
|
}
|
|
952
1304
|
ws(); let head=null;
|
|
953
1305
|
if(s[i]==='['){ const r=readLbl(); if(r.error){ err(n,r.error); return; } head=r.v; }
|
|
954
1306
|
ws();
|
|
955
1307
|
if(s[i]==='"'){ err(n,ID_RULE); return; }
|
|
956
1308
|
const b=readId();
|
|
957
|
-
if(!b){ err(n, idHere()?ID_RULE:'
|
|
1309
|
+
if(!b){ err(n, idHere()?ID_RULE:kw+' needs a target id after the operator'); return; }
|
|
958
1310
|
if(idHere()){ err(n,ID_RULE); return; }
|
|
959
1311
|
const tk2=tokenize(s.slice(i).trim());
|
|
960
1312
|
if(tk2.error){ err(n,tk2.error); return; }
|
|
@@ -968,10 +1320,10 @@ function parseOne(text){
|
|
|
968
1320
|
for(const rk in RETIRED_OPT_KEYS)
|
|
969
1321
|
if(o2[rk]!==undefined){ err(n,RETIRED_OPT_KEYS[rk]); return; }
|
|
970
1322
|
for(const k in o2)
|
|
971
|
-
if(!DIRECTIVE_OPTS.
|
|
1323
|
+
if(!DIRECTIVE_OPTS[kw].includes(k)){ err(n,kw+' does not take '+k+'='); return; }
|
|
972
1324
|
for(const k of ['label','taillabel','headlabel'])
|
|
973
|
-
if(o2[k]!==undefined){ err(n,k+'= is retired — write the label inline:
|
|
974
|
-
if(o2.fill!==undefined){ err(n,FILL_NO_INTERIOR(
|
|
1325
|
+
if(o2[k]!==undefined){ err(n,k+'= is retired — write the label inline: '+kw+' A [tail] -[mid]-> [head] B (MIGRATIONS 0.1)'); return; }
|
|
1326
|
+
if(o2.fill!==undefined){ err(n,FILL_NO_INTERIOR(kw)); return; }
|
|
975
1327
|
for(const k of ['fill','stroke'])
|
|
976
1328
|
if(o2[k]!==undefined && !isColor(o2[k])){ err(n,'unknown color "'+o2[k]+'" (#hex or CSS color name)'); return; }
|
|
977
1329
|
// `RULE-POSITION-ENUMERATION`: `edge` was the ONE id position in the language that
|
|
@@ -986,6 +1338,16 @@ function parseOne(text){
|
|
|
986
1338
|
const e=idErr(o2.plane, optHasQ(oT2,'plane'), null);
|
|
987
1339
|
if(e){ err(n,e); return; }
|
|
988
1340
|
}
|
|
1341
|
+
// `DRAWN-ANNOTATION-FORM`: the connector's copy of the `note=` version gate and
|
|
1342
|
+
// of the `QUOTING-RULES` quoted-prose rule. A connector is the acceptor the ruling
|
|
1343
|
+
// called decisive — an edge has no id, so an attribute is the ONLY form
|
|
1344
|
+
// that can reach it — and this scanner has to carry every language-wide
|
|
1345
|
+
// check itself or the one construct that most needs the key is the one
|
|
1346
|
+
// construct where the key is unchecked.
|
|
1347
|
+
if(o2.note!==undefined){
|
|
1348
|
+
if(belowOptVersion('note',doc.version)){ err(n,NOTE_VERSION(doc.version)); return; }
|
|
1349
|
+
if(!optQ(oT2,'note')){ err(n,'note= must be quoted: note="'+o2.note+'" — '+Q_WHY); return; }
|
|
1350
|
+
}
|
|
989
1351
|
// `RULE-POSITION-ENUMERATION`: and the enum half of RULE 2.4, for the one enum key `edge` takes.
|
|
990
1352
|
// Checked before the value, exactly as `badOpts` does it.
|
|
991
1353
|
if(o2.style!==undefined && optHasQ(oT2,'style')){ err(n,ENUM_BARE('style='+o2.style)); return; }
|
|
@@ -1000,7 +1362,7 @@ function parseOne(text){
|
|
|
1000
1362
|
// and `fill=` name the same channel (`stroke=` wins when both are
|
|
1001
1363
|
// written); `text=` colours the [tail]/[mid]/[head] labels.
|
|
1002
1364
|
doc.edges.push({a,b,op,tail,mid,head,style:o2.style,cls:ecls,
|
|
1003
|
-
stroke:o2.stroke,
|
|
1365
|
+
stroke:o2.stroke,note:o2.note,
|
|
1004
1366
|
plane:o2.plane||'base',line:n});
|
|
1005
1367
|
}
|
|
1006
1368
|
|
|
@@ -1073,17 +1435,41 @@ function parseOne(text){
|
|
|
1073
1435
|
if(findReservedSemi(raw)>=0){ err(n,RESERVED_SEMI); continue; }
|
|
1074
1436
|
// edge lines carry inline [labels] with free text — dedicated scanner,
|
|
1075
1437
|
// not the generic tokenizer
|
|
1076
|
-
|
|
1438
|
+
// `GENRE-CONNECTOR-SPELLING`/`GENRE-NODE-SPELLING`: all THREE connector spellings are scanned here.
|
|
1439
|
+
// The wrong one for the genre must reach the named diagnostic below, so
|
|
1440
|
+
// the dispatch cannot be narrowed to the genre's own word — a `flowline`
|
|
1441
|
+
// under `block` would then fall through to `unrecognized line`, which is
|
|
1442
|
+
// exactly the answer these rulings owe an author better than.
|
|
1443
|
+
const mConn=/^(edge|flowline|transition)(\s|$)/.exec(raw.trim());
|
|
1444
|
+
if(mConn){
|
|
1445
|
+
const ckw=mConn[1];
|
|
1077
1446
|
if(firstContent){ firstContent=false; err(n,'first line must be "figdown 0.1 <genre>"'); }
|
|
1078
1447
|
cur=null;
|
|
1079
|
-
// `CONTENT-LAYOUT-ZONE-SPLIT`:
|
|
1448
|
+
// `CONTENT-LAYOUT-ZONE-SPLIT`: a connector is a semantic directive, and it is dispatched here —
|
|
1080
1449
|
// before the generic layout-zone gate below — so it needs its own copy
|
|
1081
1450
|
// of that gate, or it is the one semantic line that escapes the zone.
|
|
1082
|
-
if(sawLayout){ err(n,'"
|
|
1083
|
-
// `GENRE-KEYWORD-ALLOWLIST`:
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1451
|
+
if(sawLayout){ err(n,'"'+ckw+'" is a semantic directive — it must appear before the layout zone (`CONTENT-LAYOUT-ZONE-SPLIT`)'); continue; }
|
|
1452
|
+
// `GENRE-KEYWORD-ALLOWLIST`: a connector is scene vocabulary only — and in a scene genre it is
|
|
1453
|
+
// THAT genre's connector word (`GENRE-CONNECTOR-SPELLING`/`GENRE-NODE-SPELLING`), not any of the three.
|
|
1454
|
+
// `KEYWORD-RENAME-SCOPE`: the word this genre uses is read AT THE DECLARED VERSION, not
|
|
1455
|
+
// at the newest one. A genre with no connector at all (bitfield, table,
|
|
1456
|
+
// timing) still gets the allowlist message.
|
|
1457
|
+
if(sawHeader && doc.genre && GENRE_KW[doc.genre]){
|
|
1458
|
+
const want=connectorKwAt(doc.genre, doc.version);
|
|
1459
|
+
if(!want){ err(n,'"'+ckw+'" is not allowed in genre '+doc.genre); continue; }
|
|
1460
|
+
if(ckw!==want){
|
|
1461
|
+
const need=CONNECTOR_MIN_VERSION[ckw];
|
|
1462
|
+
// The author wrote a word this genre really does use — just not in
|
|
1463
|
+
// the version they declared. That is a different mistake from the
|
|
1464
|
+
// wrong domain's word, and it has a different one-step fix.
|
|
1465
|
+
if(need && doc.version && need>doc.version &&
|
|
1466
|
+
GENRE_CONNECTOR_KW[doc.genre]===ckw)
|
|
1467
|
+
err(n, WRONG_VERSION_WORD(ckw,want,doc.genre,need,doc.version));
|
|
1468
|
+
else
|
|
1469
|
+
err(n, WRONG_WORD(ckw,want,doc.genre));
|
|
1470
|
+
continue; }
|
|
1471
|
+
}
|
|
1472
|
+
parseEdgeLine(raw.trim(),n,ckw);
|
|
1087
1473
|
continue;
|
|
1088
1474
|
}
|
|
1089
1475
|
const tk=tokenize(raw.trim());
|
|
@@ -1102,6 +1488,19 @@ function parseOne(text){
|
|
|
1102
1488
|
// same-line repeated option key (last-wins was silent data loss)
|
|
1103
1489
|
if(dup){ err(n,'duplicate option "'+dup+'=" on one line'); bad=true; }
|
|
1104
1490
|
for(const u of unk){ err(n,'unknown option "'+u+'="'); bad=true; }
|
|
1491
|
+
// `MEMBERSHIP-KEY-ACCEPTANCE`: the PER-GENRE option-key withdrawal, checked here —
|
|
1492
|
+
// after `unknown option`, so a key the LANGUAGE does not have keeps its
|
|
1493
|
+
// own answer, and before every value check, so a withdrawn key is never
|
|
1494
|
+
// told what its value would have meant. `gwHit` suppresses the id-value
|
|
1495
|
+
// rule below for the same key: ONE token, ONE error, the convention
|
|
1496
|
+
// `enumQ` already follows. The line is abandoned by the caller
|
|
1497
|
+
// (`if(badOpts(kw)) continue;`), so no cascade reaches the resolver and
|
|
1498
|
+
// the author never sees the `unknown group "…"` this ruling removes.
|
|
1499
|
+
const gwOpt=(doc.genre&&GENRE_WITHDRAWN_OPT[doc.genre])||null;
|
|
1500
|
+
const gwHit=new Set();
|
|
1501
|
+
if(gwOpt) for(const o in opts)
|
|
1502
|
+
if(gwOpt[o]!==undefined && allowed.includes(o)){
|
|
1503
|
+
err(n,WITHDRAWN_OPT_FROM_GENRE(o,doc.genre)); gwHit.add(o); bad=true; }
|
|
1105
1504
|
// Retired spelling: `color=` → `fill=`. Fires only where
|
|
1106
1505
|
// the key was accepted; on a directive that never took it the existing
|
|
1107
1506
|
// `<directive> does not take color=` is still the right answer.
|
|
@@ -1111,6 +1510,19 @@ function parseOne(text){
|
|
|
1111
1510
|
// spelling left the language rather than moving between directives.
|
|
1112
1511
|
for(const rk in RETIRED_OPT_KEYS)
|
|
1113
1512
|
if(opts[rk]!==undefined){ err(n,RETIRED_OPT_KEYS[rk]); bad=true; }
|
|
1513
|
+
// `DRAWN-ANNOTATION-FORM`: the two `note=` refusals, in the order that gives
|
|
1514
|
+
// ONE error per line. `field` is checked first and unconditionally,
|
|
1515
|
+
// because it refuses the key at every version — telling a `figdown 0.2`
|
|
1516
|
+
// bitfield author to raise their header would send them to a version
|
|
1517
|
+
// that still refuses them. Every directive that does NOT list `note` in
|
|
1518
|
+
// its row falls through to the generic `<directive> does not take note=`
|
|
1519
|
+
// below, which is the right answer for `external`, `threshold`, `band`,
|
|
1520
|
+
// `bundle`, `plane`, `class` and `cell`: the key is in OPT_KEYS, so none
|
|
1521
|
+
// of them can report `unknown option` for a spelling the language has.
|
|
1522
|
+
if(opts.note!==undefined && allowed.includes('note')){
|
|
1523
|
+
if(k==='field'){ err(n,NOTE_ON_FIELD); bad=true; }
|
|
1524
|
+
else if(belowOptVersion('note',doc.version)){ err(n,NOTE_VERSION(doc.version)); bad=true; }
|
|
1525
|
+
}
|
|
1114
1526
|
// `RULE-POSITION-ENUMERATION`: RULE 2.4's enum half on the OPTION keys. One loop
|
|
1115
1527
|
// for every enum-valued key, the same device the id-valued keys below
|
|
1116
1528
|
// use — so a key that gains an enum grammar later is covered by
|
|
@@ -1159,7 +1571,11 @@ function parseOne(text){
|
|
|
1159
1571
|
// until then) and `present=` (`PRESENCE-CONDITION-EXPRESSION`). `present=""` is legal and is the
|
|
1160
1572
|
// "conditional, condition not stated" form — an EMPTY quoted value,
|
|
1161
1573
|
// not an unquoted one, so the same rule admits it.
|
|
1162
|
-
|
|
1574
|
+
// `DRAWN-ANNOTATION-FORM`: THREE since `note=` revived. It is prose in the
|
|
1575
|
+
// same sense, and it revives with the value shape it retired with —
|
|
1576
|
+
// which is RULE 4.9 obligation 2 satisfied in the parser rather than
|
|
1577
|
+
// only on paper.
|
|
1578
|
+
for(const sk of ['description','present','note'])
|
|
1163
1579
|
if(opts[sk]!==undefined && allowed.includes(sk) && !optQ(optT,sk)){
|
|
1164
1580
|
err(n,sk+'= must be quoted: '+sk+'="'+opts[sk]+'" — '+Q_WHY); bad=true; }
|
|
1165
1581
|
// `QUOTED-IDS`: `in=` and `plane=` are ID-VALUED options, so the
|
|
@@ -1167,7 +1583,7 @@ function parseOne(text){
|
|
|
1167
1583
|
// keeps its directive-specific message (`threshold needs in=…`); a written
|
|
1168
1584
|
// one that is quoted or not a legal id gets the ID RULE.
|
|
1169
1585
|
for(const k of ['in','plane'])
|
|
1170
|
-
if(opts[k]!==undefined && allowed.includes(k)){
|
|
1586
|
+
if(opts[k]!==undefined && allowed.includes(k) && !gwHit.has(k)){
|
|
1171
1587
|
const e=idErr(opts[k], optHasQ(optT,k), null);
|
|
1172
1588
|
if(e){ err(n,e); bad=true; }
|
|
1173
1589
|
}
|
|
@@ -1195,25 +1611,53 @@ function parseOne(text){
|
|
|
1195
1611
|
// line. So the quoting check runs first and suppresses the value
|
|
1196
1612
|
// check for that token, exactly as `badOpts` does for `shape=`.
|
|
1197
1613
|
const hq1=!!posq[1], hq2=!!posq[2];
|
|
1614
|
+
// `STATECHART-GENRE-SCOPE`: the language version is now a SET, not a constant, so every
|
|
1615
|
+
// message that echoes a corrected header echoes the version the
|
|
1616
|
+
// author actually declared — an author on `0.2` must not be shown a
|
|
1617
|
+
// `0.1` example. An unrecognised version falls back to `0.1` for the
|
|
1618
|
+
// purpose of these examples only; it has already errored on its own.
|
|
1619
|
+
const verOK=!hq1 && LANG_VERSIONS.includes(pos[1]);
|
|
1620
|
+
const ver=verOK?pos[1]:'0.1';
|
|
1198
1621
|
if(hq1) err(n,ENUM_BARE('figdown '+pos[1]+' <genre>'));
|
|
1199
|
-
else if(hq2) err(n,ENUM_BARE('figdown
|
|
1200
|
-
if(!hq1 && pos[1]
|
|
1201
|
-
const GENRES=['block','topology','flowchart','bitfield','table','timing'];
|
|
1622
|
+
else if(hq2) err(n,ENUM_BARE('figdown '+ver+' '+pos[2]));
|
|
1623
|
+
if(!hq1 && !LANG_VERSIONS.includes(pos[1])) err(n,'unsupported version "'+(pos[1]||'')+'" (expected '+LANG_VERSIONS.join(' or ')+')');
|
|
1202
1624
|
// 0.1: the genre token is REQUIRED. `bitfield`/`table`/`timing`
|
|
1203
1625
|
// documents declare their kind in their content, but `block`,
|
|
1204
1626
|
// `topology` and `flowchart` share the SAME vocabulary
|
|
1205
1627
|
// (node/edge/group) and differ only in default flow — so the header
|
|
1206
1628
|
// is the ONLY place such a document states which kind of figure it
|
|
1207
1629
|
// is, and omitting it destroys the distinction with no recoverable
|
|
1208
|
-
// fallback. The message lists the
|
|
1209
|
-
// agent fixes it in one step
|
|
1210
|
-
|
|
1630
|
+
// fallback. The message lists the legal values so an authoring
|
|
1631
|
+
// agent fixes it in one step — the values legal AT THE DECLARED
|
|
1632
|
+
// VERSION, since listing `statechart` to a `figdown 0.1` author would
|
|
1633
|
+
// name a genre that document may not use.
|
|
1634
|
+
const GENRES=GENRES_BY_VERSION[ver];
|
|
1635
|
+
const GLIST='('+GENRES.join('|')+')';
|
|
1636
|
+
if(pos[2]===undefined) err(n,'figdown header requires a genre '+GLIST);
|
|
1211
1637
|
else if(hq2){ /* the quoting error above is this token's one error */ }
|
|
1212
1638
|
else if(pos[2]==='wave') err(n,RETIRED_WAVE);
|
|
1213
|
-
else if(!GENRES.includes(pos[2]))
|
|
1639
|
+
else if(!GENRES.includes(pos[2])){
|
|
1640
|
+
// A genre that exists but only LATER is its own diagnostic, not
|
|
1641
|
+
// `unknown genre`. core §13.7 forbids guessing a version, and the
|
|
1642
|
+
// author's one-step fix is to raise the header — which the message
|
|
1643
|
+
// SPELLS OUT, because "unknown genre statechart" would send them
|
|
1644
|
+
// looking for a typo that is not there. The trailing `— write: …`
|
|
1645
|
+
// is the same shape WRONG_VERSION_WORD ends with: name the fix, do
|
|
1646
|
+
// not leave the author to derive it.
|
|
1647
|
+
const later=Object.keys(GENRES_BY_VERSION).sort()
|
|
1648
|
+
.find(v=>v>ver && GENRES_BY_VERSION[v].includes(pos[2]));
|
|
1649
|
+
if(later) err(n,'genre "'+pos[2]+'" requires figdown '+later+' (this document declares '+ver+') — write: figdown '+later+' '+pos[2]);
|
|
1650
|
+
else err(n,'unknown genre "'+pos[2]+'" '+GLIST);
|
|
1651
|
+
}
|
|
1214
1652
|
else{ doc.genre=pos[2];
|
|
1653
|
+
// The DECLARED language version is part of the model (core §12.5
|
|
1654
|
+
// `header.version`): a reader must be able to tell what contract
|
|
1655
|
+
// the author wrote against without re-reading the source.
|
|
1656
|
+
doc.version=ver;
|
|
1215
1657
|
// genre defaults (`GENRE-NAMESPACE`/`DEFAULT-VALUE-SELECTION`): flowchart figures flow down —
|
|
1216
|
-
// the census-dominant direction; an explicit flow
|
|
1658
|
+
// the census-dominant direction; an explicit `flow` directive overrides.
|
|
1659
|
+
// `statechart` takes the SCENE default (`right`) and adds no rule
|
|
1660
|
+
// of its own — `STATECHART-GENRE-SCOPE` lands a dispatch point, not a layout.
|
|
1217
1661
|
if(pos[2]==='flowchart') doc.flow='down'; }
|
|
1218
1662
|
// §1: a directive line carrying positional arguments its grammar does
|
|
1219
1663
|
// not accept MUST be rejected — the header is a directive like any other
|
|
@@ -1248,7 +1692,7 @@ function parseOne(text){
|
|
|
1248
1692
|
// noun in a topology figure (`SHAPE-ENUM-VOCABULARY`: no domain nouns in the presentation
|
|
1249
1693
|
// vocabulary) while the directive means geometric waypoints;
|
|
1250
1694
|
// - `render` was a verb naming a zone that admits only geometry
|
|
1251
|
-
// (`pin` — and, until
|
|
1695
|
+
// (`pin` — and, until 0.1, `path` and `routing`), and it
|
|
1252
1696
|
// collided with the renderer
|
|
1253
1697
|
// and the render options of §7. `layout` is the cross-tool word for
|
|
1254
1698
|
// this half of a diagram language, and the zone it opens carried the
|
|
@@ -1257,19 +1701,25 @@ function parseOne(text){
|
|
|
1257
1701
|
// the first entries in it that name NO replacement. `route`'s own message
|
|
1258
1702
|
// has to change with them: it pointed at `path`, which no longer exists,
|
|
1259
1703
|
// so it now states the whole chain and ends where the others end.
|
|
1260
|
-
if(kw==='line'){ err(n,'line has been renamed: use threshold (a labelled reference value drawn across the target'+"'"+'s box; "line" now only names a source line number, and the 0.1 replacement `guide` was itself retired) (MIGRATIONS)'); continue; }
|
|
1704
|
+
if(kw==='line'){ err(n,'line has been renamed: use threshold (a labelled reference value drawn across the target'+"'"+'s box; "line" now only names a source line number, and the 0.1 replacement `guide` was itself retired) (MIGRATIONS 0.1)'); continue; }
|
|
1261
1705
|
if(kw==='fill'){ err(n,'fill has been renamed: use band (a range band; the KEYWORD is retired — fill= is the presentation option key)'); continue; }
|
|
1262
1706
|
if(kw==='route'){ err(n,'route has been WITHDRAWN: it was renamed path, and path was withdrawn from the language (`EDGE-GEOMETRY-CONSTRUCTS`). There is no replacement spelling. Delete the line: the edge draws under auto layout.'+WITHDRAWN_WHERE); continue; }
|
|
1263
1707
|
if(kw==='path'){ err(n,RETIRED_PATH); continue; }
|
|
1264
1708
|
if(kw==='routing'){ err(n,RETIRED_ROUTING); continue; }
|
|
1265
|
-
if(kw==='render'){ err(n,'render has been renamed: use layout (the zone takes only pin — geometry, not presentation) (MIGRATIONS)'); continue; }
|
|
1709
|
+
if(kw==='render'){ err(n,'render has been renamed: use layout (the zone takes only pin — geometry, not presentation) (MIGRATIONS 0.1)'); continue; }
|
|
1266
1710
|
if(kw==='wrap'){ err(n,RETIRED_WRAP); continue; }
|
|
1267
1711
|
if(kw==='boundary'){ err(n,RETIRED_BOUNDARY); continue; }
|
|
1268
1712
|
if(kw==='layer'){ err(n,RETIRED_LAYER); continue; }
|
|
1713
|
+
// `PAINT-ORDER-CONSTRUCT`: `plane` joins this block. RULE 6.2 placement — the
|
|
1714
|
+
// spelling left the LANGUAGE, not one genre, so it fires wherever it
|
|
1715
|
+
// appears at line start, in every genre, AHEAD of the `GENRE-KEYWORD-ALLOWLIST` allowlist. A
|
|
1716
|
+
// `plane` line under `bitfield` gets the withdrawal, not "not allowed in
|
|
1717
|
+
// genre bitfield", which would be true and useless.
|
|
1718
|
+
if(kw==='plane'){ err(n,RETIRED_PLANE); continue; }
|
|
1269
1719
|
if(kw==='guide'){ err(n,RETIRED_GUIDE); continue; }
|
|
1270
1720
|
if(kw==='wave'){ err(n,RETIRED_WAVE); continue; }
|
|
1271
1721
|
if(kw==='size'){ err(n,RETIRED_SIZE); continue; }
|
|
1272
|
-
if(kw==='plot'){ err(n,'plot has been renamed: use chart (plot reads as an imperative — the reason render was retired — while every other block opener is a noun; ECharts, Chart.js and Mermaid all name the object a chart) (MIGRATIONS)'); continue; }
|
|
1722
|
+
if(kw==='plot'){ err(n,'plot has been renamed: use chart (plot reads as an imperative — the reason render was retired — while every other block opener is a noun; ECharts, Chart.js and Mermaid all name the object a chart) (MIGRATIONS 0.1)'); continue; }
|
|
1273
1723
|
|
|
1274
1724
|
// typed-block children
|
|
1275
1725
|
if(cur && ['field','break','cell','width','signal','gap'].includes(kw)){
|
|
@@ -1280,7 +1730,7 @@ function parseOne(text){
|
|
|
1280
1730
|
// per-field options. Classic form: field <name> <width> [options].
|
|
1281
1731
|
// Classic form: field <name> <width-in-bits|*> [fill=] [description=]
|
|
1282
1732
|
// [present=]
|
|
1283
|
-
// Conditional presence was a POSITIONAL FLAG until
|
|
1733
|
+
// Conditional presence was a POSITIONAL FLAG until 0.1:
|
|
1284
1734
|
// `optional` (…0.1), `conditional` (0.1…0.1),
|
|
1285
1735
|
// `optional` again (`PRESENCE-FLAG-SPELLING`). `PRESENCE-CONDITION-EXPRESSION` replaces the flag with
|
|
1286
1736
|
// `present=`, an option key whose value is the presence CONDITION as
|
|
@@ -1347,7 +1797,7 @@ function parseOne(text){
|
|
|
1347
1797
|
if(opts.index!==undefined){
|
|
1348
1798
|
err(n,'index= is not available on the compact field form — the range would apply LINE-wide, saying that every item repeats over the same indices. Write the repeated element in the classic form on its own line: field "<name>" <width> index=0..7'); continue; }
|
|
1349
1799
|
if(items0.length>1){
|
|
1350
|
-
err(n,'field: the item list is ONE comma-delimited token — unexpected argument "'+items0[1]+'" (write field a:1,b:2 with no space after the comma; quote a name that contains whitespace: "Long Name":16) (MIGRATIONS)'); continue; }
|
|
1800
|
+
err(n,'field: the item list is ONE comma-delimited token — unexpected argument "'+items0[1]+'" (write field a:1,b:2 with no space after the comma; quote a name that contains whitespace: "Long Name":16) (MIGRATIONS 0.1)'); continue; }
|
|
1351
1801
|
let bad=null; const parsed=[];
|
|
1352
1802
|
for(const el of splitList(posT[1],0)){
|
|
1353
1803
|
const it=el.v; if(!it) continue;
|
|
@@ -1367,7 +1817,7 @@ function parseOne(text){
|
|
|
1367
1817
|
// the overflow.
|
|
1368
1818
|
if(m[2]!=='*' && +m[2]>cur.word){
|
|
1369
1819
|
// The suggestion spells the CLASSIC form, and the classic name is
|
|
1370
|
-
// QUOTED (`QUOTING-RULES`). Until
|
|
1820
|
+
// QUOTED (`QUOTING-RULES`). Until 0.1 this string said
|
|
1371
1821
|
// `write "field P 64"` — a second line error, so a user who
|
|
1372
1822
|
// followed the diagnostic was told off twice.
|
|
1373
1823
|
bad='"'+nm+':'+m[2]+'" is wider than word='+cur.word+' — a compact item must fit one row; write it in the classic form to span rows: field "'+nm+'" '+m[2]; break; }
|
|
@@ -1393,7 +1843,7 @@ function parseOne(text){
|
|
|
1393
1843
|
// `break` ends the row after the fields declared since the block
|
|
1394
1844
|
// opened (or since the previous break). With none there is nothing to
|
|
1395
1845
|
// break — genre doc: "break with no preceding field in the current row".
|
|
1396
|
-
// Spelled `wrap` until
|
|
1846
|
+
// Spelled `wrap` until 0.1 (`ROW-BREAK-NAMING`): in CSS/typography `wrap` is
|
|
1397
1847
|
// AUTOMATIC reflow — a mode — while this is an EXPLICIT break, an
|
|
1398
1848
|
// event; CSS Fragmentation calls exactly this "a forced break …
|
|
1399
1849
|
// explicitly indicated by the … author" and HTML spells it `br`.
|
|
@@ -1412,7 +1862,7 @@ function parseOne(text){
|
|
|
1412
1862
|
// `POSITIONAL-LIST-SPELLING`: comma form only; the space form is retired.
|
|
1413
1863
|
const wtoks=pos.slice(1);
|
|
1414
1864
|
if(wtoks.length>1){
|
|
1415
|
-
err(n,'width takes ONE comma-delimited token: write width '+joinListForm(wtoks)+' — the space form is retired (MIGRATIONS)'); continue; }
|
|
1865
|
+
err(n,'width takes ONE comma-delimited token: write width '+joinListForm(wtoks)+' — the space form is retired (MIGRATIONS 0.1)'); continue; }
|
|
1416
1866
|
const vals=wtoks.length?splitList(posT[1],0).map(e=>e.v):[];
|
|
1417
1867
|
if(!vals.length){ err(n,'width needs one value per column (auto | <px> | <n>%)'); continue; }
|
|
1418
1868
|
let badw=null;
|
|
@@ -1441,7 +1891,7 @@ function parseOne(text){
|
|
|
1441
1891
|
// stays bare, exactly as `threshold offset=50%` does.
|
|
1442
1892
|
const cadr=pos[1]||'';
|
|
1443
1893
|
if(/^h?\d+,\d+$/.test(cadr)){
|
|
1444
|
-
err(n,'cell address is now a paren point: cell ('+cadr+') — a bare comma pair is a list of two numbers, not an address (MIGRATIONS)'); continue; }
|
|
1894
|
+
err(n,'cell address is now a paren point: cell ('+cadr+') — a bare comma pair is a list of two numbers, not an address (MIGRATIONS 0.1)'); continue; }
|
|
1445
1895
|
const rc=/^\((h?)(\d+),(\d+)\)$/.exec(cadr)||/^(h?)(\d+)$/.exec(cadr);
|
|
1446
1896
|
// `RULE-POSITION-ENUMERATION`: `highlight` is a bare keyword FLAG
|
|
1447
1897
|
// (vocabulary-sources.tsv `cell.highlight`), so RULE 2.4 governs it
|
|
@@ -1492,7 +1942,7 @@ function parseOne(text){
|
|
|
1492
1942
|
// / `TYPED-BLOCK-SILENT-FALLBACK`: data= is ABSENCE vs presence. An empty value, empty
|
|
1493
1943
|
// members (a,b), or a count that does not match the lane's `=`
|
|
1494
1944
|
// cells are all line errors — never silent drop or shift.
|
|
1495
|
-
// Spelled `labels=` until
|
|
1945
|
+
// Spelled `labels=` until 0.1 (`SIGNAL-DATA-KEY-SPELLING`): WaveDrom's own key is
|
|
1496
1946
|
// `data`, "an array of signal labels" naming every value cell, and
|
|
1497
1947
|
// after the `2`-`9` retirement (`TIMING-LANE-ALPHABET`) the two scopes coincide exactly.
|
|
1498
1948
|
let labels;
|
|
@@ -1536,7 +1986,21 @@ function parseOne(text){
|
|
|
1536
1986
|
// must be in the header genre allowlist. Child keywords still use the
|
|
1537
1987
|
// "needs a bitfield/table/timing above" path when they appear with no cur.
|
|
1538
1988
|
if(sawHeader && doc.genre && GENRE_KW[doc.genre] && !CHILD_KW.has(kw) && !GENRE_KW[doc.genre].has(kw)){
|
|
1539
|
-
|
|
1989
|
+
// `GENRE-NODE-SPELLING`: a word this genre SPELLS DIFFERENTLY is not an
|
|
1990
|
+
// unknown word, and "not allowed in genre statechart" would send an
|
|
1991
|
+
// author looking for a construct they cannot have instead of the one
|
|
1992
|
+
// they already wrote. The named diagnostic says which word and why.
|
|
1993
|
+
// (`edge`/`flowline`/`transition` never reach here — they are
|
|
1994
|
+
// dispatched by their own scanner above.)
|
|
1995
|
+
if(NODE_SPELLINGS.has(kw) && GENRE_NODE_KW[doc.genre])
|
|
1996
|
+
err(n, WRONG_WORD(kw, GENRE_NODE_KW[doc.genre], doc.genre));
|
|
1997
|
+
// `SCENE-KEYWORD-MEMBERSHIP`: same argument one step further. A word this genre
|
|
1998
|
+
// WITHDREW is not an unknown word either, and the author holding it
|
|
1999
|
+
// needs the ground, not a spellcheck.
|
|
2000
|
+
else if(GENRE_WITHDRAWN[doc.genre] && GENRE_WITHDRAWN[doc.genre][kw])
|
|
2001
|
+
err(n, WITHDRAWN_FROM_GENRE(kw, doc.genre));
|
|
2002
|
+
else
|
|
2003
|
+
err(n,'"'+kw+'" is not allowed in genre '+doc.genre);
|
|
1540
2004
|
continue;
|
|
1541
2005
|
}
|
|
1542
2006
|
if(badOpts(kw)) continue;
|
|
@@ -1561,10 +2025,23 @@ function parseOne(text){
|
|
|
1561
2025
|
// different values for the same visible text. One form, one
|
|
1562
2026
|
// meaning: the token is a normal quoted string and the generic
|
|
1563
2027
|
// tokenizer above has already resolved its escapes.
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
2028
|
+
// `DRAWN-ANNOTATION-FORM`: read the POSITIONALS, not the raw token stream.
|
|
2029
|
+
// `title` took no options until this release, so `tk.toks[1]` and
|
|
2030
|
+
// `tk.toks.length>2` were the same thing as `pos[1]` and
|
|
2031
|
+
// `pos.length>2`. They stop being the same thing the moment the line
|
|
2032
|
+
// may carry `note=`, and testing the raw stream would report the
|
|
2033
|
+
// annotation as a surplus positional. This is `OPTION-POSITION-PARSING`'s lesson (`bundle`
|
|
2034
|
+
// and `threshold` read `posq` for exactly this reason) applied to the
|
|
2035
|
+
// one directive that had never needed it.
|
|
2036
|
+
const t0v=pos[1], t0q=posq[1];
|
|
2037
|
+
if(t0v===undefined||!t0q){ err(n,'title needs a quoted string: title "<text>" (MIGRATIONS 0.1)'); break; }
|
|
2038
|
+
if(pos.length>2){ err(n,'unexpected argument "'+pos[2]+'"'); break; }
|
|
2039
|
+
doc.title=t0v; sawTitle=true;
|
|
2040
|
+
// The figure-level note lives on the document, not on an element —
|
|
2041
|
+
// there is no element for it to live on, which is the whole reason
|
|
2042
|
+
// `title` is an acceptor.
|
|
2043
|
+
if(opts.note!==undefined) doc.note=opts.note;
|
|
2044
|
+
break;
|
|
1568
2045
|
}
|
|
1569
2046
|
case 'class': {
|
|
1570
2047
|
// semantic class (`CATEGORICAL-MEANING-MAPPING`): meaning + presentation defaults declared
|
|
@@ -1587,30 +2064,11 @@ function parseOne(text){
|
|
|
1587
2064
|
if(pos.length>3){ err(n,'unexpected argument "'+pos[3]+'"'); break; }
|
|
1588
2065
|
classIds.add(id);
|
|
1589
2066
|
// `plane=` on a class is the members' default plane (an element's own
|
|
1590
|
-
// plane
|
|
2067
|
+
// `PAINT-ORDER-CONSTRUCT`: `plane=` is withdrawn, so a class carries the
|
|
2068
|
+
// FOUR §5 attributes it can still set. The paint-order attribute is
|
|
2069
|
+
// gone from the language, not merely off this directive.
|
|
1591
2070
|
doc.classes.push({id,label:pos[2],fill:opts.fill,stroke:opts.stroke,
|
|
1592
|
-
style:opts.style,
|
|
1593
|
-
break;
|
|
1594
|
-
}
|
|
1595
|
-
case 'plane': {
|
|
1596
|
-
const id=pos[1];
|
|
1597
|
-
{ const e=idErr(id,posq[1],'plane needs an id'); if(e){ err(n,e); break; } }
|
|
1598
|
-
if(planeIds.has(id)){ err(n,'duplicate plane id "'+id+'"'); break; }
|
|
1599
|
-
if(pos[2]!==undefined&&!posq[2]){ err(n,'plane label must be quoted: plane '+id+' "'+pos[2]+'" — '+Q_WHY); break; }
|
|
1600
|
-
if(pos.length>3){ err(n,'unexpected argument "'+pos[3]+'"'); break; }
|
|
1601
|
-
// 0.1: `z=` -> `z-index=` (CSS's own spelling for the
|
|
1602
|
-
// stacking concept, taken in full per RULE 4.2). The retired `z=`
|
|
1603
|
-
// is caught language-wide in RETIRED_OPT_KEYS before this runs.
|
|
1604
|
-
let z=doc.planes.length;
|
|
1605
|
-
const zi=opts['z-index'];
|
|
1606
|
-
if(zi!==undefined){
|
|
1607
|
-
if(!/^-?\d+$/.test(zi)){ err(n,'z-index must be a number'); break; }
|
|
1608
|
-
z=parseInt(zi,10);
|
|
1609
|
-
}
|
|
1610
|
-
planeIds.add(id);
|
|
1611
|
-
// `EMPTY-LABEL-STATE`: absent is absent, `""` is a written value — same
|
|
1612
|
-
// non-collapsing form as node/group/bundle and the typed blocks.
|
|
1613
|
-
doc.planes.push({id,label:pos[2]!==undefined?pos[2]:null,z});
|
|
2071
|
+
style:opts.style,line:n});
|
|
1614
2072
|
break;
|
|
1615
2073
|
}
|
|
1616
2074
|
// `FLOWCHART-ROLE-KEYWORDS`: `process` / `decision` / `terminator` DESUGAR to
|
|
@@ -1624,9 +2082,15 @@ function parseOne(text){
|
|
|
1624
2082
|
// being wrong is harmless, and a flowchart node may be a datastore, an
|
|
1625
2083
|
// annotation or a state, so `role:"process"` by default would let the
|
|
1626
2084
|
// model assert a falsehood the figure cannot be inspected to catch.
|
|
2085
|
+
// `GENRE-NODE-SPELLING`: `state` joins the same case. It is `node` renamed
|
|
2086
|
+
// for one genre, not a role — a statechart node has exactly one kind,
|
|
2087
|
+
// so there is no role to record and `role` stays null, exactly as a
|
|
2088
|
+
// bare `node` does. The DRAWING is unchanged too (`shape=box` default),
|
|
2089
|
+
// which is what let the five corpus figures migrate byte-identically.
|
|
1627
2090
|
case 'process': case 'decision': case 'terminator':
|
|
2091
|
+
case 'state':
|
|
1628
2092
|
case 'node': {
|
|
1629
|
-
const role=kw==='node'?null:kw;
|
|
2093
|
+
const role=(kw==='node'||kw==='state')?null:kw;
|
|
1630
2094
|
const id=pos[1];
|
|
1631
2095
|
{ const e=idErr(id,posq[1],kw+' needs an id'); if(e){ err(n,e); break; } }
|
|
1632
2096
|
if(dupId(id)){ err(n,'duplicate id "'+id+'"'); break; }
|
|
@@ -1647,6 +2111,7 @@ function parseOne(text){
|
|
|
1647
2111
|
// Display falls back to the id in render(), so the figure is unchanged.
|
|
1648
2112
|
doc.nodes.push({id,label:pos[2]!==undefined?pos[2]:null,shape,role,fill:opts.fill,stroke:opts.stroke,
|
|
1649
2113
|
style:opts.style,cls:parseClassList(opts['class'],optList(optT,'class')).ids,
|
|
2114
|
+
note:opts.note,
|
|
1650
2115
|
group:opts['in']||null,plane:opts.plane||'base',line:n});
|
|
1651
2116
|
break;
|
|
1652
2117
|
}
|
|
@@ -1666,6 +2131,7 @@ function parseOne(text){
|
|
|
1666
2131
|
}
|
|
1667
2132
|
doc.groups.push({id,label:pos[2]!==undefined?pos[2]:null,fill:opts.fill,stroke:opts.stroke,
|
|
1668
2133
|
style:opts.style,gap:ggap,cls:parseClassList(opts['class'],optList(optT,'class')).ids,
|
|
2134
|
+
note:opts.note,
|
|
1669
2135
|
plane:opts.plane||null,line:n});
|
|
1670
2136
|
break;
|
|
1671
2137
|
}
|
|
@@ -1677,7 +2143,7 @@ function parseOne(text){
|
|
|
1677
2143
|
// Shares the node/group/block id namespace. Of the §5 attributes it
|
|
1678
2144
|
// can carry only the two that need no drawn shape: `text=` (the label
|
|
1679
2145
|
// colour) and `plane=` (organizational, exactly as on a node).
|
|
1680
|
-
// Spelled `boundary` until
|
|
2146
|
+
// Spelled `boundary` until 0.1 (`EXTERNAL-ENDPOINT-NAMING`): three standards claim that
|
|
1681
2147
|
// word for the OPPOSITE meaning (UML ECB «boundary» is an internal
|
|
1682
2148
|
// interface object, C4 System_Boundary is a dashed grouping container,
|
|
1683
2149
|
// BPMN's is an event), and this spec's own prose had already stopped
|
|
@@ -1695,7 +2161,7 @@ function parseOne(text){
|
|
|
1695
2161
|
break;
|
|
1696
2162
|
}
|
|
1697
2163
|
case 'flow': {
|
|
1698
|
-
if(sawFlow){ err(n,'duplicate flow
|
|
2164
|
+
if(sawFlow){ err(n,'duplicate flow directive'); break; }
|
|
1699
2165
|
// `RULE-POSITION-ENUMERATION`: `flow.direction` is an enum position — bare.
|
|
1700
2166
|
if(posq[1]){ err(n,ENUM_BARE('flow '+pos[1])); break; }
|
|
1701
2167
|
if(!['right','down','left','up'].includes(pos[1])){ err(n,'flow needs right|down|left|up'); break; }
|
|
@@ -1728,7 +2194,7 @@ function parseOne(text){
|
|
|
1728
2194
|
// could not even detect a half-converted line.
|
|
1729
2195
|
const rtoks=pos.slice(1), rT=posT.slice(1);
|
|
1730
2196
|
if(rtoks.length>1){
|
|
1731
|
-
err(n,'rank takes ONE comma-delimited token: write rank '+joinListForm(rtoks)+' — the space form is retired (MIGRATIONS)'); break; }
|
|
2197
|
+
err(n,'rank takes ONE comma-delimited token: write rank '+joinListForm(rtoks)+' — the space form is retired (MIGRATIONS 0.1)'); break; }
|
|
1732
2198
|
const rels=rtoks.length?splitList(rT[0],0):[];
|
|
1733
2199
|
let badr=null;
|
|
1734
2200
|
for(const e of rels){
|
|
@@ -1768,7 +2234,7 @@ function parseOne(text){
|
|
|
1768
2234
|
// is now detectable — a second positional token after the label is
|
|
1769
2235
|
// the half-converted line the old tolerance could not report.
|
|
1770
2236
|
if(restT.length>1){
|
|
1771
|
-
err(n,'bundle members take ONE comma-delimited token: write bundle '+id+(tlabel===null?'':' "'+tlabel+'"')+' '+joinListForm(restT.map(t=>t.v))+' — the space form is retired (MIGRATIONS)'); break; }
|
|
2237
|
+
err(n,'bundle members take ONE comma-delimited token: write bundle '+id+(tlabel===null?'':' "'+tlabel+'"')+' '+joinListForm(restT.map(t=>t.v))+' — the space form is retired (MIGRATIONS 0.1)'); break; }
|
|
1772
2238
|
const pairs=[]; let badp=null;
|
|
1773
2239
|
outerB:
|
|
1774
2240
|
for(const t of restT){
|
|
@@ -1818,7 +2284,7 @@ function parseOne(text){
|
|
|
1818
2284
|
// percentage" `offset` (on <stop>), which is the same source the
|
|
1819
2285
|
// paint keys come from, so nothing is invented.
|
|
1820
2286
|
if(opts.at!==undefined){
|
|
1821
|
-
err(n,'threshold at= has been renamed: use offset=<0..100>% (at= is the pin POINT in canvas px; SVG spells a position along an extent "offset") (MIGRATIONS)'); break; }
|
|
2287
|
+
err(n,'threshold at= has been renamed: use offset=<0..100>% (at= is the pin POINT in canvas px; SVG spells a position along an extent "offset") (MIGRATIONS 0.1)'); break; }
|
|
1822
2288
|
const m=/^(\d+(?:\.\d+)?)%$/.exec(opts.offset||''); // % is mandatory (`BARE-FRACTION-VALUES`)
|
|
1823
2289
|
if(!m||+m[1]<0||+m[1]>100){ err(n,'threshold needs offset=<0..100>% (with the % sign)'); break; }
|
|
1824
2290
|
// §5: `stroke=` is the marker colour, `color=` the label colour,
|
|
@@ -1832,7 +2298,7 @@ function parseOne(text){
|
|
|
1832
2298
|
case 'chart': {
|
|
1833
2299
|
// chart family: chart <table-id> [type=bar3d]
|
|
1834
2300
|
// rows -> X, columns -> Y, numeric cells -> Z (the table IS the data)
|
|
1835
|
-
// Spelled `plot` with `kind=bars3d` until
|
|
2301
|
+
// Spelled `plot` with `kind=bars3d` until 0.1 (`CHART-BLOCK-NAMING`).
|
|
1836
2302
|
// 0.1 (`CHART-LEVEL-KEY`): `level=` is DELETED. Zero uses corpus-wide, zero
|
|
1837
2303
|
// 3-D bar charts, zero requests; one in-repo example and two fixtures.
|
|
1838
2304
|
// It was the only construct whose caption the ENGINE wrote rather than
|
|
@@ -1869,11 +2335,11 @@ function parseOne(text){
|
|
|
1869
2335
|
// reads the same way. `OPTION-POSITION-PARSING` quotedness is `pos`-aligned, so an option
|
|
1870
2336
|
// may still precede it.
|
|
1871
2337
|
const flabel=posq[1]?pos[1]:null;
|
|
1872
|
-
if(flabel===null){ err(n,'band needs a quoted "<label>" first: band "<name>" <a>..<b>% in=<node-or-group-id> (a band with no label asserts nothing a reader may keep — fill= is presentation, and §5 forbids meaning riding on colour alone) (MIGRATIONS)'); break; }
|
|
2338
|
+
if(flabel===null){ err(n,'band needs a quoted "<label>" first: band "<name>" <a>..<b>% in=<node-or-group-id> (a band with no label asserts nothing a reader may keep — fill= is presentation, and §5 forbids meaning riding on colour alone) (MIGRATIONS 0.1)'); break; }
|
|
1873
2339
|
if(!opts['in']){ err(n,'band needs in=<node-or-group-id>'); break; }
|
|
1874
2340
|
// 0.1: the `%` is MANDATORY, matching `threshold offset=` (`BARE-FRACTION-VALUES`).
|
|
1875
2341
|
// `band 15`, `band 15-35` and `band 15%-35` all parsed before (the
|
|
1876
|
-
// separator was a hyphen until
|
|
2342
|
+
// separator was a hyphen until 0.1); one concept in one
|
|
1877
2343
|
// document must not have two value grammars (RULE 4.4).
|
|
1878
2344
|
// `RANGE-SPELLING`: the separator is `..`, and the HYPHEN form it
|
|
1879
2345
|
// replaces gets its own named diagnostic. `15-35%` reads as
|
|
@@ -1884,7 +2350,7 @@ function parseOne(text){
|
|
|
1884
2350
|
// cited by `bitfield`. `band` is EXPERIMENTAL (`CONSTRUCT-STATUS-TIERS`), so no
|
|
1885
2351
|
// compatibility promise is owed; the diagnostic is owed anyway.
|
|
1886
2352
|
if(/^(\d+(?:\.\d+)?)-(\d+(?:\.\d+)?)%$/.test(pos[2]||'')){
|
|
1887
|
-
err(n,'the hyphen range "'+pos[2]+'" is no longer the spelling: write band "'+flabel+'" '+String(pos[2]).replace('-','..')+' in=… — FigDown has ONE range grammar, "..", and a hyphen between two numbers reads as subtraction (MIGRATIONS)'); break; }
|
|
2353
|
+
err(n,'the hyphen range "'+pos[2]+'" is no longer the spelling: write band "'+flabel+'" '+String(pos[2]).replace('-','..')+' in=… — FigDown has ONE range grammar, "..", and a hyphen between two numbers reads as subtraction (MIGRATIONS 0.1)'); break; }
|
|
1888
2354
|
const m=/^(\d+(?:\.\d+)?)%$|^(\d+(?:\.\d+)?)\.\.(\d+(?:\.\d+)?)%$/.exec(pos[2]||'');
|
|
1889
2355
|
if(!m){ err(n,'band needs a range with the % sign: band "<label>" <pct>% or band "<label>" <a>..<b>%'); break; }
|
|
1890
2356
|
if(pos.length>3){ err(n,'unexpected argument "'+pos[3]+'"'); break; }
|
|
@@ -1917,7 +2383,7 @@ function parseOne(text){
|
|
|
1917
2383
|
if(!id){ err(n,PIN_SHAPE); break; }
|
|
1918
2384
|
// 0.1 (RULE 1.1a): the pair is PARENTHESISED — at=(x,y).
|
|
1919
2385
|
if(at!==undefined&&/^-?\d+(?:\.\d+)?,-?\d+(?:\.\d+)?$/.test(at)){
|
|
1920
|
-
err(n,'pin at= now takes a paren point: at=('+at+') — a bare comma pair is a list of two numbers, not a point (MIGRATIONS)'); break; }
|
|
2386
|
+
err(n,'pin at= now takes a paren point: at=('+at+') — a bare comma pair is a list of two numbers, not a point (MIGRATIONS 0.1)'); break; }
|
|
1921
2387
|
const m=at===undefined?null:/^\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)\)$/.exec(at);
|
|
1922
2388
|
// A WRITTEN `at=` that does not parse is its own error, never the
|
|
1923
2389
|
// whole-line shape message: the author declared a point and got the
|
|
@@ -1971,7 +2437,7 @@ function parseOne(text){
|
|
|
1971
2437
|
// the cell border colour, `text=` the block caption colour.
|
|
1972
2438
|
// `TYPED-BLOCK-SILENT-FALLBACK`: word= empty or non-integer was a silent fallback/truncation
|
|
1973
2439
|
// (word= → 32, word=8.5 → 8). Positive integer only; absence → 32.
|
|
1974
|
-
// Spelled `unit=` until
|
|
2440
|
+
// Spelled `unit=` until 0.1 (`BITS-PER-ROW-KEY-NAMING`).
|
|
1975
2441
|
let word=32;
|
|
1976
2442
|
if(opts.word!==undefined){
|
|
1977
2443
|
if(opts.word===''||!/^\d+$/.test(opts.word)||+opts.word<1){
|
|
@@ -2048,11 +2514,39 @@ function parseOne(text){
|
|
|
2048
2514
|
}
|
|
2049
2515
|
for(const r of doc.ranks) for(const id of r.ids)
|
|
2050
2516
|
if(!nodeIds.has(id)) errs.push('Line '+r.line+': unknown node "'+id+'" in rank');
|
|
2517
|
+
// `MARKER-TARGET-KINDS`: `in=` on `threshold`/`band` also resolves a REGION id —
|
|
2518
|
+
// a `bitfield`, `table` or `timing` block. This is a WIDENING of the value
|
|
2519
|
+
// domain, not a third sense of `in=` and not a new spelling: the relation is
|
|
2520
|
+
// sense 2 verbatim, *the element this one is drawn across*, and what changes
|
|
2521
|
+
// is only which declared ids the resolver will bind.
|
|
2522
|
+
//
|
|
2523
|
+
// It is UNGATED, and that is argued rather than assumed. A region-targeted
|
|
2524
|
+
// threshold did not merely mean something else before this release — it did
|
|
2525
|
+
// not PARSE. `threshold "Max" in=q offset=50%` over a `table q` answered
|
|
2526
|
+
// `unknown target "q" for threshold`, the same error a nonexistent id gets,
|
|
2527
|
+
// because this set was hard-coded to nodes and groups while `table <id>`
|
|
2528
|
+
// makes the id mandatory and `chart <table-id>` already consumes it from
|
|
2529
|
+
// another directive. So no `figdown 0.1` or `figdown 0.2` document changes
|
|
2530
|
+
// meaning and none becomes invalid; the only documents affected are ones
|
|
2531
|
+
// that produced no figure at all. Core §13.0.1's hazard — "a figure that
|
|
2532
|
+
// looks right and means something else" — needs two readings to choose
|
|
2533
|
+
// between, and here the alternative reading was an error message. That is
|
|
2534
|
+
// exactly why `note=` IS gated a few hundred lines up and this is not: the
|
|
2535
|
+
// key had a prior meaning, this had none. Nothing is added to the option
|
|
2536
|
+
// registry, so a reader of `figdown 0.2` consulting core §10 finds the same
|
|
2537
|
+
// 45 rows either way.
|
|
2538
|
+
//
|
|
2539
|
+
// The two WRED figures this unblocks are the whole of the measured demand
|
|
2540
|
+
// (core §9 `ANNOTATION-LOCATOR-SPLIT`). The locator COORDINATE grammar — `in=q(3)`, addressing a
|
|
2541
|
+
// row inside the region — is designed and deliberately NOT built: it has no
|
|
2542
|
+
// shipping consumer, and RULE 4.7 argues against spending a grammar before
|
|
2543
|
+
// one exists.
|
|
2544
|
+
const regionTarget=id=>blockIds.has(id);
|
|
2051
2545
|
for(const gl of doc.thresholds)
|
|
2052
|
-
if(!groupIds.has(gl.target)&&!nodeIds.has(gl.target))
|
|
2546
|
+
if(!groupIds.has(gl.target)&&!nodeIds.has(gl.target)&&!regionTarget(gl.target))
|
|
2053
2547
|
errs.push('Line '+gl.line+': unknown target "'+gl.target+'" for threshold');
|
|
2054
2548
|
for(const f of doc.bands)
|
|
2055
|
-
if(!groupIds.has(f.target)&&!nodeIds.has(f.target))
|
|
2549
|
+
if(!groupIds.has(f.target)&&!nodeIds.has(f.target)&&!regionTarget(f.target))
|
|
2056
2550
|
errs.push('Line '+f.line+': unknown target "'+f.target+'" for band');
|
|
2057
2551
|
for(const t of doc.trunks) for(const [a,b] of t.pairs){
|
|
2058
2552
|
if((!nodeIds.has(a)&&!boundaryIds.has(a))||(!nodeIds.has(b)&&!boundaryIds.has(b))){ errs.push('Line '+t.line+': unknown endpoint in "'+a+'--'+b+'"'); continue; }
|
|
@@ -2111,7 +2605,7 @@ function parseOne(text){
|
|
|
2111
2605
|
// b class=p` was accepted, drew a #555 line, and rendered a legend swatch
|
|
2112
2606
|
// that showed nothing, so the class's meaning was invisible in its own
|
|
2113
2607
|
// derived legend. With `color=` retired (`COLOUR-KEY-STATUS`) the remaining shape of the
|
|
2114
|
-
// hole is a class carrying only `style
|
|
2608
|
+
// hole is a class carrying only `style=`, or nothing at
|
|
2115
2609
|
// all: the edge silently takes the default colour and the author who
|
|
2116
2610
|
// declared a class to CLASSIFY the edge gets no colour and no warning.
|
|
2117
2611
|
// Both halves are the same rule — a class an edge joins must declare at
|
|
@@ -2126,9 +2620,9 @@ function parseOne(text){
|
|
|
2126
2620
|
if(!c||c.stroke!==undefined) continue;
|
|
2127
2621
|
if(c.fill===undefined&&c.style!==undefined) continue;
|
|
2128
2622
|
if(c.fill!==undefined)
|
|
2129
|
-
errs.push('Line '+e.line+': class "'+cid+'" sets fill= but no stroke=, and an edge has no interior — add stroke= to the class (it paints the edge; fill= keeps painting members that have an interior) (MIGRATIONS)');
|
|
2623
|
+
errs.push('Line '+e.line+': class "'+cid+'" sets fill= but no stroke=, and an edge has no interior — add stroke= to the class (it paints the edge; fill= keeps painting members that have an interior) (MIGRATIONS 0.1)');
|
|
2130
2624
|
else
|
|
2131
|
-
errs.push('Line '+e.line+': class "'+cid+'" declares no channel an edge has — add stroke= (an edge has only stroke= and style=: no interior, and v0.1 has no label-colour key). Without one the edge takes the default colour and the class shows nothing in the legend (MIGRATIONS)');
|
|
2625
|
+
errs.push('Line '+e.line+': class "'+cid+'" declares no channel an edge has — add stroke= (an edge has only stroke= and style=: no interior, and v0.1 has no label-colour key). Without one the edge takes the default colour and the class shows nothing in the legend (MIGRATIONS 0.1)');
|
|
2132
2626
|
}
|
|
2133
2627
|
}
|
|
2134
2628
|
{ // class references must resolve (closed grammar)
|
|
@@ -2281,7 +2775,7 @@ function stackSectionSvgs(results){
|
|
|
2281
2775
|
// became the node's LABEL. It is now a line error wherever it is part of the
|
|
2282
2776
|
// GRAMMAR — that is, everywhere except the FOUR verbatim regions (this
|
|
2283
2777
|
// function handles three of them; the pipe row is the caller's, see below).
|
|
2284
|
-
// The count read "three" until
|
|
2778
|
+
// The count read "three" until 0.1, listing four:
|
|
2285
2779
|
// - inside a quoted string ("…;…"),
|
|
2286
2780
|
// - inside a comment (already stripped before this runs),
|
|
2287
2781
|
// - inside an edge label (edge a -[packet arrives; TMR != 0]-> b),
|
|
@@ -2305,7 +2799,7 @@ function findReservedSemi(s){
|
|
|
2305
2799
|
}
|
|
2306
2800
|
return -1;
|
|
2307
2801
|
}
|
|
2308
|
-
const RESERVED_SEMI='";" is reserved for a future statement separator and has no meaning in v0.1 — write one directive per line; a literal ";" belongs inside a quoted string, an [edge label] or a comment (MIGRATIONS)';
|
|
2802
|
+
const RESERVED_SEMI='";" is reserved for a future statement separator and has no meaning in v0.1 — write one directive per line; a literal ";" belongs inside a quoted string, an [edge label] or a comment (MIGRATIONS 0.1)';
|
|
2309
2803
|
|
|
2310
2804
|
function findComment(s){
|
|
2311
2805
|
// '#' starts a comment only at line start or after whitespace,
|
|
@@ -2427,6 +2921,92 @@ function cwMax(s){ return Math.max(...String(s).split('\n').map(cw)); }
|
|
|
2427
2921
|
// §5 style= → SVG dash pattern. `def` is the construct's conventional
|
|
2428
2922
|
// default (the bundle ring and the threshold line are dashed by convention);
|
|
2429
2923
|
// an explicit style= always wins.
|
|
2924
|
+
// ── the note box (`DRAWN-ANNOTATION-FORM`) ───────────────────────────────────────
|
|
2925
|
+
// The drawn annotation's whole appearance lives in these three functions,
|
|
2926
|
+
// because `DOMAIN-CONVENTION-DIRECTIVES` gives the engine the drawing convention outright: `note=` takes
|
|
2927
|
+
// no `at=`, no `side=`, no colour and no size, so there is exactly one look and
|
|
2928
|
+
// it is decided here rather than by an author.
|
|
2929
|
+
//
|
|
2930
|
+
// The look is the UML note symbol — a rectangle with a folded top-right corner
|
|
2931
|
+
// — which is the notation of the metaclass the SPELLING is borrowed from
|
|
2932
|
+
// (UML 2.5.1's `Comment`; RULE 4.1 takes the standard's word, and taking its
|
|
2933
|
+
// glyph with it is what lets a reader recognise the box as an aside without a
|
|
2934
|
+
// legend entry). It is deliberately unlike a `node`: no rounded corners, a
|
|
2935
|
+
// paler wash, smaller type, and a corner no node shape has.
|
|
2936
|
+
const NOTE_FS=10, NOTE_PAD=6, NOTE_FOLD=9, NOTE_MAXCH=30;
|
|
2937
|
+
const NOTE_FILL='#fdfaf0', NOTE_STROKE='#c9c4b2', NOTE_INK='#5c584c';
|
|
2938
|
+
// The leader is deliberately DARKER than the box outline. Drawn in the box's
|
|
2939
|
+
// own stroke it was legible in the SVG and invisible on the page at 1x — a
|
|
2940
|
+
// leader nobody can see is a leader that is not there, and the note then reads
|
|
2941
|
+
// as annotating whatever it happens to sit above. Checked by eye, not by a
|
|
2942
|
+
// contrast number: the box is a surface and may recede, the leader is a
|
|
2943
|
+
// statement of attachment and may not.
|
|
2944
|
+
const NOTE_LEADER='#9c968a';
|
|
2945
|
+
// Deterministic greedy word wrap. Author newlines are honoured and never
|
|
2946
|
+
// merged; a run longer than the wrap width is broken only between words, so a
|
|
2947
|
+
// long identifier keeps its shape and simply widens the box.
|
|
2948
|
+
function noteWrap(text){
|
|
2949
|
+
const out=[];
|
|
2950
|
+
for(const para of String(text).split('\n')){
|
|
2951
|
+
const words=para.split(/ +/).filter(w=>w.length);
|
|
2952
|
+
if(!words.length){ out.push(''); continue; }
|
|
2953
|
+
let cur=words[0];
|
|
2954
|
+
for(let i=1;i<words.length;i++){
|
|
2955
|
+
if((cur+' '+words[i]).length<=NOTE_MAXCH) cur+=' '+words[i];
|
|
2956
|
+
else { out.push(cur); cur=words[i]; }
|
|
2957
|
+
}
|
|
2958
|
+
out.push(cur);
|
|
2959
|
+
}
|
|
2960
|
+
return out;
|
|
2961
|
+
}
|
|
2962
|
+
function noteBox(text){
|
|
2963
|
+
const lines=noteWrap(text);
|
|
2964
|
+
const lh=NOTE_FS*1.35;
|
|
2965
|
+
const w=Math.max(28, Math.max.apply(null,lines.map(tw))+NOTE_PAD*2+NOTE_FOLD);
|
|
2966
|
+
const h=lines.length*lh+NOTE_PAD*2-lh*0.15;
|
|
2967
|
+
return {w:Math.round(w*100)/100, h:Math.round(h*100)/100, lines, lh};
|
|
2968
|
+
}
|
|
2969
|
+
// The folded-corner outline, plus the small triangle that reads as the back of
|
|
2970
|
+
// the fold. One path each, so the shape is one primitive and the output is
|
|
2971
|
+
// byte-stable.
|
|
2972
|
+
function noteSvg(x,y,box,carrier){
|
|
2973
|
+
const F=NOTE_FOLD, w=box.w, h=box.h;
|
|
2974
|
+
const d='M'+x+' '+y+' H'+(x+w-F)+' L'+(x+w)+' '+(y+F)+' V'+(y+h)+' H'+x+' Z';
|
|
2975
|
+
const fold='M'+(x+w-F)+' '+y+' V'+(y+F)+' H'+(x+w)+' Z';
|
|
2976
|
+
const out=['<g class="fd-note"'+(carrier&&carrier.kind?' data-note-on="'+carrier.kind+'"':'')+'>',
|
|
2977
|
+
'<path d="'+d+'" fill="'+NOTE_FILL+'" stroke="'+NOTE_STROKE+'" stroke-width="1"/>',
|
|
2978
|
+
'<path d="'+fold+'" fill="'+NOTE_STROKE+'" fill-opacity="0.35" stroke="'+NOTE_STROKE+'" stroke-width="1"/>'];
|
|
2979
|
+
const first=y+NOTE_PAD+NOTE_FS*0.85;
|
|
2980
|
+
box.lines.forEach((ln,i)=>{
|
|
2981
|
+
out.push('<text x="'+(x+NOTE_PAD)+'" y="'+Math.round((first+i*box.lh)*100)/100+
|
|
2982
|
+
'" font-size="'+NOTE_FS+'" text-anchor="start" fill="'+NOTE_INK+'">'+esc(ln)+'</text>');
|
|
2983
|
+
});
|
|
2984
|
+
out.push('</g>');
|
|
2985
|
+
return out.join('');
|
|
2986
|
+
}
|
|
2987
|
+
// The leader is drawn ONLY when adjacency failed, and it is drawn AFTER the
|
|
2988
|
+
// box is placed, so it is correct by construction: it runs from the box edge
|
|
2989
|
+
// facing the carrier to the carrier's nearest point, and cannot be stale.
|
|
2990
|
+
function noteLeader(best,box,rect){
|
|
2991
|
+
const bx=best.x, by=best.y, bw=box.w, bh=box.h;
|
|
2992
|
+
const cx=rect.x+rect.w/2, cy=rect.y+rect.h/2;
|
|
2993
|
+
let x1,y1;
|
|
2994
|
+
if(best.side==='right') { x1=bx; y1=by+bh/2; }
|
|
2995
|
+
else if(best.side==='left') { x1=bx+bw; y1=by+bh/2; }
|
|
2996
|
+
else if(best.side==='below') { x1=bx+bw/2; y1=by; }
|
|
2997
|
+
else { x1=bx+bw/2; y1=by+bh; }
|
|
2998
|
+
// land on the carrier's border, not its centre, so the line stops at the
|
|
2999
|
+
// thing it points at
|
|
3000
|
+
const x2=Math.max(rect.x, Math.min(rect.x+rect.w, x1));
|
|
3001
|
+
const y2=Math.max(rect.y, Math.min(rect.y+rect.h, y1));
|
|
3002
|
+
return '<line x1="'+x1+'" y1="'+y1+'" x2="'+(rect.w||rect.h?x2:cx)+'" y2="'+(rect.w||rect.h?y2:cy)+
|
|
3003
|
+
'" stroke="'+NOTE_LEADER+'" stroke-width="1" stroke-dasharray="4 3"/>';
|
|
3004
|
+
}
|
|
3005
|
+
// A band's optional edge stroke. `renderScene` has had this as a local since
|
|
3006
|
+
// 0.1; `MARKER-TARGET-KINDS` needs the same rule for a REGION-scope band, which is drawn
|
|
3007
|
+
// outside the scene, so the one expression moves to module scope rather than
|
|
3008
|
+
// being written twice with a chance to drift.
|
|
3009
|
+
const bandEdgeOf=f=>(f.stroke||f.style)?' stroke="'+(f.stroke||'#8a8880')+'"'+dashOf(f.style,''):'';
|
|
2430
3010
|
function dashOf(style,def){
|
|
2431
3011
|
const p = style==='dashed'?'6 4' : style==='dotted'?'2 4' : style==='solid'?'' : def;
|
|
2432
3012
|
return p?' stroke-dasharray="'+p+'"':'';
|
|
@@ -2622,21 +3202,17 @@ function render(doc,ropts){
|
|
|
2622
3202
|
if(C[id] && C[id][k]!==undefined) x[k]=C[id][k];
|
|
2623
3203
|
}
|
|
2624
3204
|
};
|
|
2625
|
-
// a class carries
|
|
2626
|
-
//
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
if(C[id] && C[id].plane!==undefined) x.plane=C[id].plane;
|
|
2631
|
-
}
|
|
2632
|
-
};
|
|
2633
|
-
const rsAll=(x)=>{ rs(x,'fill'); rs(x,'stroke'); rs(x,'style'); rsl(x); };
|
|
3205
|
+
// `PAINT-ORDER-CONSTRUCT`: a class carries the FOUR §5 attributes that survive.
|
|
3206
|
+
// The fifth was `plane`, and its cascade helper (`rsl`) is gone with the
|
|
3207
|
+
// key — a class can no longer set a paint order because the language has
|
|
3208
|
+
// no paint order to set. Everything is on the implicit `base` plane.
|
|
3209
|
+
const rsAll=(x)=>{ rs(x,'fill'); rs(x,'stroke'); rs(x,'style'); };
|
|
2634
3210
|
for(const n of doc.nodes){ rsAll(n); if(n.style===undefined) n.style='solid'; }
|
|
2635
3211
|
for(const g of doc.groups){ rsAll(g); }
|
|
2636
3212
|
// 0.1 (§8.4): an edge has no interior, so it takes every class
|
|
2637
3213
|
// channel EXCEPT `fill` — which the parser has already guaranteed is
|
|
2638
3214
|
// accompanied by a `stroke` on any class an edge joins.
|
|
2639
|
-
for(const e of doc.edges){ rs(e,'stroke'); rs(e,'style');
|
|
3215
|
+
for(const e of doc.edges){ rs(e,'stroke'); rs(e,'style'); if(e.style===undefined) e.style='solid'; }
|
|
2640
3216
|
for(const b of doc.blocks){
|
|
2641
3217
|
rsAll(b);
|
|
2642
3218
|
if(b.fields) for(const f of b.fields) rsAll(f);
|
|
@@ -2650,13 +3226,54 @@ function render(doc,ropts){
|
|
|
2650
3226
|
const s=renderScene(doc,y); parts.push(s.svg); y=s.y; maxW=Math.max(maxW,s.w);
|
|
2651
3227
|
sceneMeta=s.meta;
|
|
2652
3228
|
}
|
|
3229
|
+
// `MARKER-TARGET-KINDS`: a region-scope `threshold`/`band` is drawn HERE and not
|
|
3230
|
+
// in `renderScene`, because a region is not in the scene. Typed blocks stack
|
|
3231
|
+
// in document order OUTSIDE the scene (core §2, the `plane=` carve-out says
|
|
3232
|
+
// so in as many words), so at the moment `renderScene` emits its own
|
|
3233
|
+
// thresholds the region has no geometry yet and sits at a `y` the scene never
|
|
3234
|
+
// sees. The mark therefore travels with its target: each block reports its
|
|
3235
|
+
// box, and the marks that name it are painted over that box in the same
|
|
3236
|
+
// coordinate shape (`x0`/`x1`/`yA`/`yB`) the scene uses for a group.
|
|
3237
|
+
const regionBox={};
|
|
2653
3238
|
for(const b of doc.blocks){
|
|
2654
3239
|
let s;
|
|
2655
3240
|
if(b.type==='bitfield') s=renderBitfield(b,y);
|
|
2656
3241
|
else if(b.type==='table') s=renderTable(b,y);
|
|
2657
3242
|
else if(b.type==='chart') s=renderChart(b,y,doc);
|
|
2658
3243
|
else s=renderTiming(b,y);
|
|
2659
|
-
parts.push(s.svg);
|
|
3244
|
+
parts.push(s.svg);
|
|
3245
|
+
if(s.box) regionBox[b.id]=s.box;
|
|
3246
|
+
y=s.y+24; maxW=Math.max(maxW,s.w);
|
|
3247
|
+
}
|
|
3248
|
+
{
|
|
3249
|
+
const rsvg=[];
|
|
3250
|
+
for(const f of (doc.bands||[])){
|
|
3251
|
+
const B=regionBox[f.target]; if(!B) continue;
|
|
3252
|
+
const w=B.x1-B.x0, h=B.yB-B.yA;
|
|
3253
|
+
let bx,by,bw,bh;
|
|
3254
|
+
if(f.dir==='up') { bx=B.x0; by=B.yB-h*f.to/100; bw=w; bh=h*(f.to-f.from)/100; }
|
|
3255
|
+
else if(f.dir==='down') { bx=B.x0; by=B.yA+h*f.from/100; bw=w; bh=h*(f.to-f.from)/100; }
|
|
3256
|
+
else if(f.dir==='right'){ bx=B.x0+w*f.from/100; by=B.yA; bw=w*(f.to-f.from)/100; bh=h; }
|
|
3257
|
+
else { bx=B.x1-w*f.to/100; by=B.yA; bw=w*(f.to-f.from)/100; bh=h; }
|
|
3258
|
+
rsvg.push('<rect x="'+bx+'" y="'+by+'" width="'+bw+'" height="'+bh+'" fill="'+f.fill+'" opacity="0.35"'+bandEdgeOf(f)+'/>');
|
|
3259
|
+
rsvg.push(textEl(bx+bw/2, by+bh/2+4, 11, 'middle', labelInk(f.fill,'#334155'), f.label,
|
|
3260
|
+
' paint-order="stroke" stroke="#fff" stroke-width="3"'));
|
|
3261
|
+
}
|
|
3262
|
+
for(const gl of (doc.thresholds||[])){
|
|
3263
|
+
const B=regionBox[gl.target]; if(!B) continue;
|
|
3264
|
+
const ly=B.yB-(B.yB-B.yA)*gl.pct/100;
|
|
3265
|
+
const col=gl.stroke||'#ef4444';
|
|
3266
|
+
rsvg.push('<line x1="'+B.x0+'" y1="'+ly+'" x2="'+B.x1+'" y2="'+ly+'" stroke="'+col+
|
|
3267
|
+
'" stroke-width="'+(gl.pct>=100?4:2)+'"'+dashOf(gl.style,'7 4')+'/>');
|
|
3268
|
+
rsvg.push(textEl(B.x1+8, ly+4, 11, 'start', col, gl.label,' paint-order="stroke" stroke="#fff" stroke-width="3"'));
|
|
3269
|
+
maxW=Math.max(maxW, B.x1+8+tw(gl.label));
|
|
3270
|
+
}
|
|
3271
|
+
// A band is a translucent wash UNDER the grid ink; a threshold is a mark
|
|
3272
|
+
// OVER it. The region has already been pushed, so both go after it and the
|
|
3273
|
+
// band leans on opacity rather than paint order for the "under" reading —
|
|
3274
|
+
// the same compromise `renderChart` makes, and the reason the opacity here
|
|
3275
|
+
// is lower than the scene's 0.9.
|
|
3276
|
+
if(rsvg.length) parts.push(rsvg.join(''));
|
|
2660
3277
|
}
|
|
2661
3278
|
// 0.1 (`CLASS-EMPTY-MEANING`): a class whose meaning is the EMPTY string claims no
|
|
2662
3279
|
// meaning, so it has nothing to explain and draws NO legend entry — it is
|
|
@@ -2694,6 +3311,30 @@ function render(doc,ropts){
|
|
|
2694
3311
|
parts.push(es.join(''));
|
|
2695
3312
|
y=ly+rowH;
|
|
2696
3313
|
}
|
|
3314
|
+
// `DRAWN-ANNOTATION-FORM`: the FIGURE-level note — `title "…" note="…"`. It carries
|
|
3315
|
+
// the 14% of measured annotations that name no single element ("Total: 8k
|
|
3316
|
+
// tunnel indexes", a four-signal legend, a TODO about the whole figure), and
|
|
3317
|
+
// it is the acceptor that removes the last argument for a standalone `note`
|
|
3318
|
+
// keyword: the figure HAS a declaration line, so attachment-by-position
|
|
3319
|
+
// reaches it too.
|
|
3320
|
+
//
|
|
3321
|
+
// It has no geometry to sit beside, so it takes no candidates and NEVER takes
|
|
3322
|
+
// a leader — a leader must point at something, and "the figure" is not a
|
|
3323
|
+
// thing on the canvas. It is placed with the caption, at the bottom, after
|
|
3324
|
+
// the scene, the regions and the derived legend. That is a placement rule and
|
|
3325
|
+
// not an author's choice (`DOMAIN-CONVENTION-DIRECTIVES`), and it is deterministic by construction:
|
|
3326
|
+
// there is exactly one figure-level note and exactly one place for it.
|
|
3327
|
+
//
|
|
3328
|
+
// The title itself is NOT drawn by default (`DEFAULT-VALUE-SELECTION` — an embedded figure sits
|
|
3329
|
+
// under a host caption), and the note does not follow it: the note is the
|
|
3330
|
+
// thing that draws. An author who wants the sentence in the picture writes
|
|
3331
|
+
// it here whether or not the renderer is showing the title.
|
|
3332
|
+
if(doc.note!==null&&doc.note!==undefined){
|
|
3333
|
+
const nb=noteBox(doc.note);
|
|
3334
|
+
const ny=y+8;
|
|
3335
|
+
parts.push(noteSvg(0,ny,nb,{kind:'title'}));
|
|
3336
|
+
y=ny+nb.h+2; maxW=Math.max(maxW,nb.w);
|
|
3337
|
+
}
|
|
2697
3338
|
const PADL=18, PADT=6;
|
|
2698
3339
|
const W=Math.ceil(maxW)+PADL+8, H=Math.ceil(y)+PADT+4;
|
|
2699
3340
|
return {svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '+W+' '+H+'" width="'+W+'" height="'+H+'" font-family="system-ui,sans-serif">'
|
|
@@ -3178,7 +3819,7 @@ function renderScene(doc,y0){
|
|
|
3178
3819
|
const halo=' paint-order="stroke" stroke="#fff" stroke-width="3"';
|
|
3179
3820
|
const seg=(p,q,t,lbl,fs)=>reqLabel({p,q,t0:t,text:lbl,fs,col:ecol,halo,e,A,B,kind:'end'});
|
|
3180
3821
|
if(isBack.has(e)&&!pinned(e.a)&&!pinned(e.b)){
|
|
3181
|
-
// ── ROUTING-CHANGE ARCHITECTURE NOTE ──────────
|
|
3822
|
+
// ── ROUTING-CHANGE ARCHITECTURE NOTE (`SELF-EDGE-DRAWING`/`EDGE-BEND-RETENTION`) ──────────
|
|
3182
3823
|
// Edge labels are DEFERRED: every label is registered against its
|
|
3183
3824
|
// FINAL segment geometry (reqLabel/lblReq above) and placed by ONE
|
|
3184
3825
|
// greedy pass after all edges are drawn; arrowheads are computed from
|
|
@@ -3190,7 +3831,7 @@ function renderScene(doc,y0){
|
|
|
3190
3831
|
// arrowheads, orphaned labels): that was external splicing, not an
|
|
3191
3832
|
// engine gap. Patch routing here; do not "fix" the label machinery.
|
|
3192
3833
|
if(A===B){
|
|
3193
|
-
// Self-transition: a small side loop on the node, the
|
|
3834
|
+
// Self-transition (`SELF-EDGE-DRAWING`): a small side loop on the node, the
|
|
3194
3835
|
// convention of every drawing tool — never a lap of the figure
|
|
3195
3836
|
// through the back-edge channel. Side order r,l,b,t; first side
|
|
3196
3837
|
// whose loop box overlaps no other node wins (deterministic).
|
|
@@ -3343,7 +3984,7 @@ function renderScene(doc,y0){
|
|
|
3343
3984
|
// their neighbours turns a 40-point staircase into the 2–4 bends a
|
|
3344
3985
|
// dummy-vertex chain should have, without moving the drawn line.
|
|
3345
3986
|
simplifyPts(pts);
|
|
3346
|
-
// Waypoint prune: after collinear simplification a
|
|
3987
|
+
// Waypoint prune (`EDGE-BEND-RETENTION`): after collinear simplification a
|
|
3347
3988
|
// chain can still carry a staircase of near-collinear jogs — the drift
|
|
3348
3989
|
// clamp allows only a few px of sideways movement per rank, so a run
|
|
3349
3990
|
// that wants to move 35px sideways alternates short diagonals and
|
|
@@ -3455,7 +4096,13 @@ function renderScene(doc,y0){
|
|
|
3455
4096
|
// the arrowheads, and the other edges — plus a pull back toward the
|
|
3456
4097
|
// preferred point on the segment. The lowest score wins. No randomness,
|
|
3457
4098
|
// no iteration to a fixed point: one deterministic pass.
|
|
3458
|
-
if(lblReq.length)
|
|
4099
|
+
// `DRAWN-ANNOTATION-FORM`: this block used to be guarded by `if(lblReq.length)`,
|
|
4100
|
+
// with `obst`, `ovl`, `segHit` and `placed` local to it. The note pass below
|
|
4101
|
+
// is a SECOND claimant on exactly that machinery and must see exactly the
|
|
4102
|
+
// same `placed` list — a note that did not know where the edge labels went
|
|
4103
|
+
// could not yield to them, which is the first of the four placement rules.
|
|
4104
|
+
// So the scaffolding is hoisted and only the LOOP keeps the guard.
|
|
4105
|
+
{
|
|
3459
4106
|
const obst=nodes.filter(n=>!n.boundary).map(n=>({x:n.x,y:n.y,w:n.w,h:n.h,n}));
|
|
3460
4107
|
const ovl=(a,b)=>{
|
|
3461
4108
|
const ix=Math.min(a.x+a.w,b.x+b.w)-Math.max(a.x,b.x);
|
|
@@ -3493,7 +4140,7 @@ function renderScene(doc,y0){
|
|
|
3493
4140
|
return {x,y:by+up,anchor,t,side,box:{x:bx,y:by,w,h}};
|
|
3494
4141
|
};
|
|
3495
4142
|
const placed=[];
|
|
3496
|
-
for(const r of lblReq){
|
|
4143
|
+
if(lblReq.length) for(const r of lblReq){
|
|
3497
4144
|
const dx=r.q[0]-r.p[0], dy=r.q[1]-r.p[1];
|
|
3498
4145
|
const across=Math.abs(dx)>=Math.abs(dy);
|
|
3499
4146
|
let sides, ts, tPref;
|
|
@@ -3533,6 +4180,146 @@ function renderScene(doc,y0){
|
|
|
3533
4180
|
W=Math.max(W, best.box.x+best.box.w+4);
|
|
3534
4181
|
Hh=Math.max(Hh, best.box.y+best.box.h+4-y0-20);
|
|
3535
4182
|
}
|
|
4183
|
+
// ── note placement (`DRAWN-ANNOTATION-FORM`) — the SAME pass, entered LAST ────────────────
|
|
4184
|
+
// Four rules, and they are in the spec rather than only here because two
|
|
4185
|
+
// engines have to agree on them:
|
|
4186
|
+
//
|
|
4187
|
+
// 1. Notes register LAST, after every edge label and arrowhead. The
|
|
4188
|
+
// reason is semantic, not convenient: a label is ON the thing it names
|
|
4189
|
+
// and an arrowhead IS part of the connector, whereas a note is BESIDE
|
|
4190
|
+
// what it is about. A NOTE YIELDS; NOTHING YIELDS TO A NOTE. That is
|
|
4191
|
+
// why this loop runs after the one above, reads the same `placed`, and
|
|
4192
|
+
// is read by nothing after it.
|
|
4193
|
+
// 2. Candidates are generated around the CARRIER's final geometry — a
|
|
4194
|
+
// node box, a group rect, or the edge's segment list, all of which are
|
|
4195
|
+
// rects or segments by the time this pass runs — and scored by the same
|
|
4196
|
+
// overlap function against `placed`, `obst`, `arrowBox` and `edgeSegs`.
|
|
4197
|
+
// 3. A LEADER LINE is drawn ONLY when the box could not be placed adjacent
|
|
4198
|
+
// to its carrier. This is where attachment-by-syntax pays off twice:
|
|
4199
|
+
// the carrier is known from the line, so the PREFERRED position is
|
|
4200
|
+
// always adjacency and the leader is a fallback the engine reaches for
|
|
4201
|
+
// rather than a permanent part of the construct. It is drawn AFTER
|
|
4202
|
+
// placement, so it is correct by construction — the property `SELF-EDGE-DRAWING`/`EDGE-BEND-RETENTION`
|
|
4203
|
+
// already records for arrowheads.
|
|
4204
|
+
// 4. Determinism is not optional. `RENDERING-DETERMINISM` promises byte-reproducible output,
|
|
4205
|
+
// and one greedy pass in registration order with no iteration is what
|
|
4206
|
+
// delivers it. Registration order here is DOCUMENT order — carriers are
|
|
4207
|
+
// sorted by source line, across kinds — so moving a `group` line above
|
|
4208
|
+
// a `node` line moves the notes with it and nothing else changes.
|
|
4209
|
+
//
|
|
4210
|
+
// `DOMAIN-CONVENTION-DIRECTIVES` binds throughout: `note=` accepts no `at=`, no `side=`, no
|
|
4211
|
+
// `left of`/`right of`. The author names the meaning; the engine owns the
|
|
4212
|
+
// drawing convention. The convention is the UML note symbol — a rectangle
|
|
4213
|
+
// with a folded top-right corner — which is what makes a note readable AS
|
|
4214
|
+
// a note without a legend entry, and is the notation belonging to the
|
|
4215
|
+
// metaclass the spelling is borrowed from (RULE 4.1).
|
|
4216
|
+
const noteCarriers=[];
|
|
4217
|
+
for(const n of nodes) if(n.note!==undefined&&n.note!==null&&!n.boundary)
|
|
4218
|
+
noteCarriers.push({line:n.line,text:n.note,kind:'node',rect:{x:n.x,y:n.y,w:n.w,h:n.h},n});
|
|
4219
|
+
for(const g of doc.groups) if(g.note!==undefined&&g.note!==null){
|
|
4220
|
+
const B=gBox[g.id]; if(!B) continue;
|
|
4221
|
+
noteCarriers.push({line:g.line,text:g.note,kind:'group',
|
|
4222
|
+
rect:{x:B.x0,y:B.yA,w:B.x1-B.x0,h:B.yB-B.yA}});
|
|
4223
|
+
}
|
|
4224
|
+
for(const e of doc.edges) if(e.note!==undefined&&e.note!==null){
|
|
4225
|
+
// An edge is a polyline, not a rect. Its carrier POINT is the midpoint of
|
|
4226
|
+
// the middle registered segment — deterministic, and it is the same
|
|
4227
|
+
// "middle of the run" an author means when they annotate a wire. A note
|
|
4228
|
+
// whose edge never made it to the canvas (an endpoint that did not
|
|
4229
|
+
// resolve) simply has no carrier and is not drawn; the missing endpoint
|
|
4230
|
+
// is already its own line error.
|
|
4231
|
+
const segs=edgeSegs.filter(g=>g.e===e); if(!segs.length) continue;
|
|
4232
|
+
const m=segs[Math.floor((segs.length-1)/2)];
|
|
4233
|
+
const cx=(m.p[0]+m.q[0])/2, cy=(m.p[1]+m.q[1])/2;
|
|
4234
|
+
noteCarriers.push({line:e.line,text:e.note,kind:'edge',rect:{x:cx,y:cy,w:0,h:0},e});
|
|
4235
|
+
}
|
|
4236
|
+
noteCarriers.sort((a,b)=>a.line-b.line);
|
|
4237
|
+
for(const c of noteCarriers){
|
|
4238
|
+
const box=noteBox(c.text);
|
|
4239
|
+
// Adjacency first, then the same four sides pushed out far enough that a
|
|
4240
|
+
// leader is legible. `si` orders the sides; `far` is what decides the
|
|
4241
|
+
// leader, and it costs enough that adjacency wins every time adjacency is
|
|
4242
|
+
// merely imperfect rather than blocked.
|
|
4243
|
+
// Sides in preference order, and for the two that straddle the carrier
|
|
4244
|
+
// an ALIGNMENT as well. Centring a wide note over a narrow carrier at the
|
|
4245
|
+
// left edge of the canvas puts the box off it; aligning the box's left
|
|
4246
|
+
// edge with the carrier's is the same "beside this thing" reading and
|
|
4247
|
+
// stays on the page. Found by eye — see the off-canvas note below.
|
|
4248
|
+
const SIDES=[['right','c'],['left','c'],
|
|
4249
|
+
['below','c'],['below','l'],['below','r'],
|
|
4250
|
+
['above','c'],['above','l'],['above','r']];
|
|
4251
|
+
// Three distance tiers, not two. `near` is adjacency and takes no leader;
|
|
4252
|
+
// the two `far` tiers do. The third exists because a crowded figure can
|
|
4253
|
+
// have NO free space within one leader length of the carrier — a note
|
|
4254
|
+
// then had to sit on top of an edge label, which is the exact inversion
|
|
4255
|
+
// of rule 1 (a note yields; nothing yields to a note). Given somewhere
|
|
4256
|
+
// further to go, it goes there and the canvas grows to fit.
|
|
4257
|
+
let best=null,bestS=Infinity, fallback=null,fallbackS=Infinity;
|
|
4258
|
+
for(const tier of [0,1,2]){
|
|
4259
|
+
const far=tier>0, gap=[10,46,96][tier];
|
|
4260
|
+
for(let si=0;si<SIDES.length;si++){
|
|
4261
|
+
const side=SIDES[si][0], al=SIDES[si][1];
|
|
4262
|
+
let bx,by;
|
|
4263
|
+
if(side==='right'){ bx=c.rect.x+c.rect.w+gap; by=c.rect.y+c.rect.h/2-box.h/2; }
|
|
4264
|
+
else if(side==='left'){ bx=c.rect.x-gap-box.w; by=c.rect.y+c.rect.h/2-box.h/2; }
|
|
4265
|
+
else {
|
|
4266
|
+
bx=al==='l'?c.rect.x
|
|
4267
|
+
:al==='r'?c.rect.x+c.rect.w-box.w
|
|
4268
|
+
:c.rect.x+c.rect.w/2-box.w/2;
|
|
4269
|
+
by=side==='below'?c.rect.y+c.rect.h+gap:c.rect.y-gap-box.h;
|
|
4270
|
+
}
|
|
4271
|
+
const cb={x:bx,y:by,w:box.w,h:box.h};
|
|
4272
|
+
let s=0;
|
|
4273
|
+
// A NOTE YIELDS; NOTHING YIELDS TO A NOTE. `placed` holds the edge
|
|
4274
|
+
// labels and the notes already sited, and its weight is the HIGHEST
|
|
4275
|
+
// of the three — higher than a node's — because a label is a small
|
|
4276
|
+
// box and an AREA-weighted penalty would otherwise let a note sit on
|
|
4277
|
+
// one for less than it costs to clip a node's corner. Found by eye: a
|
|
4278
|
+
// transition note landed across two edge labels while a node overlap
|
|
4279
|
+
// three times the area scored higher.
|
|
4280
|
+
for(const b of placed) s+=10*ovl(cb,b);
|
|
4281
|
+
for(const o of obst) s+=6*ovl(cb,o);
|
|
4282
|
+
for(const a of arrowBox) s+=8*ovl(cb,a);
|
|
4283
|
+
for(const g of edgeSegs) if(segHit(g.p,g.q,cb)) s+=26;
|
|
4284
|
+
for(const g of doc.groups){ const B=gBox[g.id];
|
|
4285
|
+
if(B) s+=1.2*ovl(cb,{x:B.x0,y:B.yA,w:B.x1-B.x0,h:B.yB-B.yA}); }
|
|
4286
|
+
s+=si*12;
|
|
4287
|
+
s+=tier*900; // the leader is a LAST resort
|
|
4288
|
+
// Falling off the top or the left margin is not a BAD placement, it
|
|
4289
|
+
// is NO placement. The canvas grows right and down but has no
|
|
4290
|
+
// mechanism here to grow up or left, so such a box is clipped away
|
|
4291
|
+
// and the annotation VANISHES — the author wrote a sentence and the
|
|
4292
|
+
// reader never sees it, which is the worst outcome available. So it
|
|
4293
|
+
// is a HARD FILTER and not a score term: every other penalty is an
|
|
4294
|
+
// AREA and grows without bound, so no constant can outrank one
|
|
4295
|
+
// reliably. Found by eye on a statechart, where the note on the
|
|
4296
|
+
// leftmost state was emitted at x=-267.8 and simply did not appear —
|
|
4297
|
+
// and then found AGAIN when a large constant was tried first and the
|
|
4298
|
+
// box landed on top of two states instead.
|
|
4299
|
+
// `<0`, not `<2`. The edge-label pass keeps a 2px margin because a
|
|
4300
|
+
// label is loose text; a note is a BOX whose left edge at x=0 IS the
|
|
4301
|
+
// canvas origin and is perfectly placed. With the label pass's
|
|
4302
|
+
// threshold copied over, the one candidate that rescues a wide note
|
|
4303
|
+
// on a leftmost element — below, left-aligned, at exactly x=0 — was
|
|
4304
|
+
// filtered as off-canvas, and the note went to the only survivor: on
|
|
4305
|
+
// top of the next two states.
|
|
4306
|
+
if(cb.x<0||cb.y<y0){
|
|
4307
|
+
if(s<fallbackS-1e-9){ fallbackS=s; fallback={x:bx,y:by,far,side}; }
|
|
4308
|
+
continue;
|
|
4309
|
+
}
|
|
4310
|
+
if(s<bestS-1e-9){ bestS=s; best={x:bx,y:by,far,side}; }
|
|
4311
|
+
}
|
|
4312
|
+
}
|
|
4313
|
+
// Only if EVERY candidate was off-canvas: take the least-bad one and
|
|
4314
|
+
// clamp it on. It may overlap something; visible and overlapping is
|
|
4315
|
+
// recoverable by an author, invisible is not.
|
|
4316
|
+
if(!best){ best=fallback; best.x=Math.max(0,best.x); best.y=Math.max(y0,best.y); }
|
|
4317
|
+
lblsvg.push(noteSvg(best.x,best.y,box,c));
|
|
4318
|
+
if(best.far) lblsvg.push(noteLeader(best,box,c.rect));
|
|
4319
|
+
placed.push({x:best.x,y:best.y,w:box.w,h:box.h});
|
|
4320
|
+
W=Math.max(W, best.x+box.w+4);
|
|
4321
|
+
Hh=Math.max(Hh, best.y+box.h+4-y0-20);
|
|
4322
|
+
}
|
|
3536
4323
|
}
|
|
3537
4324
|
// nodes on top (each wrapped in a draggable, identifiable group)
|
|
3538
4325
|
const nsvg=[];
|
|
@@ -3845,7 +4632,7 @@ function renderBitfield(b,y0){
|
|
|
3845
4632
|
//
|
|
3846
4633
|
// and 0.1 already ruled that a spanning field follows the RFC's
|
|
3847
4634
|
// drawing rather than a FigDown one; this is the same ruling applied to the
|
|
3848
|
-
// other construct in the same figure. Until
|
|
4635
|
+
// other construct in the same figure. Until 0.1 the engine drew ONE
|
|
3849
4636
|
// occurrence and hung `[first] … [last]` on the strip — a FigDown invention
|
|
3850
4637
|
// where a convention already existed.
|
|
3851
4638
|
//
|
|
@@ -3892,7 +4679,7 @@ function renderBitfield(b,y0){
|
|
|
3892
4679
|
const shiftFor=(row)=>elisBands(row)*EL_H;
|
|
3893
4680
|
// `FIELD-WIDER-THAN-WORD`: ONE FIELD IS ONE BOX.
|
|
3894
4681
|
//
|
|
3895
|
-
// A field wider than `word=` occupies several rows. Until
|
|
4682
|
+
// A field wider than `word=` occupies several rows. Until 0.1 each
|
|
3896
4683
|
// row was a separate fully-bordered <rect> carrying the full label, so a
|
|
3897
4684
|
// 128-bit address at word=32 drew as FOUR captioned boxes and a reader saw
|
|
3898
4685
|
// four fields where the model has one. In examples/srh.fd it was worse: the
|
|
@@ -4088,7 +4875,7 @@ function renderBitfield(b,y0){
|
|
|
4088
4875
|
}
|
|
4089
4876
|
boxes.forEach(function(bx,bi){
|
|
4090
4877
|
// `DESCRIPTION-KEY-SPELLING`: the `<title>` is a CHILD of the shape it names, not
|
|
4091
|
-
// a sibling. Until
|
|
4878
|
+
// a sibling. Until 0.1 it was pushed into the block's stream
|
|
4092
4879
|
// after the rect and the label, so it landed under the figure's single
|
|
4093
4880
|
// <g> — and SVG says a <title> names its PARENT, so every description in
|
|
4094
4881
|
// a figure named the same <g> and a conforming UA showed one arbitrary
|
|
@@ -4247,7 +5034,8 @@ function renderBitfield(b,y0){
|
|
|
4247
5034
|
}
|
|
4248
5035
|
yb+=2;
|
|
4249
5036
|
}
|
|
4250
|
-
return {svg:svg.join(''), y:yb, w:wb
|
|
5037
|
+
return {svg:svg.join(''), y:yb, w:wb,
|
|
5038
|
+
box:{x0:0, x1:wb, yA:y0+18, yB:yb}};
|
|
4251
5039
|
}
|
|
4252
5040
|
|
|
4253
5041
|
// ---- table (with ^ rowspan / < colspan merging and per-cell marks) ----
|
|
@@ -4343,7 +5131,20 @@ function renderTable(t,y0){
|
|
|
4343
5131
|
i=>[xAt[i], xAt[i+1]], i=>[cellAt(r-1,i), cellAt(r,i)]));
|
|
4344
5132
|
svg.push(edgeSvg(EDG, DEF));
|
|
4345
5133
|
const yEnd=yTop+yAt[grid.length];
|
|
4346
|
-
|
|
5134
|
+
// `MARKER-TARGET-KINDS`: the GRID's box, so a region-scope `threshold`/`band`
|
|
5135
|
+
// can be drawn across it. It is the grid and not the returned slot: the slot
|
|
5136
|
+
// includes the caption row and the trailing gap, and `offset=50%` on a table
|
|
5137
|
+
// must mean half way down the ROWS, not half way down the whitespace.
|
|
5138
|
+
// `MARKER-TARGET-KINDS`: the box a region-scope `threshold`/`band` is measured
|
|
5139
|
+
// against spans the DATA ROWS, not the whole grid. Measured over the grid,
|
|
5140
|
+
// `offset=85%` on a three-row table lands on the COLUMN HEADINGS and strikes
|
|
5141
|
+
// through them — found by eye on the WRED figure this widening exists for.
|
|
5142
|
+
// The header tiers are chrome: they name the columns, they are not values,
|
|
5143
|
+
// and a threshold is a statement about values. `h1..hN` and `1..` are already
|
|
5144
|
+
// separate address spaces in this genre (genres/table.md), so the split is
|
|
5145
|
+
// the genre's own and not invented here.
|
|
5146
|
+
return {svg:svg.join(''), y:yEnd+6, w:totalW+2,
|
|
5147
|
+
box:{x0:0, x1:totalW, yA:yTop+yAt[H], yB:yEnd}};
|
|
4347
5148
|
}
|
|
4348
5149
|
|
|
4349
5150
|
// ---- chart bar3d: deterministic isometric projection of a table ----
|
|
@@ -4447,7 +5248,8 @@ function renderTiming(w,y0){
|
|
|
4447
5248
|
svg.push('<path d="M'+x+','+(y+4)+' q4,'+(hTotal/4)+' 0,'+(hTotal/2)+' q-4,'+(hTotal/4)+' 0,'+(hTotal/2)+'" fill="none" stroke="#999" stroke-width="2"/>');
|
|
4448
5249
|
}
|
|
4449
5250
|
const H=y+8+w.signals.length*(laneH+laneGap);
|
|
4450
|
-
return {svg:svg.join(''), y:H, w:nameW+cycles*cycleW+2
|
|
5251
|
+
return {svg:svg.join(''), y:H, w:nameW+cycles*cycleW+2,
|
|
5252
|
+
box:{x0:nameW, x1:nameW+cycles*cycleW, yA:y0+18, yB:H}};
|
|
4451
5253
|
}
|
|
4452
5254
|
|
|
4453
5255
|
// ============================================================
|