@wxxb789/anc 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/mermaid-render.js +36 -0
package/package.json
CHANGED
|
@@ -405,6 +405,41 @@ function convertInlineStyles(root) {
|
|
|
405
405
|
* handlers across the corpus — which is exactly why a *failure* is the right
|
|
406
406
|
* response to finding one: it would mean the renderer changed under us.
|
|
407
407
|
*/
|
|
408
|
+
/**
|
|
409
|
+
* Remove Mermaid's gantt "today" marker: the one part of a render that reads the
|
|
410
|
+
* wall clock.
|
|
411
|
+
*
|
|
412
|
+
* The marker is positioned from `new Date()`, so two renders of the same note
|
|
413
|
+
* seconds apart differ by a pixel — measured on a `main` build, where the
|
|
414
|
+
* determinism gate went red on `x1="35387"` against `x1="35388"` — and the same
|
|
415
|
+
* note would hash differently on every rebuild, which
|
|
416
|
+
* `src/lib/markdown.ts` says cannot happen. A build also freezes the build date
|
|
417
|
+
* into content that outlives it, which is nobody's today.
|
|
418
|
+
*
|
|
419
|
+
* There is no configuration for this. Mermaid's `drawToday` reads
|
|
420
|
+
* `db.getTodayMarker()`, which only the in-source `todayMarker` directive sets;
|
|
421
|
+
* `gantt.todayMarker` in `initialize()` is never consulted, verified by setting
|
|
422
|
+
* it and watching the line survive. Removing the group after the render is
|
|
423
|
+
* therefore what makes the output a function of its source alone, and it holds
|
|
424
|
+
* whether or not a diagram spelled the directive itself.
|
|
425
|
+
*
|
|
426
|
+
* The client renderer keeps the marker: it draws at read time, where "today" is
|
|
427
|
+
* the reader's today rather than the build's.
|
|
428
|
+
*
|
|
429
|
+
* Scoped to gantt charts, and that scope is load-bearing rather than tidy: a
|
|
430
|
+
* flowchart node can carry an author's `:::today` class, which Mermaid renders
|
|
431
|
+
* as `<g class="node default today">`, so an unscoped `g.today` selector
|
|
432
|
+
* deletes that node's shape and label and leaves its edges dangling. Gantt has
|
|
433
|
+
* no author-supplied classes, and `aria-roledescription` is the renderer's own
|
|
434
|
+
* statement of the diagram type rather than a guess at its markup.
|
|
435
|
+
*/
|
|
436
|
+
function dropWallClockOutput(root) {
|
|
437
|
+
if (root.getAttribute('aria-roledescription') !== 'gantt')
|
|
438
|
+
return;
|
|
439
|
+
for (const marker of [...root.querySelectorAll('g.today')]) {
|
|
440
|
+
marker.remove();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
408
443
|
function sanitizeDiagram(root, source) {
|
|
409
444
|
if (root.querySelector('script') !== null) {
|
|
410
445
|
throw new DiagramError(source, 'the renderer emitted a <script> element');
|
|
@@ -702,6 +737,7 @@ async function renderOne(source, diagramId, accessibleName) {
|
|
|
702
737
|
const light = parse(rendered.light);
|
|
703
738
|
const dark = parse(rendered.dark);
|
|
704
739
|
for (const root of [light, dark]) {
|
|
740
|
+
dropWallClockOutput(root);
|
|
705
741
|
const style = root.querySelector('style');
|
|
706
742
|
flattenStylesheet(root, style?.textContent ?? '');
|
|
707
743
|
convertInlineStyles(root);
|