jekyll-ham 1.0.4 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/_layouts/default.html +6 -0
- data/_layouts/page.html +1 -1
- data/assets/mermaid/Diagram.d.ts +33 -0
- data/assets/mermaid/Tableau10-31042135.js +10 -0
- data/assets/mermaid/Tableau10-558cc280.js +9 -0
- data/assets/mermaid/__mocks__/mermaidAPI.d.ts +13 -0
- data/assets/mermaid/accessibility.d.ts +27 -0
- data/assets/mermaid/accessibility.spec.d.ts +1 -0
- data/assets/mermaid/arc-c0f908ab.js +148 -0
- data/assets/mermaid/arc-d1f6357e.js +86 -0
- data/assets/mermaid/array-2ff2c7a6.js +6 -0
- data/assets/mermaid/array-b7dcf730.js +6 -0
- data/assets/mermaid/assignWithDepth.d.ts +30 -0
- data/assets/mermaid/blockDiagram-5dc23a45.js +1230 -0
- data/assets/mermaid/blockDiagram-9f4a6865.js +1822 -0
- data/assets/mermaid/blockDiagram-efe38566.js +1818 -0
- data/assets/mermaid/c4Diagram-1e775db3.js +1579 -0
- data/assets/mermaid/c4Diagram-ae766693.js +2473 -0
- data/assets/mermaid/c4Diagram-af207393.js +2463 -0
- data/assets/mermaid/channel-ebbc4130.js +5 -0
- data/assets/mermaid/channel-f9001828.js +8 -0
- data/assets/mermaid/classDiagram-72b9c71d.js +356 -0
- data/assets/mermaid/classDiagram-f52caa06.js +220 -0
- data/assets/mermaid/classDiagram-fb54d2a0.js +363 -0
- data/assets/mermaid/classDiagram-v2-640c694e.js +206 -0
- data/assets/mermaid/classDiagram-v2-a2b738ad.js +298 -0
- data/assets/mermaid/classDiagram-v2-fedb80f6.js +290 -0
- data/assets/mermaid/clone-9ea6bfeb.js +8 -0
- data/assets/mermaid/clone-afc2f047.js +8 -0
- data/assets/mermaid/config.d.ts +98 -0
- data/assets/mermaid/config.spec.d.ts +1 -0
- data/assets/mermaid/config.type.d.ts +1534 -0
- data/assets/mermaid/createText-03b82060.js +2966 -0
- data/assets/mermaid/createText-b70fe78a.js +4929 -0
- data/assets/mermaid/createText-ca0c5216.js +251 -0
- data/assets/mermaid/dagre-wrapper/blockArrowHelper.d.ts +8 -0
- data/assets/mermaid/dagre-wrapper/clusters.d.ts +4 -0
- data/assets/mermaid/dagre-wrapper/createLabel.d.ts +9 -0
- data/assets/mermaid/dagre-wrapper/edgeMarker.d.ts +12 -0
- data/assets/mermaid/dagre-wrapper/edgeMarker.spec.d.ts +1 -0
- data/assets/mermaid/dagre-wrapper/edges.d.ts +14 -0
- data/assets/mermaid/dagre-wrapper/index.d.ts +1 -0
- data/assets/mermaid/dagre-wrapper/intersect/index.d.ts +13 -0
- data/assets/mermaid/dagre-wrapper/intersect/intersect-circle.d.ts +10 -0
- data/assets/mermaid/dagre-wrapper/intersect/intersect-ellipse.d.ts +11 -0
- data/assets/mermaid/dagre-wrapper/intersect/intersect-line.d.ts +13 -0
- data/assets/mermaid/dagre-wrapper/intersect/intersect-node.d.ts +6 -0
- data/assets/mermaid/dagre-wrapper/intersect/intersect-polygon.d.ts +10 -0
- data/assets/mermaid/dagre-wrapper/intersect/intersect-rect.d.ts +5 -0
- data/assets/mermaid/dagre-wrapper/markers.d.ts +2 -0
- data/assets/mermaid/dagre-wrapper/mermaid-graphlib.d.ts +8 -0
- data/assets/mermaid/dagre-wrapper/nodes.d.ts +4 -0
- data/assets/mermaid/dagre-wrapper/shapes/note.d.ts +2 -0
- data/assets/mermaid/dagre-wrapper/shapes/util.d.ts +14 -0
- data/assets/mermaid/defaultConfig.d.ts +12 -0
- data/assets/mermaid/diagram-api/comments.d.ts +6 -0
- data/assets/mermaid/diagram-api/comments.spec.d.ts +1 -0
- data/assets/mermaid/diagram-api/detectType.d.ts +42 -0
- data/assets/mermaid/diagram-api/diagram-orchestration.d.ts +1 -0
- data/assets/mermaid/diagram-api/diagram-orchestration.spec.d.ts +1 -0
- data/assets/mermaid/diagram-api/diagramAPI.d.ts +31 -0
- data/assets/mermaid/diagram-api/diagramAPI.spec.d.ts +1 -0
- data/assets/mermaid/diagram-api/frontmatter.d.ts +18 -0
- data/assets/mermaid/diagram-api/frontmatter.spec.d.ts +1 -0
- data/assets/mermaid/diagram-api/loadDiagram.d.ts +1 -0
- data/assets/mermaid/diagram-api/regexes.d.ts +3 -0
- data/assets/mermaid/diagram-api/types.d.ts +84 -0
- data/assets/mermaid/diagram.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/block/blockDB.d.ts +54 -0
- data/assets/mermaid/diagrams/block/blockDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/block/blockDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/block/blockRenderer.d.ts +15 -0
- data/assets/mermaid/diagrams/block/blockTypes.d.ts +36 -0
- data/assets/mermaid/diagrams/block/blockUtils.d.ts +1 -0
- data/assets/mermaid/diagrams/block/layout.d.ts +13 -0
- data/assets/mermaid/diagrams/block/layout.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/block/parser/block.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/block/renderHelpers.d.ts +10 -0
- data/assets/mermaid/diagrams/block/styles.d.ts +18 -0
- data/assets/mermaid/diagrams/c4/c4Db.d.ts +127 -0
- data/assets/mermaid/diagrams/c4/c4Detector.d.ts +3 -0
- data/assets/mermaid/diagrams/c4/c4Diagram.d.ts +2 -0
- data/assets/mermaid/diagrams/c4/c4Renderer.d.ts +12 -0
- data/assets/mermaid/diagrams/c4/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/c4/svgDraw.d.ts +36 -0
- data/assets/mermaid/diagrams/class/classDb.d.ts +144 -0
- data/assets/mermaid/diagrams/class/classDetector-V2.d.ts +3 -0
- data/assets/mermaid/diagrams/class/classDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/class/classDiagram-v2.d.ts +2 -0
- data/assets/mermaid/diagrams/class/classDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/class/classDiagram.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/class/classRenderer-v2.d.ts +57 -0
- data/assets/mermaid/diagrams/class/classRenderer.d.ts +5 -0
- data/assets/mermaid/diagrams/class/classTypes.d.ts +78 -0
- data/assets/mermaid/diagrams/class/classTypes.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/class/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/class/svgDraw.d.ts +25 -0
- data/assets/mermaid/diagrams/common/common.d.ts +110 -0
- data/assets/mermaid/diagrams/common/common.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/common/commonDb.d.ts +7 -0
- data/assets/mermaid/diagrams/common/commonTypes.d.ts +51 -0
- data/assets/mermaid/diagrams/common/svgDrawCommon.d.ts +15 -0
- data/assets/mermaid/diagrams/er/erDb.d.ts +49 -0
- data/assets/mermaid/diagrams/er/erDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/er/erDiagram.d.ts +34 -0
- data/assets/mermaid/diagrams/er/erMarkers.d.ts +24 -0
- data/assets/mermaid/diagrams/er/erRenderer.d.ts +19 -0
- data/assets/mermaid/diagrams/er/erRenderer.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/er/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/error/errorDiagram.d.ts +3 -0
- data/assets/mermaid/diagrams/error/errorRenderer.d.ts +12 -0
- data/assets/mermaid/diagrams/flowchart/elk/detector.d.ts +3 -0
- data/assets/mermaid/diagrams/flowchart/elk/detector.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/flowchart/elk/flowRenderer-elk.d.ts +10 -0
- data/assets/mermaid/diagrams/flowchart/elk/flowchart-elk-definition.d.ts +10 -0
- data/assets/mermaid/diagrams/flowchart/elk/render-utils.d.ts +5 -0
- data/assets/mermaid/diagrams/flowchart/elk/render-utils.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/flowchart/elk/styles.d.ts +19 -0
- data/assets/mermaid/diagrams/flowchart/flowChartShapes.d.ts +9 -0
- data/assets/mermaid/diagrams/flowchart/flowDb.d.ts +87 -0
- data/assets/mermaid/diagrams/flowchart/flowDetector-v2.d.ts +3 -0
- data/assets/mermaid/diagrams/flowchart/flowDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/flowchart/flowDiagram-v2.d.ts +57 -0
- data/assets/mermaid/diagrams/flowchart/flowDiagram.d.ts +57 -0
- data/assets/mermaid/diagrams/flowchart/flowRenderer-v2.d.ts +13 -0
- data/assets/mermaid/diagrams/flowchart/flowRenderer.d.ts +13 -0
- data/assets/mermaid/diagrams/flowchart/styles.d.ts +18 -0
- data/assets/mermaid/diagrams/gantt/ganttDb.d.ts +106 -0
- data/assets/mermaid/diagrams/gantt/ganttDb.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/gantt/ganttDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/gantt/ganttDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/gantt/ganttRenderer.d.ts +7 -0
- data/assets/mermaid/diagrams/gantt/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/git/gitGraphAst.d.ts +61 -0
- data/assets/mermaid/diagrams/git/gitGraphDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/git/gitGraphDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/git/gitGraphRenderer.d.ts +5 -0
- data/assets/mermaid/diagrams/git/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/info/info.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/info/infoDb.d.ts +5 -0
- data/assets/mermaid/diagrams/info/infoDetector.d.ts +2 -0
- data/assets/mermaid/diagrams/info/infoDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/info/infoRenderer.d.ts +4 -0
- data/assets/mermaid/diagrams/info/infoTypes.d.ts +9 -0
- data/assets/mermaid/diagrams/mindmap/detector.d.ts +3 -0
- data/assets/mermaid/diagrams/mindmap/mindmap-definition.d.ts +2 -0
- data/assets/mermaid/diagrams/mindmap/mindmap.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/mindmap/mindmapDb.d.ts +30 -0
- data/assets/mermaid/diagrams/mindmap/mindmapRenderer.d.ts +21 -0
- data/assets/mermaid/diagrams/mindmap/mindmapTypes.d.ts +20 -0
- data/assets/mermaid/diagrams/mindmap/styles.d.ts +3 -0
- data/assets/mermaid/diagrams/mindmap/svgDraw.d.ts +13 -0
- data/assets/mermaid/diagrams/pie/pie.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/pie/pieDb.d.ts +6 -0
- data/assets/mermaid/diagrams/pie/pieDetector.d.ts +2 -0
- data/assets/mermaid/diagrams/pie/pieDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/pie/pieRenderer.d.ts +13 -0
- data/assets/mermaid/diagrams/pie/pieStyles.d.ts +3 -0
- data/assets/mermaid/diagrams/pie/pieTypes.d.ts +53 -0
- data/assets/mermaid/diagrams/quadrant-chart/parser/quadrant.jison.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/quadrant-chart/quadrantBuilder.d.ts +118 -0
- data/assets/mermaid/diagrams/quadrant-chart/quadrantDb.d.ts +38 -0
- data/assets/mermaid/diagrams/quadrant-chart/quadrantDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/quadrant-chart/quadrantDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/quadrant-chart/quadrantRenderer.d.ts +6 -0
- data/assets/mermaid/diagrams/requirement/requirementDb.d.ts +70 -0
- data/assets/mermaid/diagrams/requirement/requirementDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/requirement/requirementDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/requirement/requirementMarkers.d.ts +10 -0
- data/assets/mermaid/diagrams/requirement/requirementRenderer.d.ts +7 -0
- data/assets/mermaid/diagrams/requirement/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/sankey/parser/sankey.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/sankey/sankeyDB.d.ts +36 -0
- data/assets/mermaid/diagrams/sankey/sankeyDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/sankey/sankeyDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/sankey/sankeyRenderer.d.ts +14 -0
- data/assets/mermaid/diagrams/sankey/sankeyUtils.d.ts +1 -0
- data/assets/mermaid/diagrams/sequence/sequenceDb.d.ts +153 -0
- data/assets/mermaid/diagrams/sequence/sequenceDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/sequence/sequenceDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/sequence/sequenceRenderer.d.ts +202 -0
- data/assets/mermaid/diagrams/sequence/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/sequence/svgDraw.d.ts +73 -0
- data/assets/mermaid/diagrams/state/id-cache.d.ts +11 -0
- data/assets/mermaid/diagrams/state/shapes.d.ts +14 -0
- data/assets/mermaid/diagrams/state/stateCommon.d.ts +22 -0
- data/assets/mermaid/diagrams/state/stateDb.d.ts +91 -0
- data/assets/mermaid/diagrams/state/stateDetector-V2.d.ts +3 -0
- data/assets/mermaid/diagrams/state/stateDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/state/stateDiagram-v2.d.ts +2 -0
- data/assets/mermaid/diagrams/state/stateDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/state/stateRenderer-v2.d.ts +20 -0
- data/assets/mermaid/diagrams/state/stateRenderer.d.ts +7 -0
- data/assets/mermaid/diagrams/state/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/timeline/detector.d.ts +3 -0
- data/assets/mermaid/diagrams/timeline/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/timeline/svgDraw.d.ts +46 -0
- data/assets/mermaid/diagrams/timeline/timeline-definition.d.ts +10 -0
- data/assets/mermaid/diagrams/timeline/timelineDb.d.ts +20 -0
- data/assets/mermaid/diagrams/timeline/timelineRenderer.d.ts +19 -0
- data/assets/mermaid/diagrams/user-journey/journeyDb.d.ts +30 -0
- data/assets/mermaid/diagrams/user-journey/journeyDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/user-journey/journeyDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/user-journey/journeyRenderer.d.ts +30 -0
- data/assets/mermaid/diagrams/user-journey/styles.d.ts +2 -0
- data/assets/mermaid/diagrams/user-journey/svgDraw.d.ts +20 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/axis/bandAxis.d.ts +12 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/axis/baseAxis.d.ts +38 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/axis/index.d.ts +12 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/axis/linearAxis.d.ts +11 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/chartTitle.d.ts +16 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/plot/barPlot.d.ts +12 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/plot/index.d.ts +20 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/components/plot/linePlot.d.ts +11 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/index.d.ts +5 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/interfaces.d.ts +132 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/orchestrator.d.ts +12 -0
- data/assets/mermaid/diagrams/xychart/chartBuilder/textDimensionCalculator.d.ts +10 -0
- data/assets/mermaid/diagrams/xychart/parser/xychart.jison.spec.d.ts +1 -0
- data/assets/mermaid/diagrams/xychart/xychartDb.d.ts +40 -0
- data/assets/mermaid/diagrams/xychart/xychartDetector.d.ts +3 -0
- data/assets/mermaid/diagrams/xychart/xychartDiagram.d.ts +2 -0
- data/assets/mermaid/diagrams/xychart/xychartRenderer.d.ts +6 -0
- data/assets/mermaid/docs/vite.config.d.ts +2 -0
- data/assets/mermaid/edges-066a5561.js +1840 -0
- data/assets/mermaid/edges-16357fde.js +1083 -0
- data/assets/mermaid/edges-ce5cfb7c.js +1840 -0
- data/assets/mermaid/erDiagram-09d1c15f.js +1176 -0
- data/assets/mermaid/erDiagram-543717f2.js +1321 -0
- data/assets/mermaid/erDiagram-c7ff1bec.js +931 -0
- data/assets/mermaid/errors.d.ts +3 -0
- data/assets/mermaid/flowDb-9a89ea33.js +1126 -0
- data/assets/mermaid/flowDb-ba9bd7fa.js +1713 -0
- data/assets/mermaid/flowDb-c1833063.js +1714 -0
- data/assets/mermaid/flowDiagram-aadb13b0.js +797 -0
- data/assets/mermaid/flowDiagram-b222e15a.js +614 -0
- data/assets/mermaid/flowDiagram-b5e7ba30.js +1278 -0
- data/assets/mermaid/flowDiagram-v2-13329dc7.js +40 -0
- data/assets/mermaid/flowDiagram-v2-54711e03.js +32 -0
- data/assets/mermaid/flowDiagram-v2-f2119625.js +25 -0
- data/assets/mermaid/flowchart-elk-definition-2d49707c.js +93397 -0
- data/assets/mermaid/flowchart-elk-definition-ae0efee6.js +814 -0
- data/assets/mermaid/flowchart-elk-definition-cf813a97.js +48407 -0
- data/assets/mermaid/ganttDiagram-12cf43db.js +3445 -0
- data/assets/mermaid/ganttDiagram-3c2fde2b.js +2501 -0
- data/assets/mermaid/ganttDiagram-b62c793e.js +2061 -0
- data/assets/mermaid/gitGraphDiagram-942e62fe.js +1800 -0
- data/assets/mermaid/gitGraphDiagram-b9392a12.js +1790 -0
- data/assets/mermaid/gitGraphDiagram-c3a0619c.js +1264 -0
- data/assets/mermaid/graph-0ee63739.js +881 -0
- data/assets/mermaid/graph-fe24fab6.js +1285 -0
- data/assets/mermaid/index-01f381cb.js +622 -0
- data/assets/mermaid/index-bb6d8841.js +373 -0
- data/assets/mermaid/index-fc479858.js +663 -0
- data/assets/mermaid/infoDiagram-2f5c50c0.js +319 -0
- data/assets/mermaid/infoDiagram-94cd232f.js +520 -0
- data/assets/mermaid/infoDiagram-d0d5c9bd.js +510 -0
- data/assets/mermaid/init-cc95ec8e.js +16 -0
- data/assets/mermaid/init-f9637058.js +16 -0
- data/assets/mermaid/interactionDb.d.ts +2 -0
- data/assets/mermaid/journeyDiagram-14fe341a.js +804 -0
- data/assets/mermaid/journeyDiagram-6625b456.js +1191 -0
- data/assets/mermaid/journeyDiagram-b56e6921.js +1183 -0
- data/assets/mermaid/katex-d90b6d29.js +11624 -0
- data/assets/mermaid/katex-ffb0e8f1.js +14432 -0
- data/assets/mermaid/layout-163b9689.js +2314 -0
- data/assets/mermaid/layout-fd473db2.js +1536 -0
- data/assets/mermaid/line-24d93f1b.js +34 -0
- data/assets/mermaid/line-87f517ef.js +50 -0
- data/assets/mermaid/linear-0ad15847.js +595 -0
- data/assets/mermaid/linear-9bcf74c4.js +447 -0
- data/assets/mermaid/logger.d.ts +9 -0
- data/assets/mermaid/mermaid-6dc72991.js +6461 -0
- data/assets/mermaid/mermaid-9f2aa176.js +8112 -0
- data/assets/mermaid/mermaid-dcacb631.js +12793 -0
- data/assets/mermaid/mermaid.core.mjs +14 -0
- data/assets/mermaid/mermaid.d.ts +146 -0
- data/assets/mermaid/mermaid.esm.min.mjs +4 -0
- data/assets/mermaid/mermaid.esm.mjs +4 -0
- data/assets/mermaid/mermaid.js +195755 -0
- data/assets/mermaid/mermaid.min.js +2029 -0
- data/assets/mermaid/mermaid.spec.d.ts +1 -0
- data/assets/mermaid/mermaidAPI.d.ts +170 -0
- data/assets/mermaid/mermaidAPI.spec.d.ts +1 -0
- data/assets/mermaid/mindmap-definition-307c710a.js +1177 -0
- data/assets/mermaid/mindmap-definition-696ddea4.js +32342 -0
- data/assets/mermaid/mindmap-definition-9399c7e6.js +18760 -0
- data/assets/mermaid/ordinal-475e0c0c.js +82 -0
- data/assets/mermaid/ordinal-5695958c.js +65 -0
- data/assets/mermaid/path-39bad7e2.js +118 -0
- data/assets/mermaid/path-428ebac9.js +91 -0
- data/assets/mermaid/pieDiagram-828dae43.js +502 -0
- data/assets/mermaid/pieDiagram-bb1d19e5.js +722 -0
- data/assets/mermaid/pieDiagram-e854eaf0.js +772 -0
- data/assets/mermaid/preprocess.d.ts +10 -0
- data/assets/mermaid/quadrantDiagram-25a9848b.js +1199 -0
- data/assets/mermaid/quadrantDiagram-5fa00455.js +904 -0
- data/assets/mermaid/quadrantDiagram-c759a472.js +1207 -0
- data/assets/mermaid/rendering-util/createText.d.ts +11 -0
- data/assets/mermaid/rendering-util/handle-markdown-text.d.ts +6 -0
- data/assets/mermaid/rendering-util/handle-markdown-text.spec.d.ts +1 -0
- data/assets/mermaid/rendering-util/selectSvgElement.d.ts +8 -0
- data/assets/mermaid/rendering-util/splitText.d.ts +24 -0
- data/assets/mermaid/rendering-util/splitText.spec.d.ts +1 -0
- data/assets/mermaid/rendering-util/uid.d.ts +8 -0
- data/assets/mermaid/requirementDiagram-03163dc4.js +769 -0
- data/assets/mermaid/requirementDiagram-87253d64.js +1098 -0
- data/assets/mermaid/requirementDiagram-a721e157.js +1091 -0
- data/assets/mermaid/sankeyDiagram-33525efb.js +1198 -0
- data/assets/mermaid/sankeyDiagram-52ec8976.js +818 -0
- data/assets/mermaid/sankeyDiagram-707fac0f.js +660 -0
- data/assets/mermaid/sequenceDiagram-6894f283.js +3346 -0
- data/assets/mermaid/sequenceDiagram-9813c129.js +3336 -0
- data/assets/mermaid/sequenceDiagram-b517d154.js +2234 -0
- data/assets/mermaid/setupGraphViewbox.d.ts +3 -0
- data/assets/mermaid/stateDiagram-5dee940d.js +474 -0
- data/assets/mermaid/stateDiagram-5ec31577.js +467 -0
- data/assets/mermaid/stateDiagram-fca82b5b.js +275 -0
- data/assets/mermaid/stateDiagram-v2-1992cada.js +333 -0
- data/assets/mermaid/stateDiagram-v2-992e82a1.js +325 -0
- data/assets/mermaid/stateDiagram-v2-ed04200a.js +190 -0
- data/assets/mermaid/styles-0784dbeb.js +1363 -0
- data/assets/mermaid/styles-11e81fdd.js +1089 -0
- data/assets/mermaid/styles-36a1a2e8.js +1483 -0
- data/assets/mermaid/styles-483fbfea.js +509 -0
- data/assets/mermaid/styles-727cdd61.js +571 -0
- data/assets/mermaid/styles-b83b31c9.js +1484 -0
- data/assets/mermaid/styles-cacbff60.js +960 -0
- data/assets/mermaid/styles-e75131e4.js +433 -0
- data/assets/mermaid/styles-f80da881.js +1363 -0
- data/assets/mermaid/styles.d.ts +12 -0
- data/assets/mermaid/styles.spec.d.ts +1 -0
- data/assets/mermaid/svgDrawCommon-5e1cfd1d.js +101 -0
- data/assets/mermaid/svgDrawCommon-d6ab583c.js +100 -0
- data/assets/mermaid/svgDrawCommon-ecc5f780.js +64 -0
- data/assets/mermaid/tests/MockedD3.d.ts +45 -0
- data/assets/mermaid/tests/setup.d.ts +1 -0
- data/assets/mermaid/tests/util.d.ts +3 -0
- data/assets/mermaid/themes/erDiagram-oldHardcodedValues.d.ts +7 -0
- data/assets/mermaid/themes/index.d.ts +24 -0
- data/assets/mermaid/themes/theme-base.d.ts +189 -0
- data/assets/mermaid/themes/theme-dark.d.ts +177 -0
- data/assets/mermaid/themes/theme-default.d.ts +188 -0
- data/assets/mermaid/themes/theme-forest.d.ts +185 -0
- data/assets/mermaid/themes/theme-helpers.d.ts +1 -0
- data/assets/mermaid/themes/theme-neutral.d.ts +182 -0
- data/assets/mermaid/timeline-definition-23ce0e2e.js +1211 -0
- data/assets/mermaid/timeline-definition-4ee9bff4.js +795 -0
- data/assets/mermaid/timeline-definition-bf702344.js +1219 -0
- data/assets/mermaid/types.d.ts +31 -0
- data/assets/mermaid/utils/imperativeState.d.ts +32 -0
- data/assets/mermaid/utils/imperativeState.spec.d.ts +1 -0
- data/assets/mermaid/utils/lineWithOffset.d.ts +5 -0
- data/assets/mermaid/utils/sanitizeDirective.d.ts +7 -0
- data/assets/mermaid/utils/subGraphTitleMargins.d.ts +8 -0
- data/assets/mermaid/utils/subGraphTitleMargins.spec.d.ts +1 -0
- data/assets/mermaid/utils.d.ts +286 -0
- data/assets/mermaid/utils.spec.d.ts +1 -0
- data/assets/mermaid/xychartDiagram-de2e5521.js +1800 -0
- data/assets/mermaid/xychartDiagram-e5e6b652.js +1284 -0
- data/assets/mermaid/xychartDiagram-f11f50a6.js +1745 -0
- data/assets/tables.css +23 -0
- data/assets/toURI.js +142 -0
- metadata +363 -2
@@ -0,0 +1,4929 @@
|
|
1
|
+
import { b8 as dedent, l as log, b7 as decodeEntities } from "./mermaid-dcacb631.js";
|
2
|
+
const emptyOptions = {};
|
3
|
+
function toString(value, options) {
|
4
|
+
const settings = options || emptyOptions;
|
5
|
+
const includeImageAlt = typeof settings.includeImageAlt === "boolean" ? settings.includeImageAlt : true;
|
6
|
+
const includeHtml = typeof settings.includeHtml === "boolean" ? settings.includeHtml : true;
|
7
|
+
return one(value, includeImageAlt, includeHtml);
|
8
|
+
}
|
9
|
+
function one(value, includeImageAlt, includeHtml) {
|
10
|
+
if (node(value)) {
|
11
|
+
if ("value" in value) {
|
12
|
+
return value.type === "html" && !includeHtml ? "" : value.value;
|
13
|
+
}
|
14
|
+
if (includeImageAlt && "alt" in value && value.alt) {
|
15
|
+
return value.alt;
|
16
|
+
}
|
17
|
+
if ("children" in value) {
|
18
|
+
return all(value.children, includeImageAlt, includeHtml);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
if (Array.isArray(value)) {
|
22
|
+
return all(value, includeImageAlt, includeHtml);
|
23
|
+
}
|
24
|
+
return "";
|
25
|
+
}
|
26
|
+
function all(values, includeImageAlt, includeHtml) {
|
27
|
+
const result = [];
|
28
|
+
let index2 = -1;
|
29
|
+
while (++index2 < values.length) {
|
30
|
+
result[index2] = one(values[index2], includeImageAlt, includeHtml);
|
31
|
+
}
|
32
|
+
return result.join("");
|
33
|
+
}
|
34
|
+
function node(value) {
|
35
|
+
return Boolean(value && typeof value === "object");
|
36
|
+
}
|
37
|
+
function splice(list2, start, remove, items) {
|
38
|
+
const end = list2.length;
|
39
|
+
let chunkStart = 0;
|
40
|
+
let parameters;
|
41
|
+
if (start < 0) {
|
42
|
+
start = -start > end ? 0 : end + start;
|
43
|
+
} else {
|
44
|
+
start = start > end ? end : start;
|
45
|
+
}
|
46
|
+
remove = remove > 0 ? remove : 0;
|
47
|
+
if (items.length < 1e4) {
|
48
|
+
parameters = Array.from(items);
|
49
|
+
parameters.unshift(start, remove);
|
50
|
+
list2.splice(...parameters);
|
51
|
+
} else {
|
52
|
+
if (remove)
|
53
|
+
list2.splice(start, remove);
|
54
|
+
while (chunkStart < items.length) {
|
55
|
+
parameters = items.slice(chunkStart, chunkStart + 1e4);
|
56
|
+
parameters.unshift(start, 0);
|
57
|
+
list2.splice(...parameters);
|
58
|
+
chunkStart += 1e4;
|
59
|
+
start += 1e4;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
function push(list2, items) {
|
64
|
+
if (list2.length > 0) {
|
65
|
+
splice(list2, list2.length, 0, items);
|
66
|
+
return list2;
|
67
|
+
}
|
68
|
+
return items;
|
69
|
+
}
|
70
|
+
const hasOwnProperty = {}.hasOwnProperty;
|
71
|
+
function combineExtensions(extensions) {
|
72
|
+
const all2 = {};
|
73
|
+
let index2 = -1;
|
74
|
+
while (++index2 < extensions.length) {
|
75
|
+
syntaxExtension(all2, extensions[index2]);
|
76
|
+
}
|
77
|
+
return all2;
|
78
|
+
}
|
79
|
+
function syntaxExtension(all2, extension2) {
|
80
|
+
let hook;
|
81
|
+
for (hook in extension2) {
|
82
|
+
const maybe = hasOwnProperty.call(all2, hook) ? all2[hook] : void 0;
|
83
|
+
const left = maybe || (all2[hook] = {});
|
84
|
+
const right = extension2[hook];
|
85
|
+
let code;
|
86
|
+
if (right) {
|
87
|
+
for (code in right) {
|
88
|
+
if (!hasOwnProperty.call(left, code))
|
89
|
+
left[code] = [];
|
90
|
+
const value = right[code];
|
91
|
+
constructs(
|
92
|
+
// @ts-expect-error Looks like a list.
|
93
|
+
left[code],
|
94
|
+
Array.isArray(value) ? value : value ? [value] : []
|
95
|
+
);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
function constructs(existing, list2) {
|
101
|
+
let index2 = -1;
|
102
|
+
const before = [];
|
103
|
+
while (++index2 < list2.length) {
|
104
|
+
(list2[index2].add === "after" ? existing : before).push(list2[index2]);
|
105
|
+
}
|
106
|
+
splice(existing, 0, 0, before);
|
107
|
+
}
|
108
|
+
const unicodePunctuationRegex = /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;
|
109
|
+
const asciiAlpha = regexCheck(/[A-Za-z]/);
|
110
|
+
const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
|
111
|
+
const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
|
112
|
+
function asciiControl(code) {
|
113
|
+
return (
|
114
|
+
// Special whitespace codes (which have negative values), C0 and Control
|
115
|
+
// character DEL
|
116
|
+
code !== null && (code < 32 || code === 127)
|
117
|
+
);
|
118
|
+
}
|
119
|
+
const asciiDigit = regexCheck(/\d/);
|
120
|
+
const asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
|
121
|
+
const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
|
122
|
+
function markdownLineEnding(code) {
|
123
|
+
return code !== null && code < -2;
|
124
|
+
}
|
125
|
+
function markdownLineEndingOrSpace(code) {
|
126
|
+
return code !== null && (code < 0 || code === 32);
|
127
|
+
}
|
128
|
+
function markdownSpace(code) {
|
129
|
+
return code === -2 || code === -1 || code === 32;
|
130
|
+
}
|
131
|
+
const unicodePunctuation = regexCheck(unicodePunctuationRegex);
|
132
|
+
const unicodeWhitespace = regexCheck(/\s/);
|
133
|
+
function regexCheck(regex) {
|
134
|
+
return check;
|
135
|
+
function check(code) {
|
136
|
+
return code !== null && regex.test(String.fromCharCode(code));
|
137
|
+
}
|
138
|
+
}
|
139
|
+
function factorySpace(effects, ok, type, max) {
|
140
|
+
const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
|
141
|
+
let size = 0;
|
142
|
+
return start;
|
143
|
+
function start(code) {
|
144
|
+
if (markdownSpace(code)) {
|
145
|
+
effects.enter(type);
|
146
|
+
return prefix(code);
|
147
|
+
}
|
148
|
+
return ok(code);
|
149
|
+
}
|
150
|
+
function prefix(code) {
|
151
|
+
if (markdownSpace(code) && size++ < limit) {
|
152
|
+
effects.consume(code);
|
153
|
+
return prefix;
|
154
|
+
}
|
155
|
+
effects.exit(type);
|
156
|
+
return ok(code);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
const content$1 = {
|
160
|
+
tokenize: initializeContent
|
161
|
+
};
|
162
|
+
function initializeContent(effects) {
|
163
|
+
const contentStart = effects.attempt(
|
164
|
+
this.parser.constructs.contentInitial,
|
165
|
+
afterContentStartConstruct,
|
166
|
+
paragraphInitial
|
167
|
+
);
|
168
|
+
let previous2;
|
169
|
+
return contentStart;
|
170
|
+
function afterContentStartConstruct(code) {
|
171
|
+
if (code === null) {
|
172
|
+
effects.consume(code);
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
effects.enter("lineEnding");
|
176
|
+
effects.consume(code);
|
177
|
+
effects.exit("lineEnding");
|
178
|
+
return factorySpace(effects, contentStart, "linePrefix");
|
179
|
+
}
|
180
|
+
function paragraphInitial(code) {
|
181
|
+
effects.enter("paragraph");
|
182
|
+
return lineStart(code);
|
183
|
+
}
|
184
|
+
function lineStart(code) {
|
185
|
+
const token = effects.enter("chunkText", {
|
186
|
+
contentType: "text",
|
187
|
+
previous: previous2
|
188
|
+
});
|
189
|
+
if (previous2) {
|
190
|
+
previous2.next = token;
|
191
|
+
}
|
192
|
+
previous2 = token;
|
193
|
+
return data(code);
|
194
|
+
}
|
195
|
+
function data(code) {
|
196
|
+
if (code === null) {
|
197
|
+
effects.exit("chunkText");
|
198
|
+
effects.exit("paragraph");
|
199
|
+
effects.consume(code);
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
if (markdownLineEnding(code)) {
|
203
|
+
effects.consume(code);
|
204
|
+
effects.exit("chunkText");
|
205
|
+
return lineStart;
|
206
|
+
}
|
207
|
+
effects.consume(code);
|
208
|
+
return data;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
const document$2 = {
|
212
|
+
tokenize: initializeDocument
|
213
|
+
};
|
214
|
+
const containerConstruct = {
|
215
|
+
tokenize: tokenizeContainer
|
216
|
+
};
|
217
|
+
function initializeDocument(effects) {
|
218
|
+
const self = this;
|
219
|
+
const stack = [];
|
220
|
+
let continued = 0;
|
221
|
+
let childFlow;
|
222
|
+
let childToken;
|
223
|
+
let lineStartOffset;
|
224
|
+
return start;
|
225
|
+
function start(code) {
|
226
|
+
if (continued < stack.length) {
|
227
|
+
const item = stack[continued];
|
228
|
+
self.containerState = item[1];
|
229
|
+
return effects.attempt(
|
230
|
+
item[0].continuation,
|
231
|
+
documentContinue,
|
232
|
+
checkNewContainers
|
233
|
+
)(code);
|
234
|
+
}
|
235
|
+
return checkNewContainers(code);
|
236
|
+
}
|
237
|
+
function documentContinue(code) {
|
238
|
+
continued++;
|
239
|
+
if (self.containerState._closeFlow) {
|
240
|
+
self.containerState._closeFlow = void 0;
|
241
|
+
if (childFlow) {
|
242
|
+
closeFlow();
|
243
|
+
}
|
244
|
+
const indexBeforeExits = self.events.length;
|
245
|
+
let indexBeforeFlow = indexBeforeExits;
|
246
|
+
let point2;
|
247
|
+
while (indexBeforeFlow--) {
|
248
|
+
if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
|
249
|
+
point2 = self.events[indexBeforeFlow][1].end;
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
exitContainers(continued);
|
254
|
+
let index2 = indexBeforeExits;
|
255
|
+
while (index2 < self.events.length) {
|
256
|
+
self.events[index2][1].end = Object.assign({}, point2);
|
257
|
+
index2++;
|
258
|
+
}
|
259
|
+
splice(
|
260
|
+
self.events,
|
261
|
+
indexBeforeFlow + 1,
|
262
|
+
0,
|
263
|
+
self.events.slice(indexBeforeExits)
|
264
|
+
);
|
265
|
+
self.events.length = index2;
|
266
|
+
return checkNewContainers(code);
|
267
|
+
}
|
268
|
+
return start(code);
|
269
|
+
}
|
270
|
+
function checkNewContainers(code) {
|
271
|
+
if (continued === stack.length) {
|
272
|
+
if (!childFlow) {
|
273
|
+
return documentContinued(code);
|
274
|
+
}
|
275
|
+
if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {
|
276
|
+
return flowStart(code);
|
277
|
+
}
|
278
|
+
self.interrupt = Boolean(
|
279
|
+
childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack
|
280
|
+
);
|
281
|
+
}
|
282
|
+
self.containerState = {};
|
283
|
+
return effects.check(
|
284
|
+
containerConstruct,
|
285
|
+
thereIsANewContainer,
|
286
|
+
thereIsNoNewContainer
|
287
|
+
)(code);
|
288
|
+
}
|
289
|
+
function thereIsANewContainer(code) {
|
290
|
+
if (childFlow)
|
291
|
+
closeFlow();
|
292
|
+
exitContainers(continued);
|
293
|
+
return documentContinued(code);
|
294
|
+
}
|
295
|
+
function thereIsNoNewContainer(code) {
|
296
|
+
self.parser.lazy[self.now().line] = continued !== stack.length;
|
297
|
+
lineStartOffset = self.now().offset;
|
298
|
+
return flowStart(code);
|
299
|
+
}
|
300
|
+
function documentContinued(code) {
|
301
|
+
self.containerState = {};
|
302
|
+
return effects.attempt(
|
303
|
+
containerConstruct,
|
304
|
+
containerContinue,
|
305
|
+
flowStart
|
306
|
+
)(code);
|
307
|
+
}
|
308
|
+
function containerContinue(code) {
|
309
|
+
continued++;
|
310
|
+
stack.push([self.currentConstruct, self.containerState]);
|
311
|
+
return documentContinued(code);
|
312
|
+
}
|
313
|
+
function flowStart(code) {
|
314
|
+
if (code === null) {
|
315
|
+
if (childFlow)
|
316
|
+
closeFlow();
|
317
|
+
exitContainers(0);
|
318
|
+
effects.consume(code);
|
319
|
+
return;
|
320
|
+
}
|
321
|
+
childFlow = childFlow || self.parser.flow(self.now());
|
322
|
+
effects.enter("chunkFlow", {
|
323
|
+
contentType: "flow",
|
324
|
+
previous: childToken,
|
325
|
+
_tokenizer: childFlow
|
326
|
+
});
|
327
|
+
return flowContinue(code);
|
328
|
+
}
|
329
|
+
function flowContinue(code) {
|
330
|
+
if (code === null) {
|
331
|
+
writeToChild(effects.exit("chunkFlow"), true);
|
332
|
+
exitContainers(0);
|
333
|
+
effects.consume(code);
|
334
|
+
return;
|
335
|
+
}
|
336
|
+
if (markdownLineEnding(code)) {
|
337
|
+
effects.consume(code);
|
338
|
+
writeToChild(effects.exit("chunkFlow"));
|
339
|
+
continued = 0;
|
340
|
+
self.interrupt = void 0;
|
341
|
+
return start;
|
342
|
+
}
|
343
|
+
effects.consume(code);
|
344
|
+
return flowContinue;
|
345
|
+
}
|
346
|
+
function writeToChild(token, eof) {
|
347
|
+
const stream = self.sliceStream(token);
|
348
|
+
if (eof)
|
349
|
+
stream.push(null);
|
350
|
+
token.previous = childToken;
|
351
|
+
if (childToken)
|
352
|
+
childToken.next = token;
|
353
|
+
childToken = token;
|
354
|
+
childFlow.defineSkip(token.start);
|
355
|
+
childFlow.write(stream);
|
356
|
+
if (self.parser.lazy[token.start.line]) {
|
357
|
+
let index2 = childFlow.events.length;
|
358
|
+
while (index2--) {
|
359
|
+
if (
|
360
|
+
// The token starts before the line ending…
|
361
|
+
childFlow.events[index2][1].start.offset < lineStartOffset && // …and either is not ended yet…
|
362
|
+
(!childFlow.events[index2][1].end || // …or ends after it.
|
363
|
+
childFlow.events[index2][1].end.offset > lineStartOffset)
|
364
|
+
) {
|
365
|
+
return;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
const indexBeforeExits = self.events.length;
|
369
|
+
let indexBeforeFlow = indexBeforeExits;
|
370
|
+
let seen;
|
371
|
+
let point2;
|
372
|
+
while (indexBeforeFlow--) {
|
373
|
+
if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
|
374
|
+
if (seen) {
|
375
|
+
point2 = self.events[indexBeforeFlow][1].end;
|
376
|
+
break;
|
377
|
+
}
|
378
|
+
seen = true;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
exitContainers(continued);
|
382
|
+
index2 = indexBeforeExits;
|
383
|
+
while (index2 < self.events.length) {
|
384
|
+
self.events[index2][1].end = Object.assign({}, point2);
|
385
|
+
index2++;
|
386
|
+
}
|
387
|
+
splice(
|
388
|
+
self.events,
|
389
|
+
indexBeforeFlow + 1,
|
390
|
+
0,
|
391
|
+
self.events.slice(indexBeforeExits)
|
392
|
+
);
|
393
|
+
self.events.length = index2;
|
394
|
+
}
|
395
|
+
}
|
396
|
+
function exitContainers(size) {
|
397
|
+
let index2 = stack.length;
|
398
|
+
while (index2-- > size) {
|
399
|
+
const entry = stack[index2];
|
400
|
+
self.containerState = entry[1];
|
401
|
+
entry[0].exit.call(self, effects);
|
402
|
+
}
|
403
|
+
stack.length = size;
|
404
|
+
}
|
405
|
+
function closeFlow() {
|
406
|
+
childFlow.write([null]);
|
407
|
+
childToken = void 0;
|
408
|
+
childFlow = void 0;
|
409
|
+
self.containerState._closeFlow = void 0;
|
410
|
+
}
|
411
|
+
}
|
412
|
+
function tokenizeContainer(effects, ok, nok) {
|
413
|
+
return factorySpace(
|
414
|
+
effects,
|
415
|
+
effects.attempt(this.parser.constructs.document, ok, nok),
|
416
|
+
"linePrefix",
|
417
|
+
this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4
|
418
|
+
);
|
419
|
+
}
|
420
|
+
function classifyCharacter(code) {
|
421
|
+
if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {
|
422
|
+
return 1;
|
423
|
+
}
|
424
|
+
if (unicodePunctuation(code)) {
|
425
|
+
return 2;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
function resolveAll(constructs2, events, context) {
|
429
|
+
const called = [];
|
430
|
+
let index2 = -1;
|
431
|
+
while (++index2 < constructs2.length) {
|
432
|
+
const resolve = constructs2[index2].resolveAll;
|
433
|
+
if (resolve && !called.includes(resolve)) {
|
434
|
+
events = resolve(events, context);
|
435
|
+
called.push(resolve);
|
436
|
+
}
|
437
|
+
}
|
438
|
+
return events;
|
439
|
+
}
|
440
|
+
const attention = {
|
441
|
+
name: "attention",
|
442
|
+
tokenize: tokenizeAttention,
|
443
|
+
resolveAll: resolveAllAttention
|
444
|
+
};
|
445
|
+
function resolveAllAttention(events, context) {
|
446
|
+
let index2 = -1;
|
447
|
+
let open;
|
448
|
+
let group;
|
449
|
+
let text2;
|
450
|
+
let openingSequence;
|
451
|
+
let closingSequence;
|
452
|
+
let use;
|
453
|
+
let nextEvents;
|
454
|
+
let offset;
|
455
|
+
while (++index2 < events.length) {
|
456
|
+
if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
|
457
|
+
open = index2;
|
458
|
+
while (open--) {
|
459
|
+
if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && // If the markers are the same:
|
460
|
+
context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
|
461
|
+
if ((events[open][1]._close || events[index2][1]._open) && (events[index2][1].end.offset - events[index2][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index2][1].end.offset - events[index2][1].start.offset) % 3)) {
|
462
|
+
continue;
|
463
|
+
}
|
464
|
+
use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index2][1].end.offset - events[index2][1].start.offset > 1 ? 2 : 1;
|
465
|
+
const start = Object.assign({}, events[open][1].end);
|
466
|
+
const end = Object.assign({}, events[index2][1].start);
|
467
|
+
movePoint(start, -use);
|
468
|
+
movePoint(end, use);
|
469
|
+
openingSequence = {
|
470
|
+
type: use > 1 ? "strongSequence" : "emphasisSequence",
|
471
|
+
start,
|
472
|
+
end: Object.assign({}, events[open][1].end)
|
473
|
+
};
|
474
|
+
closingSequence = {
|
475
|
+
type: use > 1 ? "strongSequence" : "emphasisSequence",
|
476
|
+
start: Object.assign({}, events[index2][1].start),
|
477
|
+
end
|
478
|
+
};
|
479
|
+
text2 = {
|
480
|
+
type: use > 1 ? "strongText" : "emphasisText",
|
481
|
+
start: Object.assign({}, events[open][1].end),
|
482
|
+
end: Object.assign({}, events[index2][1].start)
|
483
|
+
};
|
484
|
+
group = {
|
485
|
+
type: use > 1 ? "strong" : "emphasis",
|
486
|
+
start: Object.assign({}, openingSequence.start),
|
487
|
+
end: Object.assign({}, closingSequence.end)
|
488
|
+
};
|
489
|
+
events[open][1].end = Object.assign({}, openingSequence.start);
|
490
|
+
events[index2][1].start = Object.assign({}, closingSequence.end);
|
491
|
+
nextEvents = [];
|
492
|
+
if (events[open][1].end.offset - events[open][1].start.offset) {
|
493
|
+
nextEvents = push(nextEvents, [
|
494
|
+
["enter", events[open][1], context],
|
495
|
+
["exit", events[open][1], context]
|
496
|
+
]);
|
497
|
+
}
|
498
|
+
nextEvents = push(nextEvents, [
|
499
|
+
["enter", group, context],
|
500
|
+
["enter", openingSequence, context],
|
501
|
+
["exit", openingSequence, context],
|
502
|
+
["enter", text2, context]
|
503
|
+
]);
|
504
|
+
nextEvents = push(
|
505
|
+
nextEvents,
|
506
|
+
resolveAll(
|
507
|
+
context.parser.constructs.insideSpan.null,
|
508
|
+
events.slice(open + 1, index2),
|
509
|
+
context
|
510
|
+
)
|
511
|
+
);
|
512
|
+
nextEvents = push(nextEvents, [
|
513
|
+
["exit", text2, context],
|
514
|
+
["enter", closingSequence, context],
|
515
|
+
["exit", closingSequence, context],
|
516
|
+
["exit", group, context]
|
517
|
+
]);
|
518
|
+
if (events[index2][1].end.offset - events[index2][1].start.offset) {
|
519
|
+
offset = 2;
|
520
|
+
nextEvents = push(nextEvents, [
|
521
|
+
["enter", events[index2][1], context],
|
522
|
+
["exit", events[index2][1], context]
|
523
|
+
]);
|
524
|
+
} else {
|
525
|
+
offset = 0;
|
526
|
+
}
|
527
|
+
splice(events, open - 1, index2 - open + 3, nextEvents);
|
528
|
+
index2 = open + nextEvents.length - offset - 2;
|
529
|
+
break;
|
530
|
+
}
|
531
|
+
}
|
532
|
+
}
|
533
|
+
}
|
534
|
+
index2 = -1;
|
535
|
+
while (++index2 < events.length) {
|
536
|
+
if (events[index2][1].type === "attentionSequence") {
|
537
|
+
events[index2][1].type = "data";
|
538
|
+
}
|
539
|
+
}
|
540
|
+
return events;
|
541
|
+
}
|
542
|
+
function tokenizeAttention(effects, ok) {
|
543
|
+
const attentionMarkers2 = this.parser.constructs.attentionMarkers.null;
|
544
|
+
const previous2 = this.previous;
|
545
|
+
const before = classifyCharacter(previous2);
|
546
|
+
let marker;
|
547
|
+
return start;
|
548
|
+
function start(code) {
|
549
|
+
marker = code;
|
550
|
+
effects.enter("attentionSequence");
|
551
|
+
return inside(code);
|
552
|
+
}
|
553
|
+
function inside(code) {
|
554
|
+
if (code === marker) {
|
555
|
+
effects.consume(code);
|
556
|
+
return inside;
|
557
|
+
}
|
558
|
+
const token = effects.exit("attentionSequence");
|
559
|
+
const after = classifyCharacter(code);
|
560
|
+
const open = !after || after === 2 && before || attentionMarkers2.includes(code);
|
561
|
+
const close = !before || before === 2 && after || attentionMarkers2.includes(previous2);
|
562
|
+
token._open = Boolean(marker === 42 ? open : open && (before || !close));
|
563
|
+
token._close = Boolean(marker === 42 ? close : close && (after || !open));
|
564
|
+
return ok(code);
|
565
|
+
}
|
566
|
+
}
|
567
|
+
function movePoint(point2, offset) {
|
568
|
+
point2.column += offset;
|
569
|
+
point2.offset += offset;
|
570
|
+
point2._bufferIndex += offset;
|
571
|
+
}
|
572
|
+
const autolink = {
|
573
|
+
name: "autolink",
|
574
|
+
tokenize: tokenizeAutolink
|
575
|
+
};
|
576
|
+
function tokenizeAutolink(effects, ok, nok) {
|
577
|
+
let size = 0;
|
578
|
+
return start;
|
579
|
+
function start(code) {
|
580
|
+
effects.enter("autolink");
|
581
|
+
effects.enter("autolinkMarker");
|
582
|
+
effects.consume(code);
|
583
|
+
effects.exit("autolinkMarker");
|
584
|
+
effects.enter("autolinkProtocol");
|
585
|
+
return open;
|
586
|
+
}
|
587
|
+
function open(code) {
|
588
|
+
if (asciiAlpha(code)) {
|
589
|
+
effects.consume(code);
|
590
|
+
return schemeOrEmailAtext;
|
591
|
+
}
|
592
|
+
return emailAtext(code);
|
593
|
+
}
|
594
|
+
function schemeOrEmailAtext(code) {
|
595
|
+
if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
|
596
|
+
size = 1;
|
597
|
+
return schemeInsideOrEmailAtext(code);
|
598
|
+
}
|
599
|
+
return emailAtext(code);
|
600
|
+
}
|
601
|
+
function schemeInsideOrEmailAtext(code) {
|
602
|
+
if (code === 58) {
|
603
|
+
effects.consume(code);
|
604
|
+
size = 0;
|
605
|
+
return urlInside;
|
606
|
+
}
|
607
|
+
if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
|
608
|
+
effects.consume(code);
|
609
|
+
return schemeInsideOrEmailAtext;
|
610
|
+
}
|
611
|
+
size = 0;
|
612
|
+
return emailAtext(code);
|
613
|
+
}
|
614
|
+
function urlInside(code) {
|
615
|
+
if (code === 62) {
|
616
|
+
effects.exit("autolinkProtocol");
|
617
|
+
effects.enter("autolinkMarker");
|
618
|
+
effects.consume(code);
|
619
|
+
effects.exit("autolinkMarker");
|
620
|
+
effects.exit("autolink");
|
621
|
+
return ok;
|
622
|
+
}
|
623
|
+
if (code === null || code === 32 || code === 60 || asciiControl(code)) {
|
624
|
+
return nok(code);
|
625
|
+
}
|
626
|
+
effects.consume(code);
|
627
|
+
return urlInside;
|
628
|
+
}
|
629
|
+
function emailAtext(code) {
|
630
|
+
if (code === 64) {
|
631
|
+
effects.consume(code);
|
632
|
+
return emailAtSignOrDot;
|
633
|
+
}
|
634
|
+
if (asciiAtext(code)) {
|
635
|
+
effects.consume(code);
|
636
|
+
return emailAtext;
|
637
|
+
}
|
638
|
+
return nok(code);
|
639
|
+
}
|
640
|
+
function emailAtSignOrDot(code) {
|
641
|
+
return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
|
642
|
+
}
|
643
|
+
function emailLabel(code) {
|
644
|
+
if (code === 46) {
|
645
|
+
effects.consume(code);
|
646
|
+
size = 0;
|
647
|
+
return emailAtSignOrDot;
|
648
|
+
}
|
649
|
+
if (code === 62) {
|
650
|
+
effects.exit("autolinkProtocol").type = "autolinkEmail";
|
651
|
+
effects.enter("autolinkMarker");
|
652
|
+
effects.consume(code);
|
653
|
+
effects.exit("autolinkMarker");
|
654
|
+
effects.exit("autolink");
|
655
|
+
return ok;
|
656
|
+
}
|
657
|
+
return emailValue(code);
|
658
|
+
}
|
659
|
+
function emailValue(code) {
|
660
|
+
if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
|
661
|
+
const next = code === 45 ? emailValue : emailLabel;
|
662
|
+
effects.consume(code);
|
663
|
+
return next;
|
664
|
+
}
|
665
|
+
return nok(code);
|
666
|
+
}
|
667
|
+
}
|
668
|
+
const blankLine = {
|
669
|
+
tokenize: tokenizeBlankLine,
|
670
|
+
partial: true
|
671
|
+
};
|
672
|
+
function tokenizeBlankLine(effects, ok, nok) {
|
673
|
+
return start;
|
674
|
+
function start(code) {
|
675
|
+
return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code);
|
676
|
+
}
|
677
|
+
function after(code) {
|
678
|
+
return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
|
679
|
+
}
|
680
|
+
}
|
681
|
+
const blockQuote = {
|
682
|
+
name: "blockQuote",
|
683
|
+
tokenize: tokenizeBlockQuoteStart,
|
684
|
+
continuation: {
|
685
|
+
tokenize: tokenizeBlockQuoteContinuation
|
686
|
+
},
|
687
|
+
exit
|
688
|
+
};
|
689
|
+
function tokenizeBlockQuoteStart(effects, ok, nok) {
|
690
|
+
const self = this;
|
691
|
+
return start;
|
692
|
+
function start(code) {
|
693
|
+
if (code === 62) {
|
694
|
+
const state = self.containerState;
|
695
|
+
if (!state.open) {
|
696
|
+
effects.enter("blockQuote", {
|
697
|
+
_container: true
|
698
|
+
});
|
699
|
+
state.open = true;
|
700
|
+
}
|
701
|
+
effects.enter("blockQuotePrefix");
|
702
|
+
effects.enter("blockQuoteMarker");
|
703
|
+
effects.consume(code);
|
704
|
+
effects.exit("blockQuoteMarker");
|
705
|
+
return after;
|
706
|
+
}
|
707
|
+
return nok(code);
|
708
|
+
}
|
709
|
+
function after(code) {
|
710
|
+
if (markdownSpace(code)) {
|
711
|
+
effects.enter("blockQuotePrefixWhitespace");
|
712
|
+
effects.consume(code);
|
713
|
+
effects.exit("blockQuotePrefixWhitespace");
|
714
|
+
effects.exit("blockQuotePrefix");
|
715
|
+
return ok;
|
716
|
+
}
|
717
|
+
effects.exit("blockQuotePrefix");
|
718
|
+
return ok(code);
|
719
|
+
}
|
720
|
+
}
|
721
|
+
function tokenizeBlockQuoteContinuation(effects, ok, nok) {
|
722
|
+
const self = this;
|
723
|
+
return contStart;
|
724
|
+
function contStart(code) {
|
725
|
+
if (markdownSpace(code)) {
|
726
|
+
return factorySpace(
|
727
|
+
effects,
|
728
|
+
contBefore,
|
729
|
+
"linePrefix",
|
730
|
+
self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4
|
731
|
+
)(code);
|
732
|
+
}
|
733
|
+
return contBefore(code);
|
734
|
+
}
|
735
|
+
function contBefore(code) {
|
736
|
+
return effects.attempt(blockQuote, ok, nok)(code);
|
737
|
+
}
|
738
|
+
}
|
739
|
+
function exit(effects) {
|
740
|
+
effects.exit("blockQuote");
|
741
|
+
}
|
742
|
+
const characterEscape = {
|
743
|
+
name: "characterEscape",
|
744
|
+
tokenize: tokenizeCharacterEscape
|
745
|
+
};
|
746
|
+
function tokenizeCharacterEscape(effects, ok, nok) {
|
747
|
+
return start;
|
748
|
+
function start(code) {
|
749
|
+
effects.enter("characterEscape");
|
750
|
+
effects.enter("escapeMarker");
|
751
|
+
effects.consume(code);
|
752
|
+
effects.exit("escapeMarker");
|
753
|
+
return inside;
|
754
|
+
}
|
755
|
+
function inside(code) {
|
756
|
+
if (asciiPunctuation(code)) {
|
757
|
+
effects.enter("characterEscapeValue");
|
758
|
+
effects.consume(code);
|
759
|
+
effects.exit("characterEscapeValue");
|
760
|
+
effects.exit("characterEscape");
|
761
|
+
return ok;
|
762
|
+
}
|
763
|
+
return nok(code);
|
764
|
+
}
|
765
|
+
}
|
766
|
+
const element = document.createElement("i");
|
767
|
+
function decodeNamedCharacterReference(value) {
|
768
|
+
const characterReference2 = "&" + value + ";";
|
769
|
+
element.innerHTML = characterReference2;
|
770
|
+
const char = element.textContent;
|
771
|
+
if (char.charCodeAt(char.length - 1) === 59 && value !== "semi") {
|
772
|
+
return false;
|
773
|
+
}
|
774
|
+
return char === characterReference2 ? false : char;
|
775
|
+
}
|
776
|
+
const characterReference = {
|
777
|
+
name: "characterReference",
|
778
|
+
tokenize: tokenizeCharacterReference
|
779
|
+
};
|
780
|
+
function tokenizeCharacterReference(effects, ok, nok) {
|
781
|
+
const self = this;
|
782
|
+
let size = 0;
|
783
|
+
let max;
|
784
|
+
let test;
|
785
|
+
return start;
|
786
|
+
function start(code) {
|
787
|
+
effects.enter("characterReference");
|
788
|
+
effects.enter("characterReferenceMarker");
|
789
|
+
effects.consume(code);
|
790
|
+
effects.exit("characterReferenceMarker");
|
791
|
+
return open;
|
792
|
+
}
|
793
|
+
function open(code) {
|
794
|
+
if (code === 35) {
|
795
|
+
effects.enter("characterReferenceMarkerNumeric");
|
796
|
+
effects.consume(code);
|
797
|
+
effects.exit("characterReferenceMarkerNumeric");
|
798
|
+
return numeric;
|
799
|
+
}
|
800
|
+
effects.enter("characterReferenceValue");
|
801
|
+
max = 31;
|
802
|
+
test = asciiAlphanumeric;
|
803
|
+
return value(code);
|
804
|
+
}
|
805
|
+
function numeric(code) {
|
806
|
+
if (code === 88 || code === 120) {
|
807
|
+
effects.enter("characterReferenceMarkerHexadecimal");
|
808
|
+
effects.consume(code);
|
809
|
+
effects.exit("characterReferenceMarkerHexadecimal");
|
810
|
+
effects.enter("characterReferenceValue");
|
811
|
+
max = 6;
|
812
|
+
test = asciiHexDigit;
|
813
|
+
return value;
|
814
|
+
}
|
815
|
+
effects.enter("characterReferenceValue");
|
816
|
+
max = 7;
|
817
|
+
test = asciiDigit;
|
818
|
+
return value(code);
|
819
|
+
}
|
820
|
+
function value(code) {
|
821
|
+
if (code === 59 && size) {
|
822
|
+
const token = effects.exit("characterReferenceValue");
|
823
|
+
if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) {
|
824
|
+
return nok(code);
|
825
|
+
}
|
826
|
+
effects.enter("characterReferenceMarker");
|
827
|
+
effects.consume(code);
|
828
|
+
effects.exit("characterReferenceMarker");
|
829
|
+
effects.exit("characterReference");
|
830
|
+
return ok;
|
831
|
+
}
|
832
|
+
if (test(code) && size++ < max) {
|
833
|
+
effects.consume(code);
|
834
|
+
return value;
|
835
|
+
}
|
836
|
+
return nok(code);
|
837
|
+
}
|
838
|
+
}
|
839
|
+
const nonLazyContinuation = {
|
840
|
+
tokenize: tokenizeNonLazyContinuation,
|
841
|
+
partial: true
|
842
|
+
};
|
843
|
+
const codeFenced = {
|
844
|
+
name: "codeFenced",
|
845
|
+
tokenize: tokenizeCodeFenced,
|
846
|
+
concrete: true
|
847
|
+
};
|
848
|
+
function tokenizeCodeFenced(effects, ok, nok) {
|
849
|
+
const self = this;
|
850
|
+
const closeStart = {
|
851
|
+
tokenize: tokenizeCloseStart,
|
852
|
+
partial: true
|
853
|
+
};
|
854
|
+
let initialPrefix = 0;
|
855
|
+
let sizeOpen = 0;
|
856
|
+
let marker;
|
857
|
+
return start;
|
858
|
+
function start(code) {
|
859
|
+
return beforeSequenceOpen(code);
|
860
|
+
}
|
861
|
+
function beforeSequenceOpen(code) {
|
862
|
+
const tail = self.events[self.events.length - 1];
|
863
|
+
initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
|
864
|
+
marker = code;
|
865
|
+
effects.enter("codeFenced");
|
866
|
+
effects.enter("codeFencedFence");
|
867
|
+
effects.enter("codeFencedFenceSequence");
|
868
|
+
return sequenceOpen(code);
|
869
|
+
}
|
870
|
+
function sequenceOpen(code) {
|
871
|
+
if (code === marker) {
|
872
|
+
sizeOpen++;
|
873
|
+
effects.consume(code);
|
874
|
+
return sequenceOpen;
|
875
|
+
}
|
876
|
+
if (sizeOpen < 3) {
|
877
|
+
return nok(code);
|
878
|
+
}
|
879
|
+
effects.exit("codeFencedFenceSequence");
|
880
|
+
return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code);
|
881
|
+
}
|
882
|
+
function infoBefore(code) {
|
883
|
+
if (code === null || markdownLineEnding(code)) {
|
884
|
+
effects.exit("codeFencedFence");
|
885
|
+
return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
|
886
|
+
}
|
887
|
+
effects.enter("codeFencedFenceInfo");
|
888
|
+
effects.enter("chunkString", {
|
889
|
+
contentType: "string"
|
890
|
+
});
|
891
|
+
return info(code);
|
892
|
+
}
|
893
|
+
function info(code) {
|
894
|
+
if (code === null || markdownLineEnding(code)) {
|
895
|
+
effects.exit("chunkString");
|
896
|
+
effects.exit("codeFencedFenceInfo");
|
897
|
+
return infoBefore(code);
|
898
|
+
}
|
899
|
+
if (markdownSpace(code)) {
|
900
|
+
effects.exit("chunkString");
|
901
|
+
effects.exit("codeFencedFenceInfo");
|
902
|
+
return factorySpace(effects, metaBefore, "whitespace")(code);
|
903
|
+
}
|
904
|
+
if (code === 96 && code === marker) {
|
905
|
+
return nok(code);
|
906
|
+
}
|
907
|
+
effects.consume(code);
|
908
|
+
return info;
|
909
|
+
}
|
910
|
+
function metaBefore(code) {
|
911
|
+
if (code === null || markdownLineEnding(code)) {
|
912
|
+
return infoBefore(code);
|
913
|
+
}
|
914
|
+
effects.enter("codeFencedFenceMeta");
|
915
|
+
effects.enter("chunkString", {
|
916
|
+
contentType: "string"
|
917
|
+
});
|
918
|
+
return meta(code);
|
919
|
+
}
|
920
|
+
function meta(code) {
|
921
|
+
if (code === null || markdownLineEnding(code)) {
|
922
|
+
effects.exit("chunkString");
|
923
|
+
effects.exit("codeFencedFenceMeta");
|
924
|
+
return infoBefore(code);
|
925
|
+
}
|
926
|
+
if (code === 96 && code === marker) {
|
927
|
+
return nok(code);
|
928
|
+
}
|
929
|
+
effects.consume(code);
|
930
|
+
return meta;
|
931
|
+
}
|
932
|
+
function atNonLazyBreak(code) {
|
933
|
+
return effects.attempt(closeStart, after, contentBefore)(code);
|
934
|
+
}
|
935
|
+
function contentBefore(code) {
|
936
|
+
effects.enter("lineEnding");
|
937
|
+
effects.consume(code);
|
938
|
+
effects.exit("lineEnding");
|
939
|
+
return contentStart;
|
940
|
+
}
|
941
|
+
function contentStart(code) {
|
942
|
+
return initialPrefix > 0 && markdownSpace(code) ? factorySpace(
|
943
|
+
effects,
|
944
|
+
beforeContentChunk,
|
945
|
+
"linePrefix",
|
946
|
+
initialPrefix + 1
|
947
|
+
)(code) : beforeContentChunk(code);
|
948
|
+
}
|
949
|
+
function beforeContentChunk(code) {
|
950
|
+
if (code === null || markdownLineEnding(code)) {
|
951
|
+
return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
|
952
|
+
}
|
953
|
+
effects.enter("codeFlowValue");
|
954
|
+
return contentChunk(code);
|
955
|
+
}
|
956
|
+
function contentChunk(code) {
|
957
|
+
if (code === null || markdownLineEnding(code)) {
|
958
|
+
effects.exit("codeFlowValue");
|
959
|
+
return beforeContentChunk(code);
|
960
|
+
}
|
961
|
+
effects.consume(code);
|
962
|
+
return contentChunk;
|
963
|
+
}
|
964
|
+
function after(code) {
|
965
|
+
effects.exit("codeFenced");
|
966
|
+
return ok(code);
|
967
|
+
}
|
968
|
+
function tokenizeCloseStart(effects2, ok2, nok2) {
|
969
|
+
let size = 0;
|
970
|
+
return startBefore;
|
971
|
+
function startBefore(code) {
|
972
|
+
effects2.enter("lineEnding");
|
973
|
+
effects2.consume(code);
|
974
|
+
effects2.exit("lineEnding");
|
975
|
+
return start2;
|
976
|
+
}
|
977
|
+
function start2(code) {
|
978
|
+
effects2.enter("codeFencedFence");
|
979
|
+
return markdownSpace(code) ? factorySpace(
|
980
|
+
effects2,
|
981
|
+
beforeSequenceClose,
|
982
|
+
"linePrefix",
|
983
|
+
self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4
|
984
|
+
)(code) : beforeSequenceClose(code);
|
985
|
+
}
|
986
|
+
function beforeSequenceClose(code) {
|
987
|
+
if (code === marker) {
|
988
|
+
effects2.enter("codeFencedFenceSequence");
|
989
|
+
return sequenceClose(code);
|
990
|
+
}
|
991
|
+
return nok2(code);
|
992
|
+
}
|
993
|
+
function sequenceClose(code) {
|
994
|
+
if (code === marker) {
|
995
|
+
size++;
|
996
|
+
effects2.consume(code);
|
997
|
+
return sequenceClose;
|
998
|
+
}
|
999
|
+
if (size >= sizeOpen) {
|
1000
|
+
effects2.exit("codeFencedFenceSequence");
|
1001
|
+
return markdownSpace(code) ? factorySpace(effects2, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code);
|
1002
|
+
}
|
1003
|
+
return nok2(code);
|
1004
|
+
}
|
1005
|
+
function sequenceCloseAfter(code) {
|
1006
|
+
if (code === null || markdownLineEnding(code)) {
|
1007
|
+
effects2.exit("codeFencedFence");
|
1008
|
+
return ok2(code);
|
1009
|
+
}
|
1010
|
+
return nok2(code);
|
1011
|
+
}
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
function tokenizeNonLazyContinuation(effects, ok, nok) {
|
1015
|
+
const self = this;
|
1016
|
+
return start;
|
1017
|
+
function start(code) {
|
1018
|
+
if (code === null) {
|
1019
|
+
return nok(code);
|
1020
|
+
}
|
1021
|
+
effects.enter("lineEnding");
|
1022
|
+
effects.consume(code);
|
1023
|
+
effects.exit("lineEnding");
|
1024
|
+
return lineStart;
|
1025
|
+
}
|
1026
|
+
function lineStart(code) {
|
1027
|
+
return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
|
1028
|
+
}
|
1029
|
+
}
|
1030
|
+
const codeIndented = {
|
1031
|
+
name: "codeIndented",
|
1032
|
+
tokenize: tokenizeCodeIndented
|
1033
|
+
};
|
1034
|
+
const furtherStart = {
|
1035
|
+
tokenize: tokenizeFurtherStart,
|
1036
|
+
partial: true
|
1037
|
+
};
|
1038
|
+
function tokenizeCodeIndented(effects, ok, nok) {
|
1039
|
+
const self = this;
|
1040
|
+
return start;
|
1041
|
+
function start(code) {
|
1042
|
+
effects.enter("codeIndented");
|
1043
|
+
return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code);
|
1044
|
+
}
|
1045
|
+
function afterPrefix(code) {
|
1046
|
+
const tail = self.events[self.events.length - 1];
|
1047
|
+
return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code);
|
1048
|
+
}
|
1049
|
+
function atBreak(code) {
|
1050
|
+
if (code === null) {
|
1051
|
+
return after(code);
|
1052
|
+
}
|
1053
|
+
if (markdownLineEnding(code)) {
|
1054
|
+
return effects.attempt(furtherStart, atBreak, after)(code);
|
1055
|
+
}
|
1056
|
+
effects.enter("codeFlowValue");
|
1057
|
+
return inside(code);
|
1058
|
+
}
|
1059
|
+
function inside(code) {
|
1060
|
+
if (code === null || markdownLineEnding(code)) {
|
1061
|
+
effects.exit("codeFlowValue");
|
1062
|
+
return atBreak(code);
|
1063
|
+
}
|
1064
|
+
effects.consume(code);
|
1065
|
+
return inside;
|
1066
|
+
}
|
1067
|
+
function after(code) {
|
1068
|
+
effects.exit("codeIndented");
|
1069
|
+
return ok(code);
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
function tokenizeFurtherStart(effects, ok, nok) {
|
1073
|
+
const self = this;
|
1074
|
+
return furtherStart2;
|
1075
|
+
function furtherStart2(code) {
|
1076
|
+
if (self.parser.lazy[self.now().line]) {
|
1077
|
+
return nok(code);
|
1078
|
+
}
|
1079
|
+
if (markdownLineEnding(code)) {
|
1080
|
+
effects.enter("lineEnding");
|
1081
|
+
effects.consume(code);
|
1082
|
+
effects.exit("lineEnding");
|
1083
|
+
return furtherStart2;
|
1084
|
+
}
|
1085
|
+
return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code);
|
1086
|
+
}
|
1087
|
+
function afterPrefix(code) {
|
1088
|
+
const tail = self.events[self.events.length - 1];
|
1089
|
+
return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart2(code) : nok(code);
|
1090
|
+
}
|
1091
|
+
}
|
1092
|
+
const codeText = {
|
1093
|
+
name: "codeText",
|
1094
|
+
tokenize: tokenizeCodeText,
|
1095
|
+
resolve: resolveCodeText,
|
1096
|
+
previous
|
1097
|
+
};
|
1098
|
+
function resolveCodeText(events) {
|
1099
|
+
let tailExitIndex = events.length - 4;
|
1100
|
+
let headEnterIndex = 3;
|
1101
|
+
let index2;
|
1102
|
+
let enter;
|
1103
|
+
if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
|
1104
|
+
index2 = headEnterIndex;
|
1105
|
+
while (++index2 < tailExitIndex) {
|
1106
|
+
if (events[index2][1].type === "codeTextData") {
|
1107
|
+
events[headEnterIndex][1].type = "codeTextPadding";
|
1108
|
+
events[tailExitIndex][1].type = "codeTextPadding";
|
1109
|
+
headEnterIndex += 2;
|
1110
|
+
tailExitIndex -= 2;
|
1111
|
+
break;
|
1112
|
+
}
|
1113
|
+
}
|
1114
|
+
}
|
1115
|
+
index2 = headEnterIndex - 1;
|
1116
|
+
tailExitIndex++;
|
1117
|
+
while (++index2 <= tailExitIndex) {
|
1118
|
+
if (enter === void 0) {
|
1119
|
+
if (index2 !== tailExitIndex && events[index2][1].type !== "lineEnding") {
|
1120
|
+
enter = index2;
|
1121
|
+
}
|
1122
|
+
} else if (index2 === tailExitIndex || events[index2][1].type === "lineEnding") {
|
1123
|
+
events[enter][1].type = "codeTextData";
|
1124
|
+
if (index2 !== enter + 2) {
|
1125
|
+
events[enter][1].end = events[index2 - 1][1].end;
|
1126
|
+
events.splice(enter + 2, index2 - enter - 2);
|
1127
|
+
tailExitIndex -= index2 - enter - 2;
|
1128
|
+
index2 = enter + 2;
|
1129
|
+
}
|
1130
|
+
enter = void 0;
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
return events;
|
1134
|
+
}
|
1135
|
+
function previous(code) {
|
1136
|
+
return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
|
1137
|
+
}
|
1138
|
+
function tokenizeCodeText(effects, ok, nok) {
|
1139
|
+
let sizeOpen = 0;
|
1140
|
+
let size;
|
1141
|
+
let token;
|
1142
|
+
return start;
|
1143
|
+
function start(code) {
|
1144
|
+
effects.enter("codeText");
|
1145
|
+
effects.enter("codeTextSequence");
|
1146
|
+
return sequenceOpen(code);
|
1147
|
+
}
|
1148
|
+
function sequenceOpen(code) {
|
1149
|
+
if (code === 96) {
|
1150
|
+
effects.consume(code);
|
1151
|
+
sizeOpen++;
|
1152
|
+
return sequenceOpen;
|
1153
|
+
}
|
1154
|
+
effects.exit("codeTextSequence");
|
1155
|
+
return between(code);
|
1156
|
+
}
|
1157
|
+
function between(code) {
|
1158
|
+
if (code === null) {
|
1159
|
+
return nok(code);
|
1160
|
+
}
|
1161
|
+
if (code === 32) {
|
1162
|
+
effects.enter("space");
|
1163
|
+
effects.consume(code);
|
1164
|
+
effects.exit("space");
|
1165
|
+
return between;
|
1166
|
+
}
|
1167
|
+
if (code === 96) {
|
1168
|
+
token = effects.enter("codeTextSequence");
|
1169
|
+
size = 0;
|
1170
|
+
return sequenceClose(code);
|
1171
|
+
}
|
1172
|
+
if (markdownLineEnding(code)) {
|
1173
|
+
effects.enter("lineEnding");
|
1174
|
+
effects.consume(code);
|
1175
|
+
effects.exit("lineEnding");
|
1176
|
+
return between;
|
1177
|
+
}
|
1178
|
+
effects.enter("codeTextData");
|
1179
|
+
return data(code);
|
1180
|
+
}
|
1181
|
+
function data(code) {
|
1182
|
+
if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {
|
1183
|
+
effects.exit("codeTextData");
|
1184
|
+
return between(code);
|
1185
|
+
}
|
1186
|
+
effects.consume(code);
|
1187
|
+
return data;
|
1188
|
+
}
|
1189
|
+
function sequenceClose(code) {
|
1190
|
+
if (code === 96) {
|
1191
|
+
effects.consume(code);
|
1192
|
+
size++;
|
1193
|
+
return sequenceClose;
|
1194
|
+
}
|
1195
|
+
if (size === sizeOpen) {
|
1196
|
+
effects.exit("codeTextSequence");
|
1197
|
+
effects.exit("codeText");
|
1198
|
+
return ok(code);
|
1199
|
+
}
|
1200
|
+
token.type = "codeTextData";
|
1201
|
+
return data(code);
|
1202
|
+
}
|
1203
|
+
}
|
1204
|
+
function subtokenize(events) {
|
1205
|
+
const jumps = {};
|
1206
|
+
let index2 = -1;
|
1207
|
+
let event;
|
1208
|
+
let lineIndex;
|
1209
|
+
let otherIndex;
|
1210
|
+
let otherEvent;
|
1211
|
+
let parameters;
|
1212
|
+
let subevents;
|
1213
|
+
let more;
|
1214
|
+
while (++index2 < events.length) {
|
1215
|
+
while (index2 in jumps) {
|
1216
|
+
index2 = jumps[index2];
|
1217
|
+
}
|
1218
|
+
event = events[index2];
|
1219
|
+
if (index2 && event[1].type === "chunkFlow" && events[index2 - 1][1].type === "listItemPrefix") {
|
1220
|
+
subevents = event[1]._tokenizer.events;
|
1221
|
+
otherIndex = 0;
|
1222
|
+
if (otherIndex < subevents.length && subevents[otherIndex][1].type === "lineEndingBlank") {
|
1223
|
+
otherIndex += 2;
|
1224
|
+
}
|
1225
|
+
if (otherIndex < subevents.length && subevents[otherIndex][1].type === "content") {
|
1226
|
+
while (++otherIndex < subevents.length) {
|
1227
|
+
if (subevents[otherIndex][1].type === "content") {
|
1228
|
+
break;
|
1229
|
+
}
|
1230
|
+
if (subevents[otherIndex][1].type === "chunkText") {
|
1231
|
+
subevents[otherIndex][1]._isInFirstContentOfListItem = true;
|
1232
|
+
otherIndex++;
|
1233
|
+
}
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
}
|
1237
|
+
if (event[0] === "enter") {
|
1238
|
+
if (event[1].contentType) {
|
1239
|
+
Object.assign(jumps, subcontent(events, index2));
|
1240
|
+
index2 = jumps[index2];
|
1241
|
+
more = true;
|
1242
|
+
}
|
1243
|
+
} else if (event[1]._container) {
|
1244
|
+
otherIndex = index2;
|
1245
|
+
lineIndex = void 0;
|
1246
|
+
while (otherIndex--) {
|
1247
|
+
otherEvent = events[otherIndex];
|
1248
|
+
if (otherEvent[1].type === "lineEnding" || otherEvent[1].type === "lineEndingBlank") {
|
1249
|
+
if (otherEvent[0] === "enter") {
|
1250
|
+
if (lineIndex) {
|
1251
|
+
events[lineIndex][1].type = "lineEndingBlank";
|
1252
|
+
}
|
1253
|
+
otherEvent[1].type = "lineEnding";
|
1254
|
+
lineIndex = otherIndex;
|
1255
|
+
}
|
1256
|
+
} else {
|
1257
|
+
break;
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
if (lineIndex) {
|
1261
|
+
event[1].end = Object.assign({}, events[lineIndex][1].start);
|
1262
|
+
parameters = events.slice(lineIndex, index2);
|
1263
|
+
parameters.unshift(event);
|
1264
|
+
splice(events, lineIndex, index2 - lineIndex + 1, parameters);
|
1265
|
+
}
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
return !more;
|
1269
|
+
}
|
1270
|
+
function subcontent(events, eventIndex) {
|
1271
|
+
const token = events[eventIndex][1];
|
1272
|
+
const context = events[eventIndex][2];
|
1273
|
+
let startPosition = eventIndex - 1;
|
1274
|
+
const startPositions = [];
|
1275
|
+
const tokenizer = token._tokenizer || context.parser[token.contentType](token.start);
|
1276
|
+
const childEvents = tokenizer.events;
|
1277
|
+
const jumps = [];
|
1278
|
+
const gaps = {};
|
1279
|
+
let stream;
|
1280
|
+
let previous2;
|
1281
|
+
let index2 = -1;
|
1282
|
+
let current = token;
|
1283
|
+
let adjust = 0;
|
1284
|
+
let start = 0;
|
1285
|
+
const breaks = [start];
|
1286
|
+
while (current) {
|
1287
|
+
while (events[++startPosition][1] !== current) {
|
1288
|
+
}
|
1289
|
+
startPositions.push(startPosition);
|
1290
|
+
if (!current._tokenizer) {
|
1291
|
+
stream = context.sliceStream(current);
|
1292
|
+
if (!current.next) {
|
1293
|
+
stream.push(null);
|
1294
|
+
}
|
1295
|
+
if (previous2) {
|
1296
|
+
tokenizer.defineSkip(current.start);
|
1297
|
+
}
|
1298
|
+
if (current._isInFirstContentOfListItem) {
|
1299
|
+
tokenizer._gfmTasklistFirstContentOfListItem = true;
|
1300
|
+
}
|
1301
|
+
tokenizer.write(stream);
|
1302
|
+
if (current._isInFirstContentOfListItem) {
|
1303
|
+
tokenizer._gfmTasklistFirstContentOfListItem = void 0;
|
1304
|
+
}
|
1305
|
+
}
|
1306
|
+
previous2 = current;
|
1307
|
+
current = current.next;
|
1308
|
+
}
|
1309
|
+
current = token;
|
1310
|
+
while (++index2 < childEvents.length) {
|
1311
|
+
if (
|
1312
|
+
// Find a void token that includes a break.
|
1313
|
+
childEvents[index2][0] === "exit" && childEvents[index2 - 1][0] === "enter" && childEvents[index2][1].type === childEvents[index2 - 1][1].type && childEvents[index2][1].start.line !== childEvents[index2][1].end.line
|
1314
|
+
) {
|
1315
|
+
start = index2 + 1;
|
1316
|
+
breaks.push(start);
|
1317
|
+
current._tokenizer = void 0;
|
1318
|
+
current.previous = void 0;
|
1319
|
+
current = current.next;
|
1320
|
+
}
|
1321
|
+
}
|
1322
|
+
tokenizer.events = [];
|
1323
|
+
if (current) {
|
1324
|
+
current._tokenizer = void 0;
|
1325
|
+
current.previous = void 0;
|
1326
|
+
} else {
|
1327
|
+
breaks.pop();
|
1328
|
+
}
|
1329
|
+
index2 = breaks.length;
|
1330
|
+
while (index2--) {
|
1331
|
+
const slice = childEvents.slice(breaks[index2], breaks[index2 + 1]);
|
1332
|
+
const start2 = startPositions.pop();
|
1333
|
+
jumps.unshift([start2, start2 + slice.length - 1]);
|
1334
|
+
splice(events, start2, 2, slice);
|
1335
|
+
}
|
1336
|
+
index2 = -1;
|
1337
|
+
while (++index2 < jumps.length) {
|
1338
|
+
gaps[adjust + jumps[index2][0]] = adjust + jumps[index2][1];
|
1339
|
+
adjust += jumps[index2][1] - jumps[index2][0] - 1;
|
1340
|
+
}
|
1341
|
+
return gaps;
|
1342
|
+
}
|
1343
|
+
const content = {
|
1344
|
+
tokenize: tokenizeContent,
|
1345
|
+
resolve: resolveContent
|
1346
|
+
};
|
1347
|
+
const continuationConstruct = {
|
1348
|
+
tokenize: tokenizeContinuation,
|
1349
|
+
partial: true
|
1350
|
+
};
|
1351
|
+
function resolveContent(events) {
|
1352
|
+
subtokenize(events);
|
1353
|
+
return events;
|
1354
|
+
}
|
1355
|
+
function tokenizeContent(effects, ok) {
|
1356
|
+
let previous2;
|
1357
|
+
return chunkStart;
|
1358
|
+
function chunkStart(code) {
|
1359
|
+
effects.enter("content");
|
1360
|
+
previous2 = effects.enter("chunkContent", {
|
1361
|
+
contentType: "content"
|
1362
|
+
});
|
1363
|
+
return chunkInside(code);
|
1364
|
+
}
|
1365
|
+
function chunkInside(code) {
|
1366
|
+
if (code === null) {
|
1367
|
+
return contentEnd(code);
|
1368
|
+
}
|
1369
|
+
if (markdownLineEnding(code)) {
|
1370
|
+
return effects.check(
|
1371
|
+
continuationConstruct,
|
1372
|
+
contentContinue,
|
1373
|
+
contentEnd
|
1374
|
+
)(code);
|
1375
|
+
}
|
1376
|
+
effects.consume(code);
|
1377
|
+
return chunkInside;
|
1378
|
+
}
|
1379
|
+
function contentEnd(code) {
|
1380
|
+
effects.exit("chunkContent");
|
1381
|
+
effects.exit("content");
|
1382
|
+
return ok(code);
|
1383
|
+
}
|
1384
|
+
function contentContinue(code) {
|
1385
|
+
effects.consume(code);
|
1386
|
+
effects.exit("chunkContent");
|
1387
|
+
previous2.next = effects.enter("chunkContent", {
|
1388
|
+
contentType: "content",
|
1389
|
+
previous: previous2
|
1390
|
+
});
|
1391
|
+
previous2 = previous2.next;
|
1392
|
+
return chunkInside;
|
1393
|
+
}
|
1394
|
+
}
|
1395
|
+
function tokenizeContinuation(effects, ok, nok) {
|
1396
|
+
const self = this;
|
1397
|
+
return startLookahead;
|
1398
|
+
function startLookahead(code) {
|
1399
|
+
effects.exit("chunkContent");
|
1400
|
+
effects.enter("lineEnding");
|
1401
|
+
effects.consume(code);
|
1402
|
+
effects.exit("lineEnding");
|
1403
|
+
return factorySpace(effects, prefixed, "linePrefix");
|
1404
|
+
}
|
1405
|
+
function prefixed(code) {
|
1406
|
+
if (code === null || markdownLineEnding(code)) {
|
1407
|
+
return nok(code);
|
1408
|
+
}
|
1409
|
+
const tail = self.events[self.events.length - 1];
|
1410
|
+
if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4) {
|
1411
|
+
return ok(code);
|
1412
|
+
}
|
1413
|
+
return effects.interrupt(self.parser.constructs.flow, nok, ok)(code);
|
1414
|
+
}
|
1415
|
+
}
|
1416
|
+
function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) {
|
1417
|
+
const limit = max || Number.POSITIVE_INFINITY;
|
1418
|
+
let balance = 0;
|
1419
|
+
return start;
|
1420
|
+
function start(code) {
|
1421
|
+
if (code === 60) {
|
1422
|
+
effects.enter(type);
|
1423
|
+
effects.enter(literalType);
|
1424
|
+
effects.enter(literalMarkerType);
|
1425
|
+
effects.consume(code);
|
1426
|
+
effects.exit(literalMarkerType);
|
1427
|
+
return enclosedBefore;
|
1428
|
+
}
|
1429
|
+
if (code === null || code === 32 || code === 41 || asciiControl(code)) {
|
1430
|
+
return nok(code);
|
1431
|
+
}
|
1432
|
+
effects.enter(type);
|
1433
|
+
effects.enter(rawType);
|
1434
|
+
effects.enter(stringType);
|
1435
|
+
effects.enter("chunkString", {
|
1436
|
+
contentType: "string"
|
1437
|
+
});
|
1438
|
+
return raw(code);
|
1439
|
+
}
|
1440
|
+
function enclosedBefore(code) {
|
1441
|
+
if (code === 62) {
|
1442
|
+
effects.enter(literalMarkerType);
|
1443
|
+
effects.consume(code);
|
1444
|
+
effects.exit(literalMarkerType);
|
1445
|
+
effects.exit(literalType);
|
1446
|
+
effects.exit(type);
|
1447
|
+
return ok;
|
1448
|
+
}
|
1449
|
+
effects.enter(stringType);
|
1450
|
+
effects.enter("chunkString", {
|
1451
|
+
contentType: "string"
|
1452
|
+
});
|
1453
|
+
return enclosed(code);
|
1454
|
+
}
|
1455
|
+
function enclosed(code) {
|
1456
|
+
if (code === 62) {
|
1457
|
+
effects.exit("chunkString");
|
1458
|
+
effects.exit(stringType);
|
1459
|
+
return enclosedBefore(code);
|
1460
|
+
}
|
1461
|
+
if (code === null || code === 60 || markdownLineEnding(code)) {
|
1462
|
+
return nok(code);
|
1463
|
+
}
|
1464
|
+
effects.consume(code);
|
1465
|
+
return code === 92 ? enclosedEscape : enclosed;
|
1466
|
+
}
|
1467
|
+
function enclosedEscape(code) {
|
1468
|
+
if (code === 60 || code === 62 || code === 92) {
|
1469
|
+
effects.consume(code);
|
1470
|
+
return enclosed;
|
1471
|
+
}
|
1472
|
+
return enclosed(code);
|
1473
|
+
}
|
1474
|
+
function raw(code) {
|
1475
|
+
if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) {
|
1476
|
+
effects.exit("chunkString");
|
1477
|
+
effects.exit(stringType);
|
1478
|
+
effects.exit(rawType);
|
1479
|
+
effects.exit(type);
|
1480
|
+
return ok(code);
|
1481
|
+
}
|
1482
|
+
if (balance < limit && code === 40) {
|
1483
|
+
effects.consume(code);
|
1484
|
+
balance++;
|
1485
|
+
return raw;
|
1486
|
+
}
|
1487
|
+
if (code === 41) {
|
1488
|
+
effects.consume(code);
|
1489
|
+
balance--;
|
1490
|
+
return raw;
|
1491
|
+
}
|
1492
|
+
if (code === null || code === 32 || code === 40 || asciiControl(code)) {
|
1493
|
+
return nok(code);
|
1494
|
+
}
|
1495
|
+
effects.consume(code);
|
1496
|
+
return code === 92 ? rawEscape : raw;
|
1497
|
+
}
|
1498
|
+
function rawEscape(code) {
|
1499
|
+
if (code === 40 || code === 41 || code === 92) {
|
1500
|
+
effects.consume(code);
|
1501
|
+
return raw;
|
1502
|
+
}
|
1503
|
+
return raw(code);
|
1504
|
+
}
|
1505
|
+
}
|
1506
|
+
function factoryLabel(effects, ok, nok, type, markerType, stringType) {
|
1507
|
+
const self = this;
|
1508
|
+
let size = 0;
|
1509
|
+
let seen;
|
1510
|
+
return start;
|
1511
|
+
function start(code) {
|
1512
|
+
effects.enter(type);
|
1513
|
+
effects.enter(markerType);
|
1514
|
+
effects.consume(code);
|
1515
|
+
effects.exit(markerType);
|
1516
|
+
effects.enter(stringType);
|
1517
|
+
return atBreak;
|
1518
|
+
}
|
1519
|
+
function atBreak(code) {
|
1520
|
+
if (size > 999 || code === null || code === 91 || code === 93 && !seen || // To do: remove in the future once we’ve switched from
|
1521
|
+
// `micromark-extension-footnote` to `micromark-extension-gfm-footnote`,
|
1522
|
+
// which doesn’t need this.
|
1523
|
+
// Hidden footnotes hook.
|
1524
|
+
/* c8 ignore next 3 */
|
1525
|
+
code === 94 && !size && "_hiddenFootnoteSupport" in self.parser.constructs) {
|
1526
|
+
return nok(code);
|
1527
|
+
}
|
1528
|
+
if (code === 93) {
|
1529
|
+
effects.exit(stringType);
|
1530
|
+
effects.enter(markerType);
|
1531
|
+
effects.consume(code);
|
1532
|
+
effects.exit(markerType);
|
1533
|
+
effects.exit(type);
|
1534
|
+
return ok;
|
1535
|
+
}
|
1536
|
+
if (markdownLineEnding(code)) {
|
1537
|
+
effects.enter("lineEnding");
|
1538
|
+
effects.consume(code);
|
1539
|
+
effects.exit("lineEnding");
|
1540
|
+
return atBreak;
|
1541
|
+
}
|
1542
|
+
effects.enter("chunkString", {
|
1543
|
+
contentType: "string"
|
1544
|
+
});
|
1545
|
+
return labelInside(code);
|
1546
|
+
}
|
1547
|
+
function labelInside(code) {
|
1548
|
+
if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) {
|
1549
|
+
effects.exit("chunkString");
|
1550
|
+
return atBreak(code);
|
1551
|
+
}
|
1552
|
+
effects.consume(code);
|
1553
|
+
if (!seen)
|
1554
|
+
seen = !markdownSpace(code);
|
1555
|
+
return code === 92 ? labelEscape : labelInside;
|
1556
|
+
}
|
1557
|
+
function labelEscape(code) {
|
1558
|
+
if (code === 91 || code === 92 || code === 93) {
|
1559
|
+
effects.consume(code);
|
1560
|
+
size++;
|
1561
|
+
return labelInside;
|
1562
|
+
}
|
1563
|
+
return labelInside(code);
|
1564
|
+
}
|
1565
|
+
}
|
1566
|
+
function factoryTitle(effects, ok, nok, type, markerType, stringType) {
|
1567
|
+
let marker;
|
1568
|
+
return start;
|
1569
|
+
function start(code) {
|
1570
|
+
if (code === 34 || code === 39 || code === 40) {
|
1571
|
+
effects.enter(type);
|
1572
|
+
effects.enter(markerType);
|
1573
|
+
effects.consume(code);
|
1574
|
+
effects.exit(markerType);
|
1575
|
+
marker = code === 40 ? 41 : code;
|
1576
|
+
return begin;
|
1577
|
+
}
|
1578
|
+
return nok(code);
|
1579
|
+
}
|
1580
|
+
function begin(code) {
|
1581
|
+
if (code === marker) {
|
1582
|
+
effects.enter(markerType);
|
1583
|
+
effects.consume(code);
|
1584
|
+
effects.exit(markerType);
|
1585
|
+
effects.exit(type);
|
1586
|
+
return ok;
|
1587
|
+
}
|
1588
|
+
effects.enter(stringType);
|
1589
|
+
return atBreak(code);
|
1590
|
+
}
|
1591
|
+
function atBreak(code) {
|
1592
|
+
if (code === marker) {
|
1593
|
+
effects.exit(stringType);
|
1594
|
+
return begin(marker);
|
1595
|
+
}
|
1596
|
+
if (code === null) {
|
1597
|
+
return nok(code);
|
1598
|
+
}
|
1599
|
+
if (markdownLineEnding(code)) {
|
1600
|
+
effects.enter("lineEnding");
|
1601
|
+
effects.consume(code);
|
1602
|
+
effects.exit("lineEnding");
|
1603
|
+
return factorySpace(effects, atBreak, "linePrefix");
|
1604
|
+
}
|
1605
|
+
effects.enter("chunkString", {
|
1606
|
+
contentType: "string"
|
1607
|
+
});
|
1608
|
+
return inside(code);
|
1609
|
+
}
|
1610
|
+
function inside(code) {
|
1611
|
+
if (code === marker || code === null || markdownLineEnding(code)) {
|
1612
|
+
effects.exit("chunkString");
|
1613
|
+
return atBreak(code);
|
1614
|
+
}
|
1615
|
+
effects.consume(code);
|
1616
|
+
return code === 92 ? escape : inside;
|
1617
|
+
}
|
1618
|
+
function escape(code) {
|
1619
|
+
if (code === marker || code === 92) {
|
1620
|
+
effects.consume(code);
|
1621
|
+
return inside;
|
1622
|
+
}
|
1623
|
+
return inside(code);
|
1624
|
+
}
|
1625
|
+
}
|
1626
|
+
function factoryWhitespace(effects, ok) {
|
1627
|
+
let seen;
|
1628
|
+
return start;
|
1629
|
+
function start(code) {
|
1630
|
+
if (markdownLineEnding(code)) {
|
1631
|
+
effects.enter("lineEnding");
|
1632
|
+
effects.consume(code);
|
1633
|
+
effects.exit("lineEnding");
|
1634
|
+
seen = true;
|
1635
|
+
return start;
|
1636
|
+
}
|
1637
|
+
if (markdownSpace(code)) {
|
1638
|
+
return factorySpace(
|
1639
|
+
effects,
|
1640
|
+
start,
|
1641
|
+
seen ? "linePrefix" : "lineSuffix"
|
1642
|
+
)(code);
|
1643
|
+
}
|
1644
|
+
return ok(code);
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
function normalizeIdentifier(value) {
|
1648
|
+
return value.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
|
1649
|
+
}
|
1650
|
+
const definition = {
|
1651
|
+
name: "definition",
|
1652
|
+
tokenize: tokenizeDefinition
|
1653
|
+
};
|
1654
|
+
const titleBefore = {
|
1655
|
+
tokenize: tokenizeTitleBefore,
|
1656
|
+
partial: true
|
1657
|
+
};
|
1658
|
+
function tokenizeDefinition(effects, ok, nok) {
|
1659
|
+
const self = this;
|
1660
|
+
let identifier;
|
1661
|
+
return start;
|
1662
|
+
function start(code) {
|
1663
|
+
effects.enter("definition");
|
1664
|
+
return before(code);
|
1665
|
+
}
|
1666
|
+
function before(code) {
|
1667
|
+
return factoryLabel.call(
|
1668
|
+
self,
|
1669
|
+
effects,
|
1670
|
+
labelAfter,
|
1671
|
+
// Note: we don’t need to reset the way `markdown-rs` does.
|
1672
|
+
nok,
|
1673
|
+
"definitionLabel",
|
1674
|
+
"definitionLabelMarker",
|
1675
|
+
"definitionLabelString"
|
1676
|
+
)(code);
|
1677
|
+
}
|
1678
|
+
function labelAfter(code) {
|
1679
|
+
identifier = normalizeIdentifier(
|
1680
|
+
self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1)
|
1681
|
+
);
|
1682
|
+
if (code === 58) {
|
1683
|
+
effects.enter("definitionMarker");
|
1684
|
+
effects.consume(code);
|
1685
|
+
effects.exit("definitionMarker");
|
1686
|
+
return markerAfter;
|
1687
|
+
}
|
1688
|
+
return nok(code);
|
1689
|
+
}
|
1690
|
+
function markerAfter(code) {
|
1691
|
+
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);
|
1692
|
+
}
|
1693
|
+
function destinationBefore(code) {
|
1694
|
+
return factoryDestination(
|
1695
|
+
effects,
|
1696
|
+
destinationAfter,
|
1697
|
+
// Note: we don’t need to reset the way `markdown-rs` does.
|
1698
|
+
nok,
|
1699
|
+
"definitionDestination",
|
1700
|
+
"definitionDestinationLiteral",
|
1701
|
+
"definitionDestinationLiteralMarker",
|
1702
|
+
"definitionDestinationRaw",
|
1703
|
+
"definitionDestinationString"
|
1704
|
+
)(code);
|
1705
|
+
}
|
1706
|
+
function destinationAfter(code) {
|
1707
|
+
return effects.attempt(titleBefore, after, after)(code);
|
1708
|
+
}
|
1709
|
+
function after(code) {
|
1710
|
+
return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code);
|
1711
|
+
}
|
1712
|
+
function afterWhitespace(code) {
|
1713
|
+
if (code === null || markdownLineEnding(code)) {
|
1714
|
+
effects.exit("definition");
|
1715
|
+
self.parser.defined.push(identifier);
|
1716
|
+
return ok(code);
|
1717
|
+
}
|
1718
|
+
return nok(code);
|
1719
|
+
}
|
1720
|
+
}
|
1721
|
+
function tokenizeTitleBefore(effects, ok, nok) {
|
1722
|
+
return titleBefore2;
|
1723
|
+
function titleBefore2(code) {
|
1724
|
+
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);
|
1725
|
+
}
|
1726
|
+
function beforeMarker(code) {
|
1727
|
+
return factoryTitle(
|
1728
|
+
effects,
|
1729
|
+
titleAfter,
|
1730
|
+
nok,
|
1731
|
+
"definitionTitle",
|
1732
|
+
"definitionTitleMarker",
|
1733
|
+
"definitionTitleString"
|
1734
|
+
)(code);
|
1735
|
+
}
|
1736
|
+
function titleAfter(code) {
|
1737
|
+
return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code);
|
1738
|
+
}
|
1739
|
+
function titleAfterOptionalWhitespace(code) {
|
1740
|
+
return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
|
1741
|
+
}
|
1742
|
+
}
|
1743
|
+
const hardBreakEscape = {
|
1744
|
+
name: "hardBreakEscape",
|
1745
|
+
tokenize: tokenizeHardBreakEscape
|
1746
|
+
};
|
1747
|
+
function tokenizeHardBreakEscape(effects, ok, nok) {
|
1748
|
+
return start;
|
1749
|
+
function start(code) {
|
1750
|
+
effects.enter("hardBreakEscape");
|
1751
|
+
effects.consume(code);
|
1752
|
+
return after;
|
1753
|
+
}
|
1754
|
+
function after(code) {
|
1755
|
+
if (markdownLineEnding(code)) {
|
1756
|
+
effects.exit("hardBreakEscape");
|
1757
|
+
return ok(code);
|
1758
|
+
}
|
1759
|
+
return nok(code);
|
1760
|
+
}
|
1761
|
+
}
|
1762
|
+
const headingAtx = {
|
1763
|
+
name: "headingAtx",
|
1764
|
+
tokenize: tokenizeHeadingAtx,
|
1765
|
+
resolve: resolveHeadingAtx
|
1766
|
+
};
|
1767
|
+
function resolveHeadingAtx(events, context) {
|
1768
|
+
let contentEnd = events.length - 2;
|
1769
|
+
let contentStart = 3;
|
1770
|
+
let content2;
|
1771
|
+
let text2;
|
1772
|
+
if (events[contentStart][1].type === "whitespace") {
|
1773
|
+
contentStart += 2;
|
1774
|
+
}
|
1775
|
+
if (contentEnd - 2 > contentStart && events[contentEnd][1].type === "whitespace") {
|
1776
|
+
contentEnd -= 2;
|
1777
|
+
}
|
1778
|
+
if (events[contentEnd][1].type === "atxHeadingSequence" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === "whitespace")) {
|
1779
|
+
contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
|
1780
|
+
}
|
1781
|
+
if (contentEnd > contentStart) {
|
1782
|
+
content2 = {
|
1783
|
+
type: "atxHeadingText",
|
1784
|
+
start: events[contentStart][1].start,
|
1785
|
+
end: events[contentEnd][1].end
|
1786
|
+
};
|
1787
|
+
text2 = {
|
1788
|
+
type: "chunkText",
|
1789
|
+
start: events[contentStart][1].start,
|
1790
|
+
end: events[contentEnd][1].end,
|
1791
|
+
contentType: "text"
|
1792
|
+
};
|
1793
|
+
splice(events, contentStart, contentEnd - contentStart + 1, [
|
1794
|
+
["enter", content2, context],
|
1795
|
+
["enter", text2, context],
|
1796
|
+
["exit", text2, context],
|
1797
|
+
["exit", content2, context]
|
1798
|
+
]);
|
1799
|
+
}
|
1800
|
+
return events;
|
1801
|
+
}
|
1802
|
+
function tokenizeHeadingAtx(effects, ok, nok) {
|
1803
|
+
let size = 0;
|
1804
|
+
return start;
|
1805
|
+
function start(code) {
|
1806
|
+
effects.enter("atxHeading");
|
1807
|
+
return before(code);
|
1808
|
+
}
|
1809
|
+
function before(code) {
|
1810
|
+
effects.enter("atxHeadingSequence");
|
1811
|
+
return sequenceOpen(code);
|
1812
|
+
}
|
1813
|
+
function sequenceOpen(code) {
|
1814
|
+
if (code === 35 && size++ < 6) {
|
1815
|
+
effects.consume(code);
|
1816
|
+
return sequenceOpen;
|
1817
|
+
}
|
1818
|
+
if (code === null || markdownLineEndingOrSpace(code)) {
|
1819
|
+
effects.exit("atxHeadingSequence");
|
1820
|
+
return atBreak(code);
|
1821
|
+
}
|
1822
|
+
return nok(code);
|
1823
|
+
}
|
1824
|
+
function atBreak(code) {
|
1825
|
+
if (code === 35) {
|
1826
|
+
effects.enter("atxHeadingSequence");
|
1827
|
+
return sequenceFurther(code);
|
1828
|
+
}
|
1829
|
+
if (code === null || markdownLineEnding(code)) {
|
1830
|
+
effects.exit("atxHeading");
|
1831
|
+
return ok(code);
|
1832
|
+
}
|
1833
|
+
if (markdownSpace(code)) {
|
1834
|
+
return factorySpace(effects, atBreak, "whitespace")(code);
|
1835
|
+
}
|
1836
|
+
effects.enter("atxHeadingText");
|
1837
|
+
return data(code);
|
1838
|
+
}
|
1839
|
+
function sequenceFurther(code) {
|
1840
|
+
if (code === 35) {
|
1841
|
+
effects.consume(code);
|
1842
|
+
return sequenceFurther;
|
1843
|
+
}
|
1844
|
+
effects.exit("atxHeadingSequence");
|
1845
|
+
return atBreak(code);
|
1846
|
+
}
|
1847
|
+
function data(code) {
|
1848
|
+
if (code === null || code === 35 || markdownLineEndingOrSpace(code)) {
|
1849
|
+
effects.exit("atxHeadingText");
|
1850
|
+
return atBreak(code);
|
1851
|
+
}
|
1852
|
+
effects.consume(code);
|
1853
|
+
return data;
|
1854
|
+
}
|
1855
|
+
}
|
1856
|
+
const htmlBlockNames = [
|
1857
|
+
"address",
|
1858
|
+
"article",
|
1859
|
+
"aside",
|
1860
|
+
"base",
|
1861
|
+
"basefont",
|
1862
|
+
"blockquote",
|
1863
|
+
"body",
|
1864
|
+
"caption",
|
1865
|
+
"center",
|
1866
|
+
"col",
|
1867
|
+
"colgroup",
|
1868
|
+
"dd",
|
1869
|
+
"details",
|
1870
|
+
"dialog",
|
1871
|
+
"dir",
|
1872
|
+
"div",
|
1873
|
+
"dl",
|
1874
|
+
"dt",
|
1875
|
+
"fieldset",
|
1876
|
+
"figcaption",
|
1877
|
+
"figure",
|
1878
|
+
"footer",
|
1879
|
+
"form",
|
1880
|
+
"frame",
|
1881
|
+
"frameset",
|
1882
|
+
"h1",
|
1883
|
+
"h2",
|
1884
|
+
"h3",
|
1885
|
+
"h4",
|
1886
|
+
"h5",
|
1887
|
+
"h6",
|
1888
|
+
"head",
|
1889
|
+
"header",
|
1890
|
+
"hr",
|
1891
|
+
"html",
|
1892
|
+
"iframe",
|
1893
|
+
"legend",
|
1894
|
+
"li",
|
1895
|
+
"link",
|
1896
|
+
"main",
|
1897
|
+
"menu",
|
1898
|
+
"menuitem",
|
1899
|
+
"nav",
|
1900
|
+
"noframes",
|
1901
|
+
"ol",
|
1902
|
+
"optgroup",
|
1903
|
+
"option",
|
1904
|
+
"p",
|
1905
|
+
"param",
|
1906
|
+
"search",
|
1907
|
+
"section",
|
1908
|
+
"summary",
|
1909
|
+
"table",
|
1910
|
+
"tbody",
|
1911
|
+
"td",
|
1912
|
+
"tfoot",
|
1913
|
+
"th",
|
1914
|
+
"thead",
|
1915
|
+
"title",
|
1916
|
+
"tr",
|
1917
|
+
"track",
|
1918
|
+
"ul"
|
1919
|
+
];
|
1920
|
+
const htmlRawNames = ["pre", "script", "style", "textarea"];
|
1921
|
+
const htmlFlow = {
|
1922
|
+
name: "htmlFlow",
|
1923
|
+
tokenize: tokenizeHtmlFlow,
|
1924
|
+
resolveTo: resolveToHtmlFlow,
|
1925
|
+
concrete: true
|
1926
|
+
};
|
1927
|
+
const blankLineBefore = {
|
1928
|
+
tokenize: tokenizeBlankLineBefore,
|
1929
|
+
partial: true
|
1930
|
+
};
|
1931
|
+
const nonLazyContinuationStart = {
|
1932
|
+
tokenize: tokenizeNonLazyContinuationStart,
|
1933
|
+
partial: true
|
1934
|
+
};
|
1935
|
+
function resolveToHtmlFlow(events) {
|
1936
|
+
let index2 = events.length;
|
1937
|
+
while (index2--) {
|
1938
|
+
if (events[index2][0] === "enter" && events[index2][1].type === "htmlFlow") {
|
1939
|
+
break;
|
1940
|
+
}
|
1941
|
+
}
|
1942
|
+
if (index2 > 1 && events[index2 - 2][1].type === "linePrefix") {
|
1943
|
+
events[index2][1].start = events[index2 - 2][1].start;
|
1944
|
+
events[index2 + 1][1].start = events[index2 - 2][1].start;
|
1945
|
+
events.splice(index2 - 2, 2);
|
1946
|
+
}
|
1947
|
+
return events;
|
1948
|
+
}
|
1949
|
+
function tokenizeHtmlFlow(effects, ok, nok) {
|
1950
|
+
const self = this;
|
1951
|
+
let marker;
|
1952
|
+
let closingTag;
|
1953
|
+
let buffer;
|
1954
|
+
let index2;
|
1955
|
+
let markerB;
|
1956
|
+
return start;
|
1957
|
+
function start(code) {
|
1958
|
+
return before(code);
|
1959
|
+
}
|
1960
|
+
function before(code) {
|
1961
|
+
effects.enter("htmlFlow");
|
1962
|
+
effects.enter("htmlFlowData");
|
1963
|
+
effects.consume(code);
|
1964
|
+
return open;
|
1965
|
+
}
|
1966
|
+
function open(code) {
|
1967
|
+
if (code === 33) {
|
1968
|
+
effects.consume(code);
|
1969
|
+
return declarationOpen;
|
1970
|
+
}
|
1971
|
+
if (code === 47) {
|
1972
|
+
effects.consume(code);
|
1973
|
+
closingTag = true;
|
1974
|
+
return tagCloseStart;
|
1975
|
+
}
|
1976
|
+
if (code === 63) {
|
1977
|
+
effects.consume(code);
|
1978
|
+
marker = 3;
|
1979
|
+
return self.interrupt ? ok : continuationDeclarationInside;
|
1980
|
+
}
|
1981
|
+
if (asciiAlpha(code)) {
|
1982
|
+
effects.consume(code);
|
1983
|
+
buffer = String.fromCharCode(code);
|
1984
|
+
return tagName;
|
1985
|
+
}
|
1986
|
+
return nok(code);
|
1987
|
+
}
|
1988
|
+
function declarationOpen(code) {
|
1989
|
+
if (code === 45) {
|
1990
|
+
effects.consume(code);
|
1991
|
+
marker = 2;
|
1992
|
+
return commentOpenInside;
|
1993
|
+
}
|
1994
|
+
if (code === 91) {
|
1995
|
+
effects.consume(code);
|
1996
|
+
marker = 5;
|
1997
|
+
index2 = 0;
|
1998
|
+
return cdataOpenInside;
|
1999
|
+
}
|
2000
|
+
if (asciiAlpha(code)) {
|
2001
|
+
effects.consume(code);
|
2002
|
+
marker = 4;
|
2003
|
+
return self.interrupt ? ok : continuationDeclarationInside;
|
2004
|
+
}
|
2005
|
+
return nok(code);
|
2006
|
+
}
|
2007
|
+
function commentOpenInside(code) {
|
2008
|
+
if (code === 45) {
|
2009
|
+
effects.consume(code);
|
2010
|
+
return self.interrupt ? ok : continuationDeclarationInside;
|
2011
|
+
}
|
2012
|
+
return nok(code);
|
2013
|
+
}
|
2014
|
+
function cdataOpenInside(code) {
|
2015
|
+
const value = "CDATA[";
|
2016
|
+
if (code === value.charCodeAt(index2++)) {
|
2017
|
+
effects.consume(code);
|
2018
|
+
if (index2 === value.length) {
|
2019
|
+
return self.interrupt ? ok : continuation;
|
2020
|
+
}
|
2021
|
+
return cdataOpenInside;
|
2022
|
+
}
|
2023
|
+
return nok(code);
|
2024
|
+
}
|
2025
|
+
function tagCloseStart(code) {
|
2026
|
+
if (asciiAlpha(code)) {
|
2027
|
+
effects.consume(code);
|
2028
|
+
buffer = String.fromCharCode(code);
|
2029
|
+
return tagName;
|
2030
|
+
}
|
2031
|
+
return nok(code);
|
2032
|
+
}
|
2033
|
+
function tagName(code) {
|
2034
|
+
if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
|
2035
|
+
const slash = code === 47;
|
2036
|
+
const name = buffer.toLowerCase();
|
2037
|
+
if (!slash && !closingTag && htmlRawNames.includes(name)) {
|
2038
|
+
marker = 1;
|
2039
|
+
return self.interrupt ? ok(code) : continuation(code);
|
2040
|
+
}
|
2041
|
+
if (htmlBlockNames.includes(buffer.toLowerCase())) {
|
2042
|
+
marker = 6;
|
2043
|
+
if (slash) {
|
2044
|
+
effects.consume(code);
|
2045
|
+
return basicSelfClosing;
|
2046
|
+
}
|
2047
|
+
return self.interrupt ? ok(code) : continuation(code);
|
2048
|
+
}
|
2049
|
+
marker = 7;
|
2050
|
+
return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
|
2051
|
+
}
|
2052
|
+
if (code === 45 || asciiAlphanumeric(code)) {
|
2053
|
+
effects.consume(code);
|
2054
|
+
buffer += String.fromCharCode(code);
|
2055
|
+
return tagName;
|
2056
|
+
}
|
2057
|
+
return nok(code);
|
2058
|
+
}
|
2059
|
+
function basicSelfClosing(code) {
|
2060
|
+
if (code === 62) {
|
2061
|
+
effects.consume(code);
|
2062
|
+
return self.interrupt ? ok : continuation;
|
2063
|
+
}
|
2064
|
+
return nok(code);
|
2065
|
+
}
|
2066
|
+
function completeClosingTagAfter(code) {
|
2067
|
+
if (markdownSpace(code)) {
|
2068
|
+
effects.consume(code);
|
2069
|
+
return completeClosingTagAfter;
|
2070
|
+
}
|
2071
|
+
return completeEnd(code);
|
2072
|
+
}
|
2073
|
+
function completeAttributeNameBefore(code) {
|
2074
|
+
if (code === 47) {
|
2075
|
+
effects.consume(code);
|
2076
|
+
return completeEnd;
|
2077
|
+
}
|
2078
|
+
if (code === 58 || code === 95 || asciiAlpha(code)) {
|
2079
|
+
effects.consume(code);
|
2080
|
+
return completeAttributeName;
|
2081
|
+
}
|
2082
|
+
if (markdownSpace(code)) {
|
2083
|
+
effects.consume(code);
|
2084
|
+
return completeAttributeNameBefore;
|
2085
|
+
}
|
2086
|
+
return completeEnd(code);
|
2087
|
+
}
|
2088
|
+
function completeAttributeName(code) {
|
2089
|
+
if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
|
2090
|
+
effects.consume(code);
|
2091
|
+
return completeAttributeName;
|
2092
|
+
}
|
2093
|
+
return completeAttributeNameAfter(code);
|
2094
|
+
}
|
2095
|
+
function completeAttributeNameAfter(code) {
|
2096
|
+
if (code === 61) {
|
2097
|
+
effects.consume(code);
|
2098
|
+
return completeAttributeValueBefore;
|
2099
|
+
}
|
2100
|
+
if (markdownSpace(code)) {
|
2101
|
+
effects.consume(code);
|
2102
|
+
return completeAttributeNameAfter;
|
2103
|
+
}
|
2104
|
+
return completeAttributeNameBefore(code);
|
2105
|
+
}
|
2106
|
+
function completeAttributeValueBefore(code) {
|
2107
|
+
if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {
|
2108
|
+
return nok(code);
|
2109
|
+
}
|
2110
|
+
if (code === 34 || code === 39) {
|
2111
|
+
effects.consume(code);
|
2112
|
+
markerB = code;
|
2113
|
+
return completeAttributeValueQuoted;
|
2114
|
+
}
|
2115
|
+
if (markdownSpace(code)) {
|
2116
|
+
effects.consume(code);
|
2117
|
+
return completeAttributeValueBefore;
|
2118
|
+
}
|
2119
|
+
return completeAttributeValueUnquoted(code);
|
2120
|
+
}
|
2121
|
+
function completeAttributeValueQuoted(code) {
|
2122
|
+
if (code === markerB) {
|
2123
|
+
effects.consume(code);
|
2124
|
+
markerB = null;
|
2125
|
+
return completeAttributeValueQuotedAfter;
|
2126
|
+
}
|
2127
|
+
if (code === null || markdownLineEnding(code)) {
|
2128
|
+
return nok(code);
|
2129
|
+
}
|
2130
|
+
effects.consume(code);
|
2131
|
+
return completeAttributeValueQuoted;
|
2132
|
+
}
|
2133
|
+
function completeAttributeValueUnquoted(code) {
|
2134
|
+
if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) {
|
2135
|
+
return completeAttributeNameAfter(code);
|
2136
|
+
}
|
2137
|
+
effects.consume(code);
|
2138
|
+
return completeAttributeValueUnquoted;
|
2139
|
+
}
|
2140
|
+
function completeAttributeValueQuotedAfter(code) {
|
2141
|
+
if (code === 47 || code === 62 || markdownSpace(code)) {
|
2142
|
+
return completeAttributeNameBefore(code);
|
2143
|
+
}
|
2144
|
+
return nok(code);
|
2145
|
+
}
|
2146
|
+
function completeEnd(code) {
|
2147
|
+
if (code === 62) {
|
2148
|
+
effects.consume(code);
|
2149
|
+
return completeAfter;
|
2150
|
+
}
|
2151
|
+
return nok(code);
|
2152
|
+
}
|
2153
|
+
function completeAfter(code) {
|
2154
|
+
if (code === null || markdownLineEnding(code)) {
|
2155
|
+
return continuation(code);
|
2156
|
+
}
|
2157
|
+
if (markdownSpace(code)) {
|
2158
|
+
effects.consume(code);
|
2159
|
+
return completeAfter;
|
2160
|
+
}
|
2161
|
+
return nok(code);
|
2162
|
+
}
|
2163
|
+
function continuation(code) {
|
2164
|
+
if (code === 45 && marker === 2) {
|
2165
|
+
effects.consume(code);
|
2166
|
+
return continuationCommentInside;
|
2167
|
+
}
|
2168
|
+
if (code === 60 && marker === 1) {
|
2169
|
+
effects.consume(code);
|
2170
|
+
return continuationRawTagOpen;
|
2171
|
+
}
|
2172
|
+
if (code === 62 && marker === 4) {
|
2173
|
+
effects.consume(code);
|
2174
|
+
return continuationClose;
|
2175
|
+
}
|
2176
|
+
if (code === 63 && marker === 3) {
|
2177
|
+
effects.consume(code);
|
2178
|
+
return continuationDeclarationInside;
|
2179
|
+
}
|
2180
|
+
if (code === 93 && marker === 5) {
|
2181
|
+
effects.consume(code);
|
2182
|
+
return continuationCdataInside;
|
2183
|
+
}
|
2184
|
+
if (markdownLineEnding(code) && (marker === 6 || marker === 7)) {
|
2185
|
+
effects.exit("htmlFlowData");
|
2186
|
+
return effects.check(
|
2187
|
+
blankLineBefore,
|
2188
|
+
continuationAfter,
|
2189
|
+
continuationStart
|
2190
|
+
)(code);
|
2191
|
+
}
|
2192
|
+
if (code === null || markdownLineEnding(code)) {
|
2193
|
+
effects.exit("htmlFlowData");
|
2194
|
+
return continuationStart(code);
|
2195
|
+
}
|
2196
|
+
effects.consume(code);
|
2197
|
+
return continuation;
|
2198
|
+
}
|
2199
|
+
function continuationStart(code) {
|
2200
|
+
return effects.check(
|
2201
|
+
nonLazyContinuationStart,
|
2202
|
+
continuationStartNonLazy,
|
2203
|
+
continuationAfter
|
2204
|
+
)(code);
|
2205
|
+
}
|
2206
|
+
function continuationStartNonLazy(code) {
|
2207
|
+
effects.enter("lineEnding");
|
2208
|
+
effects.consume(code);
|
2209
|
+
effects.exit("lineEnding");
|
2210
|
+
return continuationBefore;
|
2211
|
+
}
|
2212
|
+
function continuationBefore(code) {
|
2213
|
+
if (code === null || markdownLineEnding(code)) {
|
2214
|
+
return continuationStart(code);
|
2215
|
+
}
|
2216
|
+
effects.enter("htmlFlowData");
|
2217
|
+
return continuation(code);
|
2218
|
+
}
|
2219
|
+
function continuationCommentInside(code) {
|
2220
|
+
if (code === 45) {
|
2221
|
+
effects.consume(code);
|
2222
|
+
return continuationDeclarationInside;
|
2223
|
+
}
|
2224
|
+
return continuation(code);
|
2225
|
+
}
|
2226
|
+
function continuationRawTagOpen(code) {
|
2227
|
+
if (code === 47) {
|
2228
|
+
effects.consume(code);
|
2229
|
+
buffer = "";
|
2230
|
+
return continuationRawEndTag;
|
2231
|
+
}
|
2232
|
+
return continuation(code);
|
2233
|
+
}
|
2234
|
+
function continuationRawEndTag(code) {
|
2235
|
+
if (code === 62) {
|
2236
|
+
const name = buffer.toLowerCase();
|
2237
|
+
if (htmlRawNames.includes(name)) {
|
2238
|
+
effects.consume(code);
|
2239
|
+
return continuationClose;
|
2240
|
+
}
|
2241
|
+
return continuation(code);
|
2242
|
+
}
|
2243
|
+
if (asciiAlpha(code) && buffer.length < 8) {
|
2244
|
+
effects.consume(code);
|
2245
|
+
buffer += String.fromCharCode(code);
|
2246
|
+
return continuationRawEndTag;
|
2247
|
+
}
|
2248
|
+
return continuation(code);
|
2249
|
+
}
|
2250
|
+
function continuationCdataInside(code) {
|
2251
|
+
if (code === 93) {
|
2252
|
+
effects.consume(code);
|
2253
|
+
return continuationDeclarationInside;
|
2254
|
+
}
|
2255
|
+
return continuation(code);
|
2256
|
+
}
|
2257
|
+
function continuationDeclarationInside(code) {
|
2258
|
+
if (code === 62) {
|
2259
|
+
effects.consume(code);
|
2260
|
+
return continuationClose;
|
2261
|
+
}
|
2262
|
+
if (code === 45 && marker === 2) {
|
2263
|
+
effects.consume(code);
|
2264
|
+
return continuationDeclarationInside;
|
2265
|
+
}
|
2266
|
+
return continuation(code);
|
2267
|
+
}
|
2268
|
+
function continuationClose(code) {
|
2269
|
+
if (code === null || markdownLineEnding(code)) {
|
2270
|
+
effects.exit("htmlFlowData");
|
2271
|
+
return continuationAfter(code);
|
2272
|
+
}
|
2273
|
+
effects.consume(code);
|
2274
|
+
return continuationClose;
|
2275
|
+
}
|
2276
|
+
function continuationAfter(code) {
|
2277
|
+
effects.exit("htmlFlow");
|
2278
|
+
return ok(code);
|
2279
|
+
}
|
2280
|
+
}
|
2281
|
+
function tokenizeNonLazyContinuationStart(effects, ok, nok) {
|
2282
|
+
const self = this;
|
2283
|
+
return start;
|
2284
|
+
function start(code) {
|
2285
|
+
if (markdownLineEnding(code)) {
|
2286
|
+
effects.enter("lineEnding");
|
2287
|
+
effects.consume(code);
|
2288
|
+
effects.exit("lineEnding");
|
2289
|
+
return after;
|
2290
|
+
}
|
2291
|
+
return nok(code);
|
2292
|
+
}
|
2293
|
+
function after(code) {
|
2294
|
+
return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
|
2295
|
+
}
|
2296
|
+
}
|
2297
|
+
function tokenizeBlankLineBefore(effects, ok, nok) {
|
2298
|
+
return start;
|
2299
|
+
function start(code) {
|
2300
|
+
effects.enter("lineEnding");
|
2301
|
+
effects.consume(code);
|
2302
|
+
effects.exit("lineEnding");
|
2303
|
+
return effects.attempt(blankLine, ok, nok);
|
2304
|
+
}
|
2305
|
+
}
|
2306
|
+
const htmlText = {
|
2307
|
+
name: "htmlText",
|
2308
|
+
tokenize: tokenizeHtmlText
|
2309
|
+
};
|
2310
|
+
function tokenizeHtmlText(effects, ok, nok) {
|
2311
|
+
const self = this;
|
2312
|
+
let marker;
|
2313
|
+
let index2;
|
2314
|
+
let returnState;
|
2315
|
+
return start;
|
2316
|
+
function start(code) {
|
2317
|
+
effects.enter("htmlText");
|
2318
|
+
effects.enter("htmlTextData");
|
2319
|
+
effects.consume(code);
|
2320
|
+
return open;
|
2321
|
+
}
|
2322
|
+
function open(code) {
|
2323
|
+
if (code === 33) {
|
2324
|
+
effects.consume(code);
|
2325
|
+
return declarationOpen;
|
2326
|
+
}
|
2327
|
+
if (code === 47) {
|
2328
|
+
effects.consume(code);
|
2329
|
+
return tagCloseStart;
|
2330
|
+
}
|
2331
|
+
if (code === 63) {
|
2332
|
+
effects.consume(code);
|
2333
|
+
return instruction;
|
2334
|
+
}
|
2335
|
+
if (asciiAlpha(code)) {
|
2336
|
+
effects.consume(code);
|
2337
|
+
return tagOpen;
|
2338
|
+
}
|
2339
|
+
return nok(code);
|
2340
|
+
}
|
2341
|
+
function declarationOpen(code) {
|
2342
|
+
if (code === 45) {
|
2343
|
+
effects.consume(code);
|
2344
|
+
return commentOpenInside;
|
2345
|
+
}
|
2346
|
+
if (code === 91) {
|
2347
|
+
effects.consume(code);
|
2348
|
+
index2 = 0;
|
2349
|
+
return cdataOpenInside;
|
2350
|
+
}
|
2351
|
+
if (asciiAlpha(code)) {
|
2352
|
+
effects.consume(code);
|
2353
|
+
return declaration;
|
2354
|
+
}
|
2355
|
+
return nok(code);
|
2356
|
+
}
|
2357
|
+
function commentOpenInside(code) {
|
2358
|
+
if (code === 45) {
|
2359
|
+
effects.consume(code);
|
2360
|
+
return commentEnd;
|
2361
|
+
}
|
2362
|
+
return nok(code);
|
2363
|
+
}
|
2364
|
+
function comment(code) {
|
2365
|
+
if (code === null) {
|
2366
|
+
return nok(code);
|
2367
|
+
}
|
2368
|
+
if (code === 45) {
|
2369
|
+
effects.consume(code);
|
2370
|
+
return commentClose;
|
2371
|
+
}
|
2372
|
+
if (markdownLineEnding(code)) {
|
2373
|
+
returnState = comment;
|
2374
|
+
return lineEndingBefore(code);
|
2375
|
+
}
|
2376
|
+
effects.consume(code);
|
2377
|
+
return comment;
|
2378
|
+
}
|
2379
|
+
function commentClose(code) {
|
2380
|
+
if (code === 45) {
|
2381
|
+
effects.consume(code);
|
2382
|
+
return commentEnd;
|
2383
|
+
}
|
2384
|
+
return comment(code);
|
2385
|
+
}
|
2386
|
+
function commentEnd(code) {
|
2387
|
+
return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
|
2388
|
+
}
|
2389
|
+
function cdataOpenInside(code) {
|
2390
|
+
const value = "CDATA[";
|
2391
|
+
if (code === value.charCodeAt(index2++)) {
|
2392
|
+
effects.consume(code);
|
2393
|
+
return index2 === value.length ? cdata : cdataOpenInside;
|
2394
|
+
}
|
2395
|
+
return nok(code);
|
2396
|
+
}
|
2397
|
+
function cdata(code) {
|
2398
|
+
if (code === null) {
|
2399
|
+
return nok(code);
|
2400
|
+
}
|
2401
|
+
if (code === 93) {
|
2402
|
+
effects.consume(code);
|
2403
|
+
return cdataClose;
|
2404
|
+
}
|
2405
|
+
if (markdownLineEnding(code)) {
|
2406
|
+
returnState = cdata;
|
2407
|
+
return lineEndingBefore(code);
|
2408
|
+
}
|
2409
|
+
effects.consume(code);
|
2410
|
+
return cdata;
|
2411
|
+
}
|
2412
|
+
function cdataClose(code) {
|
2413
|
+
if (code === 93) {
|
2414
|
+
effects.consume(code);
|
2415
|
+
return cdataEnd;
|
2416
|
+
}
|
2417
|
+
return cdata(code);
|
2418
|
+
}
|
2419
|
+
function cdataEnd(code) {
|
2420
|
+
if (code === 62) {
|
2421
|
+
return end(code);
|
2422
|
+
}
|
2423
|
+
if (code === 93) {
|
2424
|
+
effects.consume(code);
|
2425
|
+
return cdataEnd;
|
2426
|
+
}
|
2427
|
+
return cdata(code);
|
2428
|
+
}
|
2429
|
+
function declaration(code) {
|
2430
|
+
if (code === null || code === 62) {
|
2431
|
+
return end(code);
|
2432
|
+
}
|
2433
|
+
if (markdownLineEnding(code)) {
|
2434
|
+
returnState = declaration;
|
2435
|
+
return lineEndingBefore(code);
|
2436
|
+
}
|
2437
|
+
effects.consume(code);
|
2438
|
+
return declaration;
|
2439
|
+
}
|
2440
|
+
function instruction(code) {
|
2441
|
+
if (code === null) {
|
2442
|
+
return nok(code);
|
2443
|
+
}
|
2444
|
+
if (code === 63) {
|
2445
|
+
effects.consume(code);
|
2446
|
+
return instructionClose;
|
2447
|
+
}
|
2448
|
+
if (markdownLineEnding(code)) {
|
2449
|
+
returnState = instruction;
|
2450
|
+
return lineEndingBefore(code);
|
2451
|
+
}
|
2452
|
+
effects.consume(code);
|
2453
|
+
return instruction;
|
2454
|
+
}
|
2455
|
+
function instructionClose(code) {
|
2456
|
+
return code === 62 ? end(code) : instruction(code);
|
2457
|
+
}
|
2458
|
+
function tagCloseStart(code) {
|
2459
|
+
if (asciiAlpha(code)) {
|
2460
|
+
effects.consume(code);
|
2461
|
+
return tagClose;
|
2462
|
+
}
|
2463
|
+
return nok(code);
|
2464
|
+
}
|
2465
|
+
function tagClose(code) {
|
2466
|
+
if (code === 45 || asciiAlphanumeric(code)) {
|
2467
|
+
effects.consume(code);
|
2468
|
+
return tagClose;
|
2469
|
+
}
|
2470
|
+
return tagCloseBetween(code);
|
2471
|
+
}
|
2472
|
+
function tagCloseBetween(code) {
|
2473
|
+
if (markdownLineEnding(code)) {
|
2474
|
+
returnState = tagCloseBetween;
|
2475
|
+
return lineEndingBefore(code);
|
2476
|
+
}
|
2477
|
+
if (markdownSpace(code)) {
|
2478
|
+
effects.consume(code);
|
2479
|
+
return tagCloseBetween;
|
2480
|
+
}
|
2481
|
+
return end(code);
|
2482
|
+
}
|
2483
|
+
function tagOpen(code) {
|
2484
|
+
if (code === 45 || asciiAlphanumeric(code)) {
|
2485
|
+
effects.consume(code);
|
2486
|
+
return tagOpen;
|
2487
|
+
}
|
2488
|
+
if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
|
2489
|
+
return tagOpenBetween(code);
|
2490
|
+
}
|
2491
|
+
return nok(code);
|
2492
|
+
}
|
2493
|
+
function tagOpenBetween(code) {
|
2494
|
+
if (code === 47) {
|
2495
|
+
effects.consume(code);
|
2496
|
+
return end;
|
2497
|
+
}
|
2498
|
+
if (code === 58 || code === 95 || asciiAlpha(code)) {
|
2499
|
+
effects.consume(code);
|
2500
|
+
return tagOpenAttributeName;
|
2501
|
+
}
|
2502
|
+
if (markdownLineEnding(code)) {
|
2503
|
+
returnState = tagOpenBetween;
|
2504
|
+
return lineEndingBefore(code);
|
2505
|
+
}
|
2506
|
+
if (markdownSpace(code)) {
|
2507
|
+
effects.consume(code);
|
2508
|
+
return tagOpenBetween;
|
2509
|
+
}
|
2510
|
+
return end(code);
|
2511
|
+
}
|
2512
|
+
function tagOpenAttributeName(code) {
|
2513
|
+
if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
|
2514
|
+
effects.consume(code);
|
2515
|
+
return tagOpenAttributeName;
|
2516
|
+
}
|
2517
|
+
return tagOpenAttributeNameAfter(code);
|
2518
|
+
}
|
2519
|
+
function tagOpenAttributeNameAfter(code) {
|
2520
|
+
if (code === 61) {
|
2521
|
+
effects.consume(code);
|
2522
|
+
return tagOpenAttributeValueBefore;
|
2523
|
+
}
|
2524
|
+
if (markdownLineEnding(code)) {
|
2525
|
+
returnState = tagOpenAttributeNameAfter;
|
2526
|
+
return lineEndingBefore(code);
|
2527
|
+
}
|
2528
|
+
if (markdownSpace(code)) {
|
2529
|
+
effects.consume(code);
|
2530
|
+
return tagOpenAttributeNameAfter;
|
2531
|
+
}
|
2532
|
+
return tagOpenBetween(code);
|
2533
|
+
}
|
2534
|
+
function tagOpenAttributeValueBefore(code) {
|
2535
|
+
if (code === null || code === 60 || code === 61 || code === 62 || code === 96) {
|
2536
|
+
return nok(code);
|
2537
|
+
}
|
2538
|
+
if (code === 34 || code === 39) {
|
2539
|
+
effects.consume(code);
|
2540
|
+
marker = code;
|
2541
|
+
return tagOpenAttributeValueQuoted;
|
2542
|
+
}
|
2543
|
+
if (markdownLineEnding(code)) {
|
2544
|
+
returnState = tagOpenAttributeValueBefore;
|
2545
|
+
return lineEndingBefore(code);
|
2546
|
+
}
|
2547
|
+
if (markdownSpace(code)) {
|
2548
|
+
effects.consume(code);
|
2549
|
+
return tagOpenAttributeValueBefore;
|
2550
|
+
}
|
2551
|
+
effects.consume(code);
|
2552
|
+
return tagOpenAttributeValueUnquoted;
|
2553
|
+
}
|
2554
|
+
function tagOpenAttributeValueQuoted(code) {
|
2555
|
+
if (code === marker) {
|
2556
|
+
effects.consume(code);
|
2557
|
+
marker = void 0;
|
2558
|
+
return tagOpenAttributeValueQuotedAfter;
|
2559
|
+
}
|
2560
|
+
if (code === null) {
|
2561
|
+
return nok(code);
|
2562
|
+
}
|
2563
|
+
if (markdownLineEnding(code)) {
|
2564
|
+
returnState = tagOpenAttributeValueQuoted;
|
2565
|
+
return lineEndingBefore(code);
|
2566
|
+
}
|
2567
|
+
effects.consume(code);
|
2568
|
+
return tagOpenAttributeValueQuoted;
|
2569
|
+
}
|
2570
|
+
function tagOpenAttributeValueUnquoted(code) {
|
2571
|
+
if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) {
|
2572
|
+
return nok(code);
|
2573
|
+
}
|
2574
|
+
if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
|
2575
|
+
return tagOpenBetween(code);
|
2576
|
+
}
|
2577
|
+
effects.consume(code);
|
2578
|
+
return tagOpenAttributeValueUnquoted;
|
2579
|
+
}
|
2580
|
+
function tagOpenAttributeValueQuotedAfter(code) {
|
2581
|
+
if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
|
2582
|
+
return tagOpenBetween(code);
|
2583
|
+
}
|
2584
|
+
return nok(code);
|
2585
|
+
}
|
2586
|
+
function end(code) {
|
2587
|
+
if (code === 62) {
|
2588
|
+
effects.consume(code);
|
2589
|
+
effects.exit("htmlTextData");
|
2590
|
+
effects.exit("htmlText");
|
2591
|
+
return ok;
|
2592
|
+
}
|
2593
|
+
return nok(code);
|
2594
|
+
}
|
2595
|
+
function lineEndingBefore(code) {
|
2596
|
+
effects.exit("htmlTextData");
|
2597
|
+
effects.enter("lineEnding");
|
2598
|
+
effects.consume(code);
|
2599
|
+
effects.exit("lineEnding");
|
2600
|
+
return lineEndingAfter;
|
2601
|
+
}
|
2602
|
+
function lineEndingAfter(code) {
|
2603
|
+
return markdownSpace(code) ? factorySpace(
|
2604
|
+
effects,
|
2605
|
+
lineEndingAfterPrefix,
|
2606
|
+
"linePrefix",
|
2607
|
+
self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4
|
2608
|
+
)(code) : lineEndingAfterPrefix(code);
|
2609
|
+
}
|
2610
|
+
function lineEndingAfterPrefix(code) {
|
2611
|
+
effects.enter("htmlTextData");
|
2612
|
+
return returnState(code);
|
2613
|
+
}
|
2614
|
+
}
|
2615
|
+
const labelEnd = {
|
2616
|
+
name: "labelEnd",
|
2617
|
+
tokenize: tokenizeLabelEnd,
|
2618
|
+
resolveTo: resolveToLabelEnd,
|
2619
|
+
resolveAll: resolveAllLabelEnd
|
2620
|
+
};
|
2621
|
+
const resourceConstruct = {
|
2622
|
+
tokenize: tokenizeResource
|
2623
|
+
};
|
2624
|
+
const referenceFullConstruct = {
|
2625
|
+
tokenize: tokenizeReferenceFull
|
2626
|
+
};
|
2627
|
+
const referenceCollapsedConstruct = {
|
2628
|
+
tokenize: tokenizeReferenceCollapsed
|
2629
|
+
};
|
2630
|
+
function resolveAllLabelEnd(events) {
|
2631
|
+
let index2 = -1;
|
2632
|
+
while (++index2 < events.length) {
|
2633
|
+
const token = events[index2][1];
|
2634
|
+
if (token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") {
|
2635
|
+
events.splice(index2 + 1, token.type === "labelImage" ? 4 : 2);
|
2636
|
+
token.type = "data";
|
2637
|
+
index2++;
|
2638
|
+
}
|
2639
|
+
}
|
2640
|
+
return events;
|
2641
|
+
}
|
2642
|
+
function resolveToLabelEnd(events, context) {
|
2643
|
+
let index2 = events.length;
|
2644
|
+
let offset = 0;
|
2645
|
+
let token;
|
2646
|
+
let open;
|
2647
|
+
let close;
|
2648
|
+
let media;
|
2649
|
+
while (index2--) {
|
2650
|
+
token = events[index2][1];
|
2651
|
+
if (open) {
|
2652
|
+
if (token.type === "link" || token.type === "labelLink" && token._inactive) {
|
2653
|
+
break;
|
2654
|
+
}
|
2655
|
+
if (events[index2][0] === "enter" && token.type === "labelLink") {
|
2656
|
+
token._inactive = true;
|
2657
|
+
}
|
2658
|
+
} else if (close) {
|
2659
|
+
if (events[index2][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
|
2660
|
+
open = index2;
|
2661
|
+
if (token.type !== "labelLink") {
|
2662
|
+
offset = 2;
|
2663
|
+
break;
|
2664
|
+
}
|
2665
|
+
}
|
2666
|
+
} else if (token.type === "labelEnd") {
|
2667
|
+
close = index2;
|
2668
|
+
}
|
2669
|
+
}
|
2670
|
+
const group = {
|
2671
|
+
type: events[open][1].type === "labelLink" ? "link" : "image",
|
2672
|
+
start: Object.assign({}, events[open][1].start),
|
2673
|
+
end: Object.assign({}, events[events.length - 1][1].end)
|
2674
|
+
};
|
2675
|
+
const label = {
|
2676
|
+
type: "label",
|
2677
|
+
start: Object.assign({}, events[open][1].start),
|
2678
|
+
end: Object.assign({}, events[close][1].end)
|
2679
|
+
};
|
2680
|
+
const text2 = {
|
2681
|
+
type: "labelText",
|
2682
|
+
start: Object.assign({}, events[open + offset + 2][1].end),
|
2683
|
+
end: Object.assign({}, events[close - 2][1].start)
|
2684
|
+
};
|
2685
|
+
media = [
|
2686
|
+
["enter", group, context],
|
2687
|
+
["enter", label, context]
|
2688
|
+
];
|
2689
|
+
media = push(media, events.slice(open + 1, open + offset + 3));
|
2690
|
+
media = push(media, [["enter", text2, context]]);
|
2691
|
+
media = push(
|
2692
|
+
media,
|
2693
|
+
resolveAll(
|
2694
|
+
context.parser.constructs.insideSpan.null,
|
2695
|
+
events.slice(open + offset + 4, close - 3),
|
2696
|
+
context
|
2697
|
+
)
|
2698
|
+
);
|
2699
|
+
media = push(media, [
|
2700
|
+
["exit", text2, context],
|
2701
|
+
events[close - 2],
|
2702
|
+
events[close - 1],
|
2703
|
+
["exit", label, context]
|
2704
|
+
]);
|
2705
|
+
media = push(media, events.slice(close + 1));
|
2706
|
+
media = push(media, [["exit", group, context]]);
|
2707
|
+
splice(events, open, events.length, media);
|
2708
|
+
return events;
|
2709
|
+
}
|
2710
|
+
function tokenizeLabelEnd(effects, ok, nok) {
|
2711
|
+
const self = this;
|
2712
|
+
let index2 = self.events.length;
|
2713
|
+
let labelStart;
|
2714
|
+
let defined;
|
2715
|
+
while (index2--) {
|
2716
|
+
if ((self.events[index2][1].type === "labelImage" || self.events[index2][1].type === "labelLink") && !self.events[index2][1]._balanced) {
|
2717
|
+
labelStart = self.events[index2][1];
|
2718
|
+
break;
|
2719
|
+
}
|
2720
|
+
}
|
2721
|
+
return start;
|
2722
|
+
function start(code) {
|
2723
|
+
if (!labelStart) {
|
2724
|
+
return nok(code);
|
2725
|
+
}
|
2726
|
+
if (labelStart._inactive) {
|
2727
|
+
return labelEndNok(code);
|
2728
|
+
}
|
2729
|
+
defined = self.parser.defined.includes(
|
2730
|
+
normalizeIdentifier(
|
2731
|
+
self.sliceSerialize({
|
2732
|
+
start: labelStart.end,
|
2733
|
+
end: self.now()
|
2734
|
+
})
|
2735
|
+
)
|
2736
|
+
);
|
2737
|
+
effects.enter("labelEnd");
|
2738
|
+
effects.enter("labelMarker");
|
2739
|
+
effects.consume(code);
|
2740
|
+
effects.exit("labelMarker");
|
2741
|
+
effects.exit("labelEnd");
|
2742
|
+
return after;
|
2743
|
+
}
|
2744
|
+
function after(code) {
|
2745
|
+
if (code === 40) {
|
2746
|
+
return effects.attempt(
|
2747
|
+
resourceConstruct,
|
2748
|
+
labelEndOk,
|
2749
|
+
defined ? labelEndOk : labelEndNok
|
2750
|
+
)(code);
|
2751
|
+
}
|
2752
|
+
if (code === 91) {
|
2753
|
+
return effects.attempt(
|
2754
|
+
referenceFullConstruct,
|
2755
|
+
labelEndOk,
|
2756
|
+
defined ? referenceNotFull : labelEndNok
|
2757
|
+
)(code);
|
2758
|
+
}
|
2759
|
+
return defined ? labelEndOk(code) : labelEndNok(code);
|
2760
|
+
}
|
2761
|
+
function referenceNotFull(code) {
|
2762
|
+
return effects.attempt(
|
2763
|
+
referenceCollapsedConstruct,
|
2764
|
+
labelEndOk,
|
2765
|
+
labelEndNok
|
2766
|
+
)(code);
|
2767
|
+
}
|
2768
|
+
function labelEndOk(code) {
|
2769
|
+
return ok(code);
|
2770
|
+
}
|
2771
|
+
function labelEndNok(code) {
|
2772
|
+
labelStart._balanced = true;
|
2773
|
+
return nok(code);
|
2774
|
+
}
|
2775
|
+
}
|
2776
|
+
function tokenizeResource(effects, ok, nok) {
|
2777
|
+
return resourceStart;
|
2778
|
+
function resourceStart(code) {
|
2779
|
+
effects.enter("resource");
|
2780
|
+
effects.enter("resourceMarker");
|
2781
|
+
effects.consume(code);
|
2782
|
+
effects.exit("resourceMarker");
|
2783
|
+
return resourceBefore;
|
2784
|
+
}
|
2785
|
+
function resourceBefore(code) {
|
2786
|
+
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
|
2787
|
+
}
|
2788
|
+
function resourceOpen(code) {
|
2789
|
+
if (code === 41) {
|
2790
|
+
return resourceEnd(code);
|
2791
|
+
}
|
2792
|
+
return factoryDestination(
|
2793
|
+
effects,
|
2794
|
+
resourceDestinationAfter,
|
2795
|
+
resourceDestinationMissing,
|
2796
|
+
"resourceDestination",
|
2797
|
+
"resourceDestinationLiteral",
|
2798
|
+
"resourceDestinationLiteralMarker",
|
2799
|
+
"resourceDestinationRaw",
|
2800
|
+
"resourceDestinationString",
|
2801
|
+
32
|
2802
|
+
)(code);
|
2803
|
+
}
|
2804
|
+
function resourceDestinationAfter(code) {
|
2805
|
+
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
|
2806
|
+
}
|
2807
|
+
function resourceDestinationMissing(code) {
|
2808
|
+
return nok(code);
|
2809
|
+
}
|
2810
|
+
function resourceBetween(code) {
|
2811
|
+
if (code === 34 || code === 39 || code === 40) {
|
2812
|
+
return factoryTitle(
|
2813
|
+
effects,
|
2814
|
+
resourceTitleAfter,
|
2815
|
+
nok,
|
2816
|
+
"resourceTitle",
|
2817
|
+
"resourceTitleMarker",
|
2818
|
+
"resourceTitleString"
|
2819
|
+
)(code);
|
2820
|
+
}
|
2821
|
+
return resourceEnd(code);
|
2822
|
+
}
|
2823
|
+
function resourceTitleAfter(code) {
|
2824
|
+
return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
|
2825
|
+
}
|
2826
|
+
function resourceEnd(code) {
|
2827
|
+
if (code === 41) {
|
2828
|
+
effects.enter("resourceMarker");
|
2829
|
+
effects.consume(code);
|
2830
|
+
effects.exit("resourceMarker");
|
2831
|
+
effects.exit("resource");
|
2832
|
+
return ok;
|
2833
|
+
}
|
2834
|
+
return nok(code);
|
2835
|
+
}
|
2836
|
+
}
|
2837
|
+
function tokenizeReferenceFull(effects, ok, nok) {
|
2838
|
+
const self = this;
|
2839
|
+
return referenceFull;
|
2840
|
+
function referenceFull(code) {
|
2841
|
+
return factoryLabel.call(
|
2842
|
+
self,
|
2843
|
+
effects,
|
2844
|
+
referenceFullAfter,
|
2845
|
+
referenceFullMissing,
|
2846
|
+
"reference",
|
2847
|
+
"referenceMarker",
|
2848
|
+
"referenceString"
|
2849
|
+
)(code);
|
2850
|
+
}
|
2851
|
+
function referenceFullAfter(code) {
|
2852
|
+
return self.parser.defined.includes(
|
2853
|
+
normalizeIdentifier(
|
2854
|
+
self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1)
|
2855
|
+
)
|
2856
|
+
) ? ok(code) : nok(code);
|
2857
|
+
}
|
2858
|
+
function referenceFullMissing(code) {
|
2859
|
+
return nok(code);
|
2860
|
+
}
|
2861
|
+
}
|
2862
|
+
function tokenizeReferenceCollapsed(effects, ok, nok) {
|
2863
|
+
return referenceCollapsedStart;
|
2864
|
+
function referenceCollapsedStart(code) {
|
2865
|
+
effects.enter("reference");
|
2866
|
+
effects.enter("referenceMarker");
|
2867
|
+
effects.consume(code);
|
2868
|
+
effects.exit("referenceMarker");
|
2869
|
+
return referenceCollapsedOpen;
|
2870
|
+
}
|
2871
|
+
function referenceCollapsedOpen(code) {
|
2872
|
+
if (code === 93) {
|
2873
|
+
effects.enter("referenceMarker");
|
2874
|
+
effects.consume(code);
|
2875
|
+
effects.exit("referenceMarker");
|
2876
|
+
effects.exit("reference");
|
2877
|
+
return ok;
|
2878
|
+
}
|
2879
|
+
return nok(code);
|
2880
|
+
}
|
2881
|
+
}
|
2882
|
+
const labelStartImage = {
|
2883
|
+
name: "labelStartImage",
|
2884
|
+
tokenize: tokenizeLabelStartImage,
|
2885
|
+
resolveAll: labelEnd.resolveAll
|
2886
|
+
};
|
2887
|
+
function tokenizeLabelStartImage(effects, ok, nok) {
|
2888
|
+
const self = this;
|
2889
|
+
return start;
|
2890
|
+
function start(code) {
|
2891
|
+
effects.enter("labelImage");
|
2892
|
+
effects.enter("labelImageMarker");
|
2893
|
+
effects.consume(code);
|
2894
|
+
effects.exit("labelImageMarker");
|
2895
|
+
return open;
|
2896
|
+
}
|
2897
|
+
function open(code) {
|
2898
|
+
if (code === 91) {
|
2899
|
+
effects.enter("labelMarker");
|
2900
|
+
effects.consume(code);
|
2901
|
+
effects.exit("labelMarker");
|
2902
|
+
effects.exit("labelImage");
|
2903
|
+
return after;
|
2904
|
+
}
|
2905
|
+
return nok(code);
|
2906
|
+
}
|
2907
|
+
function after(code) {
|
2908
|
+
return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
|
2909
|
+
}
|
2910
|
+
}
|
2911
|
+
const labelStartLink = {
|
2912
|
+
name: "labelStartLink",
|
2913
|
+
tokenize: tokenizeLabelStartLink,
|
2914
|
+
resolveAll: labelEnd.resolveAll
|
2915
|
+
};
|
2916
|
+
function tokenizeLabelStartLink(effects, ok, nok) {
|
2917
|
+
const self = this;
|
2918
|
+
return start;
|
2919
|
+
function start(code) {
|
2920
|
+
effects.enter("labelLink");
|
2921
|
+
effects.enter("labelMarker");
|
2922
|
+
effects.consume(code);
|
2923
|
+
effects.exit("labelMarker");
|
2924
|
+
effects.exit("labelLink");
|
2925
|
+
return after;
|
2926
|
+
}
|
2927
|
+
function after(code) {
|
2928
|
+
return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
|
2929
|
+
}
|
2930
|
+
}
|
2931
|
+
const lineEnding = {
|
2932
|
+
name: "lineEnding",
|
2933
|
+
tokenize: tokenizeLineEnding
|
2934
|
+
};
|
2935
|
+
function tokenizeLineEnding(effects, ok) {
|
2936
|
+
return start;
|
2937
|
+
function start(code) {
|
2938
|
+
effects.enter("lineEnding");
|
2939
|
+
effects.consume(code);
|
2940
|
+
effects.exit("lineEnding");
|
2941
|
+
return factorySpace(effects, ok, "linePrefix");
|
2942
|
+
}
|
2943
|
+
}
|
2944
|
+
const thematicBreak = {
|
2945
|
+
name: "thematicBreak",
|
2946
|
+
tokenize: tokenizeThematicBreak
|
2947
|
+
};
|
2948
|
+
function tokenizeThematicBreak(effects, ok, nok) {
|
2949
|
+
let size = 0;
|
2950
|
+
let marker;
|
2951
|
+
return start;
|
2952
|
+
function start(code) {
|
2953
|
+
effects.enter("thematicBreak");
|
2954
|
+
return before(code);
|
2955
|
+
}
|
2956
|
+
function before(code) {
|
2957
|
+
marker = code;
|
2958
|
+
return atBreak(code);
|
2959
|
+
}
|
2960
|
+
function atBreak(code) {
|
2961
|
+
if (code === marker) {
|
2962
|
+
effects.enter("thematicBreakSequence");
|
2963
|
+
return sequence(code);
|
2964
|
+
}
|
2965
|
+
if (size >= 3 && (code === null || markdownLineEnding(code))) {
|
2966
|
+
effects.exit("thematicBreak");
|
2967
|
+
return ok(code);
|
2968
|
+
}
|
2969
|
+
return nok(code);
|
2970
|
+
}
|
2971
|
+
function sequence(code) {
|
2972
|
+
if (code === marker) {
|
2973
|
+
effects.consume(code);
|
2974
|
+
size++;
|
2975
|
+
return sequence;
|
2976
|
+
}
|
2977
|
+
effects.exit("thematicBreakSequence");
|
2978
|
+
return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code);
|
2979
|
+
}
|
2980
|
+
}
|
2981
|
+
const list = {
|
2982
|
+
name: "list",
|
2983
|
+
tokenize: tokenizeListStart,
|
2984
|
+
continuation: {
|
2985
|
+
tokenize: tokenizeListContinuation
|
2986
|
+
},
|
2987
|
+
exit: tokenizeListEnd
|
2988
|
+
};
|
2989
|
+
const listItemPrefixWhitespaceConstruct = {
|
2990
|
+
tokenize: tokenizeListItemPrefixWhitespace,
|
2991
|
+
partial: true
|
2992
|
+
};
|
2993
|
+
const indentConstruct = {
|
2994
|
+
tokenize: tokenizeIndent,
|
2995
|
+
partial: true
|
2996
|
+
};
|
2997
|
+
function tokenizeListStart(effects, ok, nok) {
|
2998
|
+
const self = this;
|
2999
|
+
const tail = self.events[self.events.length - 1];
|
3000
|
+
let initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
|
3001
|
+
let size = 0;
|
3002
|
+
return start;
|
3003
|
+
function start(code) {
|
3004
|
+
const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered");
|
3005
|
+
if (kind === "listUnordered" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {
|
3006
|
+
if (!self.containerState.type) {
|
3007
|
+
self.containerState.type = kind;
|
3008
|
+
effects.enter(kind, {
|
3009
|
+
_container: true
|
3010
|
+
});
|
3011
|
+
}
|
3012
|
+
if (kind === "listUnordered") {
|
3013
|
+
effects.enter("listItemPrefix");
|
3014
|
+
return code === 42 || code === 45 ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code);
|
3015
|
+
}
|
3016
|
+
if (!self.interrupt || code === 49) {
|
3017
|
+
effects.enter("listItemPrefix");
|
3018
|
+
effects.enter("listItemValue");
|
3019
|
+
return inside(code);
|
3020
|
+
}
|
3021
|
+
}
|
3022
|
+
return nok(code);
|
3023
|
+
}
|
3024
|
+
function inside(code) {
|
3025
|
+
if (asciiDigit(code) && ++size < 10) {
|
3026
|
+
effects.consume(code);
|
3027
|
+
return inside;
|
3028
|
+
}
|
3029
|
+
if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {
|
3030
|
+
effects.exit("listItemValue");
|
3031
|
+
return atMarker(code);
|
3032
|
+
}
|
3033
|
+
return nok(code);
|
3034
|
+
}
|
3035
|
+
function atMarker(code) {
|
3036
|
+
effects.enter("listItemMarker");
|
3037
|
+
effects.consume(code);
|
3038
|
+
effects.exit("listItemMarker");
|
3039
|
+
self.containerState.marker = self.containerState.marker || code;
|
3040
|
+
return effects.check(
|
3041
|
+
blankLine,
|
3042
|
+
// Can’t be empty when interrupting.
|
3043
|
+
self.interrupt ? nok : onBlank,
|
3044
|
+
effects.attempt(
|
3045
|
+
listItemPrefixWhitespaceConstruct,
|
3046
|
+
endOfPrefix,
|
3047
|
+
otherPrefix
|
3048
|
+
)
|
3049
|
+
);
|
3050
|
+
}
|
3051
|
+
function onBlank(code) {
|
3052
|
+
self.containerState.initialBlankLine = true;
|
3053
|
+
initialSize++;
|
3054
|
+
return endOfPrefix(code);
|
3055
|
+
}
|
3056
|
+
function otherPrefix(code) {
|
3057
|
+
if (markdownSpace(code)) {
|
3058
|
+
effects.enter("listItemPrefixWhitespace");
|
3059
|
+
effects.consume(code);
|
3060
|
+
effects.exit("listItemPrefixWhitespace");
|
3061
|
+
return endOfPrefix;
|
3062
|
+
}
|
3063
|
+
return nok(code);
|
3064
|
+
}
|
3065
|
+
function endOfPrefix(code) {
|
3066
|
+
self.containerState.size = initialSize + self.sliceSerialize(effects.exit("listItemPrefix"), true).length;
|
3067
|
+
return ok(code);
|
3068
|
+
}
|
3069
|
+
}
|
3070
|
+
function tokenizeListContinuation(effects, ok, nok) {
|
3071
|
+
const self = this;
|
3072
|
+
self.containerState._closeFlow = void 0;
|
3073
|
+
return effects.check(blankLine, onBlank, notBlank);
|
3074
|
+
function onBlank(code) {
|
3075
|
+
self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;
|
3076
|
+
return factorySpace(
|
3077
|
+
effects,
|
3078
|
+
ok,
|
3079
|
+
"listItemIndent",
|
3080
|
+
self.containerState.size + 1
|
3081
|
+
)(code);
|
3082
|
+
}
|
3083
|
+
function notBlank(code) {
|
3084
|
+
if (self.containerState.furtherBlankLines || !markdownSpace(code)) {
|
3085
|
+
self.containerState.furtherBlankLines = void 0;
|
3086
|
+
self.containerState.initialBlankLine = void 0;
|
3087
|
+
return notInCurrentItem(code);
|
3088
|
+
}
|
3089
|
+
self.containerState.furtherBlankLines = void 0;
|
3090
|
+
self.containerState.initialBlankLine = void 0;
|
3091
|
+
return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);
|
3092
|
+
}
|
3093
|
+
function notInCurrentItem(code) {
|
3094
|
+
self.containerState._closeFlow = true;
|
3095
|
+
self.interrupt = void 0;
|
3096
|
+
return factorySpace(
|
3097
|
+
effects,
|
3098
|
+
effects.attempt(list, ok, nok),
|
3099
|
+
"linePrefix",
|
3100
|
+
self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4
|
3101
|
+
)(code);
|
3102
|
+
}
|
3103
|
+
}
|
3104
|
+
function tokenizeIndent(effects, ok, nok) {
|
3105
|
+
const self = this;
|
3106
|
+
return factorySpace(
|
3107
|
+
effects,
|
3108
|
+
afterPrefix,
|
3109
|
+
"listItemIndent",
|
3110
|
+
self.containerState.size + 1
|
3111
|
+
);
|
3112
|
+
function afterPrefix(code) {
|
3113
|
+
const tail = self.events[self.events.length - 1];
|
3114
|
+
return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);
|
3115
|
+
}
|
3116
|
+
}
|
3117
|
+
function tokenizeListEnd(effects) {
|
3118
|
+
effects.exit(this.containerState.type);
|
3119
|
+
}
|
3120
|
+
function tokenizeListItemPrefixWhitespace(effects, ok, nok) {
|
3121
|
+
const self = this;
|
3122
|
+
return factorySpace(
|
3123
|
+
effects,
|
3124
|
+
afterPrefix,
|
3125
|
+
"listItemPrefixWhitespace",
|
3126
|
+
self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4 + 1
|
3127
|
+
);
|
3128
|
+
function afterPrefix(code) {
|
3129
|
+
const tail = self.events[self.events.length - 1];
|
3130
|
+
return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code);
|
3131
|
+
}
|
3132
|
+
}
|
3133
|
+
const setextUnderline = {
|
3134
|
+
name: "setextUnderline",
|
3135
|
+
tokenize: tokenizeSetextUnderline,
|
3136
|
+
resolveTo: resolveToSetextUnderline
|
3137
|
+
};
|
3138
|
+
function resolveToSetextUnderline(events, context) {
|
3139
|
+
let index2 = events.length;
|
3140
|
+
let content2;
|
3141
|
+
let text2;
|
3142
|
+
let definition2;
|
3143
|
+
while (index2--) {
|
3144
|
+
if (events[index2][0] === "enter") {
|
3145
|
+
if (events[index2][1].type === "content") {
|
3146
|
+
content2 = index2;
|
3147
|
+
break;
|
3148
|
+
}
|
3149
|
+
if (events[index2][1].type === "paragraph") {
|
3150
|
+
text2 = index2;
|
3151
|
+
}
|
3152
|
+
} else {
|
3153
|
+
if (events[index2][1].type === "content") {
|
3154
|
+
events.splice(index2, 1);
|
3155
|
+
}
|
3156
|
+
if (!definition2 && events[index2][1].type === "definition") {
|
3157
|
+
definition2 = index2;
|
3158
|
+
}
|
3159
|
+
}
|
3160
|
+
}
|
3161
|
+
const heading = {
|
3162
|
+
type: "setextHeading",
|
3163
|
+
start: Object.assign({}, events[text2][1].start),
|
3164
|
+
end: Object.assign({}, events[events.length - 1][1].end)
|
3165
|
+
};
|
3166
|
+
events[text2][1].type = "setextHeadingText";
|
3167
|
+
if (definition2) {
|
3168
|
+
events.splice(text2, 0, ["enter", heading, context]);
|
3169
|
+
events.splice(definition2 + 1, 0, ["exit", events[content2][1], context]);
|
3170
|
+
events[content2][1].end = Object.assign({}, events[definition2][1].end);
|
3171
|
+
} else {
|
3172
|
+
events[content2][1] = heading;
|
3173
|
+
}
|
3174
|
+
events.push(["exit", heading, context]);
|
3175
|
+
return events;
|
3176
|
+
}
|
3177
|
+
function tokenizeSetextUnderline(effects, ok, nok) {
|
3178
|
+
const self = this;
|
3179
|
+
let marker;
|
3180
|
+
return start;
|
3181
|
+
function start(code) {
|
3182
|
+
let index2 = self.events.length;
|
3183
|
+
let paragraph;
|
3184
|
+
while (index2--) {
|
3185
|
+
if (self.events[index2][1].type !== "lineEnding" && self.events[index2][1].type !== "linePrefix" && self.events[index2][1].type !== "content") {
|
3186
|
+
paragraph = self.events[index2][1].type === "paragraph";
|
3187
|
+
break;
|
3188
|
+
}
|
3189
|
+
}
|
3190
|
+
if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {
|
3191
|
+
effects.enter("setextHeadingLine");
|
3192
|
+
marker = code;
|
3193
|
+
return before(code);
|
3194
|
+
}
|
3195
|
+
return nok(code);
|
3196
|
+
}
|
3197
|
+
function before(code) {
|
3198
|
+
effects.enter("setextHeadingLineSequence");
|
3199
|
+
return inside(code);
|
3200
|
+
}
|
3201
|
+
function inside(code) {
|
3202
|
+
if (code === marker) {
|
3203
|
+
effects.consume(code);
|
3204
|
+
return inside;
|
3205
|
+
}
|
3206
|
+
effects.exit("setextHeadingLineSequence");
|
3207
|
+
return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code);
|
3208
|
+
}
|
3209
|
+
function after(code) {
|
3210
|
+
if (code === null || markdownLineEnding(code)) {
|
3211
|
+
effects.exit("setextHeadingLine");
|
3212
|
+
return ok(code);
|
3213
|
+
}
|
3214
|
+
return nok(code);
|
3215
|
+
}
|
3216
|
+
}
|
3217
|
+
const flow$1 = {
|
3218
|
+
tokenize: initializeFlow
|
3219
|
+
};
|
3220
|
+
function initializeFlow(effects) {
|
3221
|
+
const self = this;
|
3222
|
+
const initial = effects.attempt(
|
3223
|
+
// Try to parse a blank line.
|
3224
|
+
blankLine,
|
3225
|
+
atBlankEnding,
|
3226
|
+
// Try to parse initial flow (essentially, only code).
|
3227
|
+
effects.attempt(
|
3228
|
+
this.parser.constructs.flowInitial,
|
3229
|
+
afterConstruct,
|
3230
|
+
factorySpace(
|
3231
|
+
effects,
|
3232
|
+
effects.attempt(
|
3233
|
+
this.parser.constructs.flow,
|
3234
|
+
afterConstruct,
|
3235
|
+
effects.attempt(content, afterConstruct)
|
3236
|
+
),
|
3237
|
+
"linePrefix"
|
3238
|
+
)
|
3239
|
+
)
|
3240
|
+
);
|
3241
|
+
return initial;
|
3242
|
+
function atBlankEnding(code) {
|
3243
|
+
if (code === null) {
|
3244
|
+
effects.consume(code);
|
3245
|
+
return;
|
3246
|
+
}
|
3247
|
+
effects.enter("lineEndingBlank");
|
3248
|
+
effects.consume(code);
|
3249
|
+
effects.exit("lineEndingBlank");
|
3250
|
+
self.currentConstruct = void 0;
|
3251
|
+
return initial;
|
3252
|
+
}
|
3253
|
+
function afterConstruct(code) {
|
3254
|
+
if (code === null) {
|
3255
|
+
effects.consume(code);
|
3256
|
+
return;
|
3257
|
+
}
|
3258
|
+
effects.enter("lineEnding");
|
3259
|
+
effects.consume(code);
|
3260
|
+
effects.exit("lineEnding");
|
3261
|
+
self.currentConstruct = void 0;
|
3262
|
+
return initial;
|
3263
|
+
}
|
3264
|
+
}
|
3265
|
+
const resolver = {
|
3266
|
+
resolveAll: createResolver()
|
3267
|
+
};
|
3268
|
+
const string$1 = initializeFactory("string");
|
3269
|
+
const text$1 = initializeFactory("text");
|
3270
|
+
function initializeFactory(field) {
|
3271
|
+
return {
|
3272
|
+
tokenize: initializeText,
|
3273
|
+
resolveAll: createResolver(
|
3274
|
+
field === "text" ? resolveAllLineSuffixes : void 0
|
3275
|
+
)
|
3276
|
+
};
|
3277
|
+
function initializeText(effects) {
|
3278
|
+
const self = this;
|
3279
|
+
const constructs2 = this.parser.constructs[field];
|
3280
|
+
const text2 = effects.attempt(constructs2, start, notText);
|
3281
|
+
return start;
|
3282
|
+
function start(code) {
|
3283
|
+
return atBreak(code) ? text2(code) : notText(code);
|
3284
|
+
}
|
3285
|
+
function notText(code) {
|
3286
|
+
if (code === null) {
|
3287
|
+
effects.consume(code);
|
3288
|
+
return;
|
3289
|
+
}
|
3290
|
+
effects.enter("data");
|
3291
|
+
effects.consume(code);
|
3292
|
+
return data;
|
3293
|
+
}
|
3294
|
+
function data(code) {
|
3295
|
+
if (atBreak(code)) {
|
3296
|
+
effects.exit("data");
|
3297
|
+
return text2(code);
|
3298
|
+
}
|
3299
|
+
effects.consume(code);
|
3300
|
+
return data;
|
3301
|
+
}
|
3302
|
+
function atBreak(code) {
|
3303
|
+
if (code === null) {
|
3304
|
+
return true;
|
3305
|
+
}
|
3306
|
+
const list2 = constructs2[code];
|
3307
|
+
let index2 = -1;
|
3308
|
+
if (list2) {
|
3309
|
+
while (++index2 < list2.length) {
|
3310
|
+
const item = list2[index2];
|
3311
|
+
if (!item.previous || item.previous.call(self, self.previous)) {
|
3312
|
+
return true;
|
3313
|
+
}
|
3314
|
+
}
|
3315
|
+
}
|
3316
|
+
return false;
|
3317
|
+
}
|
3318
|
+
}
|
3319
|
+
}
|
3320
|
+
function createResolver(extraResolver) {
|
3321
|
+
return resolveAllText;
|
3322
|
+
function resolveAllText(events, context) {
|
3323
|
+
let index2 = -1;
|
3324
|
+
let enter;
|
3325
|
+
while (++index2 <= events.length) {
|
3326
|
+
if (enter === void 0) {
|
3327
|
+
if (events[index2] && events[index2][1].type === "data") {
|
3328
|
+
enter = index2;
|
3329
|
+
index2++;
|
3330
|
+
}
|
3331
|
+
} else if (!events[index2] || events[index2][1].type !== "data") {
|
3332
|
+
if (index2 !== enter + 2) {
|
3333
|
+
events[enter][1].end = events[index2 - 1][1].end;
|
3334
|
+
events.splice(enter + 2, index2 - enter - 2);
|
3335
|
+
index2 = enter + 2;
|
3336
|
+
}
|
3337
|
+
enter = void 0;
|
3338
|
+
}
|
3339
|
+
}
|
3340
|
+
return extraResolver ? extraResolver(events, context) : events;
|
3341
|
+
}
|
3342
|
+
}
|
3343
|
+
function resolveAllLineSuffixes(events, context) {
|
3344
|
+
let eventIndex = 0;
|
3345
|
+
while (++eventIndex <= events.length) {
|
3346
|
+
if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
|
3347
|
+
const data = events[eventIndex - 1][1];
|
3348
|
+
const chunks = context.sliceStream(data);
|
3349
|
+
let index2 = chunks.length;
|
3350
|
+
let bufferIndex = -1;
|
3351
|
+
let size = 0;
|
3352
|
+
let tabs;
|
3353
|
+
while (index2--) {
|
3354
|
+
const chunk = chunks[index2];
|
3355
|
+
if (typeof chunk === "string") {
|
3356
|
+
bufferIndex = chunk.length;
|
3357
|
+
while (chunk.charCodeAt(bufferIndex - 1) === 32) {
|
3358
|
+
size++;
|
3359
|
+
bufferIndex--;
|
3360
|
+
}
|
3361
|
+
if (bufferIndex)
|
3362
|
+
break;
|
3363
|
+
bufferIndex = -1;
|
3364
|
+
} else if (chunk === -2) {
|
3365
|
+
tabs = true;
|
3366
|
+
size++;
|
3367
|
+
} else if (chunk === -1)
|
3368
|
+
;
|
3369
|
+
else {
|
3370
|
+
index2++;
|
3371
|
+
break;
|
3372
|
+
}
|
3373
|
+
}
|
3374
|
+
if (size) {
|
3375
|
+
const token = {
|
3376
|
+
type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
|
3377
|
+
start: {
|
3378
|
+
line: data.end.line,
|
3379
|
+
column: data.end.column - size,
|
3380
|
+
offset: data.end.offset - size,
|
3381
|
+
_index: data.start._index + index2,
|
3382
|
+
_bufferIndex: index2 ? bufferIndex : data.start._bufferIndex + bufferIndex
|
3383
|
+
},
|
3384
|
+
end: Object.assign({}, data.end)
|
3385
|
+
};
|
3386
|
+
data.end = Object.assign({}, token.start);
|
3387
|
+
if (data.start.offset === data.end.offset) {
|
3388
|
+
Object.assign(data, token);
|
3389
|
+
} else {
|
3390
|
+
events.splice(
|
3391
|
+
eventIndex,
|
3392
|
+
0,
|
3393
|
+
["enter", token, context],
|
3394
|
+
["exit", token, context]
|
3395
|
+
);
|
3396
|
+
eventIndex += 2;
|
3397
|
+
}
|
3398
|
+
}
|
3399
|
+
eventIndex++;
|
3400
|
+
}
|
3401
|
+
}
|
3402
|
+
return events;
|
3403
|
+
}
|
3404
|
+
function createTokenizer(parser, initialize, from) {
|
3405
|
+
let point2 = Object.assign(
|
3406
|
+
from ? Object.assign({}, from) : {
|
3407
|
+
line: 1,
|
3408
|
+
column: 1,
|
3409
|
+
offset: 0
|
3410
|
+
},
|
3411
|
+
{
|
3412
|
+
_index: 0,
|
3413
|
+
_bufferIndex: -1
|
3414
|
+
}
|
3415
|
+
);
|
3416
|
+
const columnStart = {};
|
3417
|
+
const resolveAllConstructs = [];
|
3418
|
+
let chunks = [];
|
3419
|
+
let stack = [];
|
3420
|
+
const effects = {
|
3421
|
+
consume,
|
3422
|
+
enter,
|
3423
|
+
exit: exit2,
|
3424
|
+
attempt: constructFactory(onsuccessfulconstruct),
|
3425
|
+
check: constructFactory(onsuccessfulcheck),
|
3426
|
+
interrupt: constructFactory(onsuccessfulcheck, {
|
3427
|
+
interrupt: true
|
3428
|
+
})
|
3429
|
+
};
|
3430
|
+
const context = {
|
3431
|
+
previous: null,
|
3432
|
+
code: null,
|
3433
|
+
containerState: {},
|
3434
|
+
events: [],
|
3435
|
+
parser,
|
3436
|
+
sliceStream,
|
3437
|
+
sliceSerialize,
|
3438
|
+
now,
|
3439
|
+
defineSkip,
|
3440
|
+
write
|
3441
|
+
};
|
3442
|
+
let state = initialize.tokenize.call(context, effects);
|
3443
|
+
if (initialize.resolveAll) {
|
3444
|
+
resolveAllConstructs.push(initialize);
|
3445
|
+
}
|
3446
|
+
return context;
|
3447
|
+
function write(slice) {
|
3448
|
+
chunks = push(chunks, slice);
|
3449
|
+
main();
|
3450
|
+
if (chunks[chunks.length - 1] !== null) {
|
3451
|
+
return [];
|
3452
|
+
}
|
3453
|
+
addResult(initialize, 0);
|
3454
|
+
context.events = resolveAll(resolveAllConstructs, context.events, context);
|
3455
|
+
return context.events;
|
3456
|
+
}
|
3457
|
+
function sliceSerialize(token, expandTabs) {
|
3458
|
+
return serializeChunks(sliceStream(token), expandTabs);
|
3459
|
+
}
|
3460
|
+
function sliceStream(token) {
|
3461
|
+
return sliceChunks(chunks, token);
|
3462
|
+
}
|
3463
|
+
function now() {
|
3464
|
+
const { line, column, offset, _index, _bufferIndex } = point2;
|
3465
|
+
return {
|
3466
|
+
line,
|
3467
|
+
column,
|
3468
|
+
offset,
|
3469
|
+
_index,
|
3470
|
+
_bufferIndex
|
3471
|
+
};
|
3472
|
+
}
|
3473
|
+
function defineSkip(value) {
|
3474
|
+
columnStart[value.line] = value.column;
|
3475
|
+
accountForPotentialSkip();
|
3476
|
+
}
|
3477
|
+
function main() {
|
3478
|
+
let chunkIndex;
|
3479
|
+
while (point2._index < chunks.length) {
|
3480
|
+
const chunk = chunks[point2._index];
|
3481
|
+
if (typeof chunk === "string") {
|
3482
|
+
chunkIndex = point2._index;
|
3483
|
+
if (point2._bufferIndex < 0) {
|
3484
|
+
point2._bufferIndex = 0;
|
3485
|
+
}
|
3486
|
+
while (point2._index === chunkIndex && point2._bufferIndex < chunk.length) {
|
3487
|
+
go(chunk.charCodeAt(point2._bufferIndex));
|
3488
|
+
}
|
3489
|
+
} else {
|
3490
|
+
go(chunk);
|
3491
|
+
}
|
3492
|
+
}
|
3493
|
+
}
|
3494
|
+
function go(code) {
|
3495
|
+
state = state(code);
|
3496
|
+
}
|
3497
|
+
function consume(code) {
|
3498
|
+
if (markdownLineEnding(code)) {
|
3499
|
+
point2.line++;
|
3500
|
+
point2.column = 1;
|
3501
|
+
point2.offset += code === -3 ? 2 : 1;
|
3502
|
+
accountForPotentialSkip();
|
3503
|
+
} else if (code !== -1) {
|
3504
|
+
point2.column++;
|
3505
|
+
point2.offset++;
|
3506
|
+
}
|
3507
|
+
if (point2._bufferIndex < 0) {
|
3508
|
+
point2._index++;
|
3509
|
+
} else {
|
3510
|
+
point2._bufferIndex++;
|
3511
|
+
if (point2._bufferIndex === chunks[point2._index].length) {
|
3512
|
+
point2._bufferIndex = -1;
|
3513
|
+
point2._index++;
|
3514
|
+
}
|
3515
|
+
}
|
3516
|
+
context.previous = code;
|
3517
|
+
}
|
3518
|
+
function enter(type, fields) {
|
3519
|
+
const token = fields || {};
|
3520
|
+
token.type = type;
|
3521
|
+
token.start = now();
|
3522
|
+
context.events.push(["enter", token, context]);
|
3523
|
+
stack.push(token);
|
3524
|
+
return token;
|
3525
|
+
}
|
3526
|
+
function exit2(type) {
|
3527
|
+
const token = stack.pop();
|
3528
|
+
token.end = now();
|
3529
|
+
context.events.push(["exit", token, context]);
|
3530
|
+
return token;
|
3531
|
+
}
|
3532
|
+
function onsuccessfulconstruct(construct, info) {
|
3533
|
+
addResult(construct, info.from);
|
3534
|
+
}
|
3535
|
+
function onsuccessfulcheck(_, info) {
|
3536
|
+
info.restore();
|
3537
|
+
}
|
3538
|
+
function constructFactory(onreturn, fields) {
|
3539
|
+
return hook;
|
3540
|
+
function hook(constructs2, returnState, bogusState) {
|
3541
|
+
let listOfConstructs;
|
3542
|
+
let constructIndex;
|
3543
|
+
let currentConstruct;
|
3544
|
+
let info;
|
3545
|
+
return Array.isArray(constructs2) ? handleListOfConstructs(constructs2) : "tokenize" in constructs2 ? (
|
3546
|
+
// @ts-expect-error Looks like a construct.
|
3547
|
+
handleListOfConstructs([constructs2])
|
3548
|
+
) : handleMapOfConstructs(constructs2);
|
3549
|
+
function handleMapOfConstructs(map) {
|
3550
|
+
return start;
|
3551
|
+
function start(code) {
|
3552
|
+
const def = code !== null && map[code];
|
3553
|
+
const all2 = code !== null && map.null;
|
3554
|
+
const list2 = [
|
3555
|
+
// To do: add more extension tests.
|
3556
|
+
/* c8 ignore next 2 */
|
3557
|
+
...Array.isArray(def) ? def : def ? [def] : [],
|
3558
|
+
...Array.isArray(all2) ? all2 : all2 ? [all2] : []
|
3559
|
+
];
|
3560
|
+
return handleListOfConstructs(list2)(code);
|
3561
|
+
}
|
3562
|
+
}
|
3563
|
+
function handleListOfConstructs(list2) {
|
3564
|
+
listOfConstructs = list2;
|
3565
|
+
constructIndex = 0;
|
3566
|
+
if (list2.length === 0) {
|
3567
|
+
return bogusState;
|
3568
|
+
}
|
3569
|
+
return handleConstruct(list2[constructIndex]);
|
3570
|
+
}
|
3571
|
+
function handleConstruct(construct) {
|
3572
|
+
return start;
|
3573
|
+
function start(code) {
|
3574
|
+
info = store();
|
3575
|
+
currentConstruct = construct;
|
3576
|
+
if (!construct.partial) {
|
3577
|
+
context.currentConstruct = construct;
|
3578
|
+
}
|
3579
|
+
if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) {
|
3580
|
+
return nok();
|
3581
|
+
}
|
3582
|
+
return construct.tokenize.call(
|
3583
|
+
// If we do have fields, create an object w/ `context` as its
|
3584
|
+
// prototype.
|
3585
|
+
// This allows a “live binding”, which is needed for `interrupt`.
|
3586
|
+
fields ? Object.assign(Object.create(context), fields) : context,
|
3587
|
+
effects,
|
3588
|
+
ok,
|
3589
|
+
nok
|
3590
|
+
)(code);
|
3591
|
+
}
|
3592
|
+
}
|
3593
|
+
function ok(code) {
|
3594
|
+
onreturn(currentConstruct, info);
|
3595
|
+
return returnState;
|
3596
|
+
}
|
3597
|
+
function nok(code) {
|
3598
|
+
info.restore();
|
3599
|
+
if (++constructIndex < listOfConstructs.length) {
|
3600
|
+
return handleConstruct(listOfConstructs[constructIndex]);
|
3601
|
+
}
|
3602
|
+
return bogusState;
|
3603
|
+
}
|
3604
|
+
}
|
3605
|
+
}
|
3606
|
+
function addResult(construct, from2) {
|
3607
|
+
if (construct.resolveAll && !resolveAllConstructs.includes(construct)) {
|
3608
|
+
resolveAllConstructs.push(construct);
|
3609
|
+
}
|
3610
|
+
if (construct.resolve) {
|
3611
|
+
splice(
|
3612
|
+
context.events,
|
3613
|
+
from2,
|
3614
|
+
context.events.length - from2,
|
3615
|
+
construct.resolve(context.events.slice(from2), context)
|
3616
|
+
);
|
3617
|
+
}
|
3618
|
+
if (construct.resolveTo) {
|
3619
|
+
context.events = construct.resolveTo(context.events, context);
|
3620
|
+
}
|
3621
|
+
}
|
3622
|
+
function store() {
|
3623
|
+
const startPoint = now();
|
3624
|
+
const startPrevious = context.previous;
|
3625
|
+
const startCurrentConstruct = context.currentConstruct;
|
3626
|
+
const startEventsIndex = context.events.length;
|
3627
|
+
const startStack = Array.from(stack);
|
3628
|
+
return {
|
3629
|
+
restore,
|
3630
|
+
from: startEventsIndex
|
3631
|
+
};
|
3632
|
+
function restore() {
|
3633
|
+
point2 = startPoint;
|
3634
|
+
context.previous = startPrevious;
|
3635
|
+
context.currentConstruct = startCurrentConstruct;
|
3636
|
+
context.events.length = startEventsIndex;
|
3637
|
+
stack = startStack;
|
3638
|
+
accountForPotentialSkip();
|
3639
|
+
}
|
3640
|
+
}
|
3641
|
+
function accountForPotentialSkip() {
|
3642
|
+
if (point2.line in columnStart && point2.column < 2) {
|
3643
|
+
point2.column = columnStart[point2.line];
|
3644
|
+
point2.offset += columnStart[point2.line] - 1;
|
3645
|
+
}
|
3646
|
+
}
|
3647
|
+
}
|
3648
|
+
function sliceChunks(chunks, token) {
|
3649
|
+
const startIndex = token.start._index;
|
3650
|
+
const startBufferIndex = token.start._bufferIndex;
|
3651
|
+
const endIndex = token.end._index;
|
3652
|
+
const endBufferIndex = token.end._bufferIndex;
|
3653
|
+
let view;
|
3654
|
+
if (startIndex === endIndex) {
|
3655
|
+
view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
|
3656
|
+
} else {
|
3657
|
+
view = chunks.slice(startIndex, endIndex);
|
3658
|
+
if (startBufferIndex > -1) {
|
3659
|
+
const head = view[0];
|
3660
|
+
if (typeof head === "string") {
|
3661
|
+
view[0] = head.slice(startBufferIndex);
|
3662
|
+
} else {
|
3663
|
+
view.shift();
|
3664
|
+
}
|
3665
|
+
}
|
3666
|
+
if (endBufferIndex > 0) {
|
3667
|
+
view.push(chunks[endIndex].slice(0, endBufferIndex));
|
3668
|
+
}
|
3669
|
+
}
|
3670
|
+
return view;
|
3671
|
+
}
|
3672
|
+
function serializeChunks(chunks, expandTabs) {
|
3673
|
+
let index2 = -1;
|
3674
|
+
const result = [];
|
3675
|
+
let atTab;
|
3676
|
+
while (++index2 < chunks.length) {
|
3677
|
+
const chunk = chunks[index2];
|
3678
|
+
let value;
|
3679
|
+
if (typeof chunk === "string") {
|
3680
|
+
value = chunk;
|
3681
|
+
} else
|
3682
|
+
switch (chunk) {
|
3683
|
+
case -5: {
|
3684
|
+
value = "\r";
|
3685
|
+
break;
|
3686
|
+
}
|
3687
|
+
case -4: {
|
3688
|
+
value = "\n";
|
3689
|
+
break;
|
3690
|
+
}
|
3691
|
+
case -3: {
|
3692
|
+
value = "\r\n";
|
3693
|
+
break;
|
3694
|
+
}
|
3695
|
+
case -2: {
|
3696
|
+
value = expandTabs ? " " : " ";
|
3697
|
+
break;
|
3698
|
+
}
|
3699
|
+
case -1: {
|
3700
|
+
if (!expandTabs && atTab)
|
3701
|
+
continue;
|
3702
|
+
value = " ";
|
3703
|
+
break;
|
3704
|
+
}
|
3705
|
+
default: {
|
3706
|
+
value = String.fromCharCode(chunk);
|
3707
|
+
}
|
3708
|
+
}
|
3709
|
+
atTab = chunk === -2;
|
3710
|
+
result.push(value);
|
3711
|
+
}
|
3712
|
+
return result.join("");
|
3713
|
+
}
|
3714
|
+
const document$1 = {
|
3715
|
+
[42]: list,
|
3716
|
+
[43]: list,
|
3717
|
+
[45]: list,
|
3718
|
+
[48]: list,
|
3719
|
+
[49]: list,
|
3720
|
+
[50]: list,
|
3721
|
+
[51]: list,
|
3722
|
+
[52]: list,
|
3723
|
+
[53]: list,
|
3724
|
+
[54]: list,
|
3725
|
+
[55]: list,
|
3726
|
+
[56]: list,
|
3727
|
+
[57]: list,
|
3728
|
+
[62]: blockQuote
|
3729
|
+
};
|
3730
|
+
const contentInitial = {
|
3731
|
+
[91]: definition
|
3732
|
+
};
|
3733
|
+
const flowInitial = {
|
3734
|
+
[-2]: codeIndented,
|
3735
|
+
[-1]: codeIndented,
|
3736
|
+
[32]: codeIndented
|
3737
|
+
};
|
3738
|
+
const flow = {
|
3739
|
+
[35]: headingAtx,
|
3740
|
+
[42]: thematicBreak,
|
3741
|
+
[45]: [setextUnderline, thematicBreak],
|
3742
|
+
[60]: htmlFlow,
|
3743
|
+
[61]: setextUnderline,
|
3744
|
+
[95]: thematicBreak,
|
3745
|
+
[96]: codeFenced,
|
3746
|
+
[126]: codeFenced
|
3747
|
+
};
|
3748
|
+
const string = {
|
3749
|
+
[38]: characterReference,
|
3750
|
+
[92]: characterEscape
|
3751
|
+
};
|
3752
|
+
const text = {
|
3753
|
+
[-5]: lineEnding,
|
3754
|
+
[-4]: lineEnding,
|
3755
|
+
[-3]: lineEnding,
|
3756
|
+
[33]: labelStartImage,
|
3757
|
+
[38]: characterReference,
|
3758
|
+
[42]: attention,
|
3759
|
+
[60]: [autolink, htmlText],
|
3760
|
+
[91]: labelStartLink,
|
3761
|
+
[92]: [hardBreakEscape, characterEscape],
|
3762
|
+
[93]: labelEnd,
|
3763
|
+
[95]: attention,
|
3764
|
+
[96]: codeText
|
3765
|
+
};
|
3766
|
+
const insideSpan = {
|
3767
|
+
null: [attention, resolver]
|
3768
|
+
};
|
3769
|
+
const attentionMarkers = {
|
3770
|
+
null: [42, 95]
|
3771
|
+
};
|
3772
|
+
const disable = {
|
3773
|
+
null: []
|
3774
|
+
};
|
3775
|
+
const defaultConstructs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
3776
|
+
__proto__: null,
|
3777
|
+
attentionMarkers,
|
3778
|
+
contentInitial,
|
3779
|
+
disable,
|
3780
|
+
document: document$1,
|
3781
|
+
flow,
|
3782
|
+
flowInitial,
|
3783
|
+
insideSpan,
|
3784
|
+
string,
|
3785
|
+
text
|
3786
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
3787
|
+
function parse(options) {
|
3788
|
+
const settings = options || {};
|
3789
|
+
const constructs2 = (
|
3790
|
+
/** @type {FullNormalizedExtension} */
|
3791
|
+
combineExtensions([defaultConstructs, ...settings.extensions || []])
|
3792
|
+
);
|
3793
|
+
const parser = {
|
3794
|
+
defined: [],
|
3795
|
+
lazy: {},
|
3796
|
+
constructs: constructs2,
|
3797
|
+
content: create(content$1),
|
3798
|
+
document: create(document$2),
|
3799
|
+
flow: create(flow$1),
|
3800
|
+
string: create(string$1),
|
3801
|
+
text: create(text$1)
|
3802
|
+
};
|
3803
|
+
return parser;
|
3804
|
+
function create(initial) {
|
3805
|
+
return creator;
|
3806
|
+
function creator(from) {
|
3807
|
+
return createTokenizer(parser, initial, from);
|
3808
|
+
}
|
3809
|
+
}
|
3810
|
+
}
|
3811
|
+
const search = /[\0\t\n\r]/g;
|
3812
|
+
function preprocess() {
|
3813
|
+
let column = 1;
|
3814
|
+
let buffer = "";
|
3815
|
+
let start = true;
|
3816
|
+
let atCarriageReturn;
|
3817
|
+
return preprocessor;
|
3818
|
+
function preprocessor(value, encoding, end) {
|
3819
|
+
const chunks = [];
|
3820
|
+
let match;
|
3821
|
+
let next;
|
3822
|
+
let startPosition;
|
3823
|
+
let endPosition;
|
3824
|
+
let code;
|
3825
|
+
value = buffer + value.toString(encoding);
|
3826
|
+
startPosition = 0;
|
3827
|
+
buffer = "";
|
3828
|
+
if (start) {
|
3829
|
+
if (value.charCodeAt(0) === 65279) {
|
3830
|
+
startPosition++;
|
3831
|
+
}
|
3832
|
+
start = void 0;
|
3833
|
+
}
|
3834
|
+
while (startPosition < value.length) {
|
3835
|
+
search.lastIndex = startPosition;
|
3836
|
+
match = search.exec(value);
|
3837
|
+
endPosition = match && match.index !== void 0 ? match.index : value.length;
|
3838
|
+
code = value.charCodeAt(endPosition);
|
3839
|
+
if (!match) {
|
3840
|
+
buffer = value.slice(startPosition);
|
3841
|
+
break;
|
3842
|
+
}
|
3843
|
+
if (code === 10 && startPosition === endPosition && atCarriageReturn) {
|
3844
|
+
chunks.push(-3);
|
3845
|
+
atCarriageReturn = void 0;
|
3846
|
+
} else {
|
3847
|
+
if (atCarriageReturn) {
|
3848
|
+
chunks.push(-5);
|
3849
|
+
atCarriageReturn = void 0;
|
3850
|
+
}
|
3851
|
+
if (startPosition < endPosition) {
|
3852
|
+
chunks.push(value.slice(startPosition, endPosition));
|
3853
|
+
column += endPosition - startPosition;
|
3854
|
+
}
|
3855
|
+
switch (code) {
|
3856
|
+
case 0: {
|
3857
|
+
chunks.push(65533);
|
3858
|
+
column++;
|
3859
|
+
break;
|
3860
|
+
}
|
3861
|
+
case 9: {
|
3862
|
+
next = Math.ceil(column / 4) * 4;
|
3863
|
+
chunks.push(-2);
|
3864
|
+
while (column++ < next)
|
3865
|
+
chunks.push(-1);
|
3866
|
+
break;
|
3867
|
+
}
|
3868
|
+
case 10: {
|
3869
|
+
chunks.push(-4);
|
3870
|
+
column = 1;
|
3871
|
+
break;
|
3872
|
+
}
|
3873
|
+
default: {
|
3874
|
+
atCarriageReturn = true;
|
3875
|
+
column = 1;
|
3876
|
+
}
|
3877
|
+
}
|
3878
|
+
}
|
3879
|
+
startPosition = endPosition + 1;
|
3880
|
+
}
|
3881
|
+
if (end) {
|
3882
|
+
if (atCarriageReturn)
|
3883
|
+
chunks.push(-5);
|
3884
|
+
if (buffer)
|
3885
|
+
chunks.push(buffer);
|
3886
|
+
chunks.push(null);
|
3887
|
+
}
|
3888
|
+
return chunks;
|
3889
|
+
}
|
3890
|
+
}
|
3891
|
+
function postprocess(events) {
|
3892
|
+
while (!subtokenize(events)) {
|
3893
|
+
}
|
3894
|
+
return events;
|
3895
|
+
}
|
3896
|
+
function decodeNumericCharacterReference(value, base) {
|
3897
|
+
const code = Number.parseInt(value, base);
|
3898
|
+
if (
|
3899
|
+
// C0 except for HT, LF, FF, CR, space.
|
3900
|
+
code < 9 || code === 11 || code > 13 && code < 32 || // Control character (DEL) of C0, and C1 controls.
|
3901
|
+
code > 126 && code < 160 || // Lone high surrogates and low surrogates.
|
3902
|
+
code > 55295 && code < 57344 || // Noncharacters.
|
3903
|
+
code > 64975 && code < 65008 || (code & 65535) === 65535 || (code & 65535) === 65534 || // Out of range
|
3904
|
+
code > 1114111
|
3905
|
+
) {
|
3906
|
+
return "�";
|
3907
|
+
}
|
3908
|
+
return String.fromCharCode(code);
|
3909
|
+
}
|
3910
|
+
const characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
|
3911
|
+
function decodeString(value) {
|
3912
|
+
return value.replace(characterEscapeOrReference, decode);
|
3913
|
+
}
|
3914
|
+
function decode($0, $1, $2) {
|
3915
|
+
if ($1) {
|
3916
|
+
return $1;
|
3917
|
+
}
|
3918
|
+
const head = $2.charCodeAt(0);
|
3919
|
+
if (head === 35) {
|
3920
|
+
const head2 = $2.charCodeAt(1);
|
3921
|
+
const hex = head2 === 120 || head2 === 88;
|
3922
|
+
return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);
|
3923
|
+
}
|
3924
|
+
return decodeNamedCharacterReference($2) || $0;
|
3925
|
+
}
|
3926
|
+
function stringifyPosition(value) {
|
3927
|
+
if (!value || typeof value !== "object") {
|
3928
|
+
return "";
|
3929
|
+
}
|
3930
|
+
if ("position" in value || "type" in value) {
|
3931
|
+
return position(value.position);
|
3932
|
+
}
|
3933
|
+
if ("start" in value || "end" in value) {
|
3934
|
+
return position(value);
|
3935
|
+
}
|
3936
|
+
if ("line" in value || "column" in value) {
|
3937
|
+
return point$1(value);
|
3938
|
+
}
|
3939
|
+
return "";
|
3940
|
+
}
|
3941
|
+
function point$1(point2) {
|
3942
|
+
return index(point2 && point2.line) + ":" + index(point2 && point2.column);
|
3943
|
+
}
|
3944
|
+
function position(pos) {
|
3945
|
+
return point$1(pos && pos.start) + "-" + point$1(pos && pos.end);
|
3946
|
+
}
|
3947
|
+
function index(value) {
|
3948
|
+
return value && typeof value === "number" ? value : 1;
|
3949
|
+
}
|
3950
|
+
const own = {}.hasOwnProperty;
|
3951
|
+
const fromMarkdown = (
|
3952
|
+
/**
|
3953
|
+
* @type {(
|
3954
|
+
* ((value: Value, encoding: Encoding, options?: Options | null | undefined) => Root) &
|
3955
|
+
* ((value: Value, options?: Options | null | undefined) => Root)
|
3956
|
+
* )}
|
3957
|
+
*/
|
3958
|
+
/**
|
3959
|
+
* @param {Value} value
|
3960
|
+
* @param {Encoding | Options | null | undefined} [encoding]
|
3961
|
+
* @param {Options | null | undefined} [options]
|
3962
|
+
* @returns {Root}
|
3963
|
+
*/
|
3964
|
+
function(value, encoding, options) {
|
3965
|
+
if (typeof encoding !== "string") {
|
3966
|
+
options = encoding;
|
3967
|
+
encoding = void 0;
|
3968
|
+
}
|
3969
|
+
return compiler(options)(
|
3970
|
+
postprocess(
|
3971
|
+
parse(options).document().write(preprocess()(value, encoding, true))
|
3972
|
+
)
|
3973
|
+
);
|
3974
|
+
}
|
3975
|
+
);
|
3976
|
+
function compiler(options) {
|
3977
|
+
const config = {
|
3978
|
+
transforms: [],
|
3979
|
+
canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
|
3980
|
+
enter: {
|
3981
|
+
autolink: opener(link),
|
3982
|
+
autolinkProtocol: onenterdata,
|
3983
|
+
autolinkEmail: onenterdata,
|
3984
|
+
atxHeading: opener(heading),
|
3985
|
+
blockQuote: opener(blockQuote2),
|
3986
|
+
characterEscape: onenterdata,
|
3987
|
+
characterReference: onenterdata,
|
3988
|
+
codeFenced: opener(codeFlow),
|
3989
|
+
codeFencedFenceInfo: buffer,
|
3990
|
+
codeFencedFenceMeta: buffer,
|
3991
|
+
codeIndented: opener(codeFlow, buffer),
|
3992
|
+
codeText: opener(codeText2, buffer),
|
3993
|
+
codeTextData: onenterdata,
|
3994
|
+
data: onenterdata,
|
3995
|
+
codeFlowValue: onenterdata,
|
3996
|
+
definition: opener(definition2),
|
3997
|
+
definitionDestinationString: buffer,
|
3998
|
+
definitionLabelString: buffer,
|
3999
|
+
definitionTitleString: buffer,
|
4000
|
+
emphasis: opener(emphasis),
|
4001
|
+
hardBreakEscape: opener(hardBreak),
|
4002
|
+
hardBreakTrailing: opener(hardBreak),
|
4003
|
+
htmlFlow: opener(html, buffer),
|
4004
|
+
htmlFlowData: onenterdata,
|
4005
|
+
htmlText: opener(html, buffer),
|
4006
|
+
htmlTextData: onenterdata,
|
4007
|
+
image: opener(image),
|
4008
|
+
label: buffer,
|
4009
|
+
link: opener(link),
|
4010
|
+
listItem: opener(listItem),
|
4011
|
+
listItemValue: onenterlistitemvalue,
|
4012
|
+
listOrdered: opener(list2, onenterlistordered),
|
4013
|
+
listUnordered: opener(list2),
|
4014
|
+
paragraph: opener(paragraph),
|
4015
|
+
reference: onenterreference,
|
4016
|
+
referenceString: buffer,
|
4017
|
+
resourceDestinationString: buffer,
|
4018
|
+
resourceTitleString: buffer,
|
4019
|
+
setextHeading: opener(heading),
|
4020
|
+
strong: opener(strong),
|
4021
|
+
thematicBreak: opener(thematicBreak2)
|
4022
|
+
},
|
4023
|
+
exit: {
|
4024
|
+
atxHeading: closer(),
|
4025
|
+
atxHeadingSequence: onexitatxheadingsequence,
|
4026
|
+
autolink: closer(),
|
4027
|
+
autolinkEmail: onexitautolinkemail,
|
4028
|
+
autolinkProtocol: onexitautolinkprotocol,
|
4029
|
+
blockQuote: closer(),
|
4030
|
+
characterEscapeValue: onexitdata,
|
4031
|
+
characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,
|
4032
|
+
characterReferenceMarkerNumeric: onexitcharacterreferencemarker,
|
4033
|
+
characterReferenceValue: onexitcharacterreferencevalue,
|
4034
|
+
codeFenced: closer(onexitcodefenced),
|
4035
|
+
codeFencedFence: onexitcodefencedfence,
|
4036
|
+
codeFencedFenceInfo: onexitcodefencedfenceinfo,
|
4037
|
+
codeFencedFenceMeta: onexitcodefencedfencemeta,
|
4038
|
+
codeFlowValue: onexitdata,
|
4039
|
+
codeIndented: closer(onexitcodeindented),
|
4040
|
+
codeText: closer(onexitcodetext),
|
4041
|
+
codeTextData: onexitdata,
|
4042
|
+
data: onexitdata,
|
4043
|
+
definition: closer(),
|
4044
|
+
definitionDestinationString: onexitdefinitiondestinationstring,
|
4045
|
+
definitionLabelString: onexitdefinitionlabelstring,
|
4046
|
+
definitionTitleString: onexitdefinitiontitlestring,
|
4047
|
+
emphasis: closer(),
|
4048
|
+
hardBreakEscape: closer(onexithardbreak),
|
4049
|
+
hardBreakTrailing: closer(onexithardbreak),
|
4050
|
+
htmlFlow: closer(onexithtmlflow),
|
4051
|
+
htmlFlowData: onexitdata,
|
4052
|
+
htmlText: closer(onexithtmltext),
|
4053
|
+
htmlTextData: onexitdata,
|
4054
|
+
image: closer(onexitimage),
|
4055
|
+
label: onexitlabel,
|
4056
|
+
labelText: onexitlabeltext,
|
4057
|
+
lineEnding: onexitlineending,
|
4058
|
+
link: closer(onexitlink),
|
4059
|
+
listItem: closer(),
|
4060
|
+
listOrdered: closer(),
|
4061
|
+
listUnordered: closer(),
|
4062
|
+
paragraph: closer(),
|
4063
|
+
referenceString: onexitreferencestring,
|
4064
|
+
resourceDestinationString: onexitresourcedestinationstring,
|
4065
|
+
resourceTitleString: onexitresourcetitlestring,
|
4066
|
+
resource: onexitresource,
|
4067
|
+
setextHeading: closer(onexitsetextheading),
|
4068
|
+
setextHeadingLineSequence: onexitsetextheadinglinesequence,
|
4069
|
+
setextHeadingText: onexitsetextheadingtext,
|
4070
|
+
strong: closer(),
|
4071
|
+
thematicBreak: closer()
|
4072
|
+
}
|
4073
|
+
};
|
4074
|
+
configure(config, (options || {}).mdastExtensions || []);
|
4075
|
+
const data = {};
|
4076
|
+
return compile;
|
4077
|
+
function compile(events) {
|
4078
|
+
let tree = {
|
4079
|
+
type: "root",
|
4080
|
+
children: []
|
4081
|
+
};
|
4082
|
+
const context = {
|
4083
|
+
stack: [tree],
|
4084
|
+
tokenStack: [],
|
4085
|
+
config,
|
4086
|
+
enter,
|
4087
|
+
exit: exit2,
|
4088
|
+
buffer,
|
4089
|
+
resume,
|
4090
|
+
setData,
|
4091
|
+
getData
|
4092
|
+
};
|
4093
|
+
const listStack = [];
|
4094
|
+
let index2 = -1;
|
4095
|
+
while (++index2 < events.length) {
|
4096
|
+
if (events[index2][1].type === "listOrdered" || events[index2][1].type === "listUnordered") {
|
4097
|
+
if (events[index2][0] === "enter") {
|
4098
|
+
listStack.push(index2);
|
4099
|
+
} else {
|
4100
|
+
const tail = listStack.pop();
|
4101
|
+
index2 = prepareList(events, tail, index2);
|
4102
|
+
}
|
4103
|
+
}
|
4104
|
+
}
|
4105
|
+
index2 = -1;
|
4106
|
+
while (++index2 < events.length) {
|
4107
|
+
const handler = config[events[index2][0]];
|
4108
|
+
if (own.call(handler, events[index2][1].type)) {
|
4109
|
+
handler[events[index2][1].type].call(
|
4110
|
+
Object.assign(
|
4111
|
+
{
|
4112
|
+
sliceSerialize: events[index2][2].sliceSerialize
|
4113
|
+
},
|
4114
|
+
context
|
4115
|
+
),
|
4116
|
+
events[index2][1]
|
4117
|
+
);
|
4118
|
+
}
|
4119
|
+
}
|
4120
|
+
if (context.tokenStack.length > 0) {
|
4121
|
+
const tail = context.tokenStack[context.tokenStack.length - 1];
|
4122
|
+
const handler = tail[1] || defaultOnError;
|
4123
|
+
handler.call(context, void 0, tail[0]);
|
4124
|
+
}
|
4125
|
+
tree.position = {
|
4126
|
+
start: point(
|
4127
|
+
events.length > 0 ? events[0][1].start : {
|
4128
|
+
line: 1,
|
4129
|
+
column: 1,
|
4130
|
+
offset: 0
|
4131
|
+
}
|
4132
|
+
),
|
4133
|
+
end: point(
|
4134
|
+
events.length > 0 ? events[events.length - 2][1].end : {
|
4135
|
+
line: 1,
|
4136
|
+
column: 1,
|
4137
|
+
offset: 0
|
4138
|
+
}
|
4139
|
+
)
|
4140
|
+
};
|
4141
|
+
index2 = -1;
|
4142
|
+
while (++index2 < config.transforms.length) {
|
4143
|
+
tree = config.transforms[index2](tree) || tree;
|
4144
|
+
}
|
4145
|
+
return tree;
|
4146
|
+
}
|
4147
|
+
function prepareList(events, start, length) {
|
4148
|
+
let index2 = start - 1;
|
4149
|
+
let containerBalance = -1;
|
4150
|
+
let listSpread = false;
|
4151
|
+
let listItem2;
|
4152
|
+
let lineIndex;
|
4153
|
+
let firstBlankLineIndex;
|
4154
|
+
let atMarker;
|
4155
|
+
while (++index2 <= length) {
|
4156
|
+
const event = events[index2];
|
4157
|
+
if (event[1].type === "listUnordered" || event[1].type === "listOrdered" || event[1].type === "blockQuote") {
|
4158
|
+
if (event[0] === "enter") {
|
4159
|
+
containerBalance++;
|
4160
|
+
} else {
|
4161
|
+
containerBalance--;
|
4162
|
+
}
|
4163
|
+
atMarker = void 0;
|
4164
|
+
} else if (event[1].type === "lineEndingBlank") {
|
4165
|
+
if (event[0] === "enter") {
|
4166
|
+
if (listItem2 && !atMarker && !containerBalance && !firstBlankLineIndex) {
|
4167
|
+
firstBlankLineIndex = index2;
|
4168
|
+
}
|
4169
|
+
atMarker = void 0;
|
4170
|
+
}
|
4171
|
+
} else if (event[1].type === "linePrefix" || event[1].type === "listItemValue" || event[1].type === "listItemMarker" || event[1].type === "listItemPrefix" || event[1].type === "listItemPrefixWhitespace")
|
4172
|
+
;
|
4173
|
+
else {
|
4174
|
+
atMarker = void 0;
|
4175
|
+
}
|
4176
|
+
if (!containerBalance && event[0] === "enter" && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === "exit" && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) {
|
4177
|
+
if (listItem2) {
|
4178
|
+
let tailIndex = index2;
|
4179
|
+
lineIndex = void 0;
|
4180
|
+
while (tailIndex--) {
|
4181
|
+
const tailEvent = events[tailIndex];
|
4182
|
+
if (tailEvent[1].type === "lineEnding" || tailEvent[1].type === "lineEndingBlank") {
|
4183
|
+
if (tailEvent[0] === "exit")
|
4184
|
+
continue;
|
4185
|
+
if (lineIndex) {
|
4186
|
+
events[lineIndex][1].type = "lineEndingBlank";
|
4187
|
+
listSpread = true;
|
4188
|
+
}
|
4189
|
+
tailEvent[1].type = "lineEnding";
|
4190
|
+
lineIndex = tailIndex;
|
4191
|
+
} else if (tailEvent[1].type === "linePrefix" || tailEvent[1].type === "blockQuotePrefix" || tailEvent[1].type === "blockQuotePrefixWhitespace" || tailEvent[1].type === "blockQuoteMarker" || tailEvent[1].type === "listItemIndent")
|
4192
|
+
;
|
4193
|
+
else {
|
4194
|
+
break;
|
4195
|
+
}
|
4196
|
+
}
|
4197
|
+
if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) {
|
4198
|
+
listItem2._spread = true;
|
4199
|
+
}
|
4200
|
+
listItem2.end = Object.assign(
|
4201
|
+
{},
|
4202
|
+
lineIndex ? events[lineIndex][1].start : event[1].end
|
4203
|
+
);
|
4204
|
+
events.splice(lineIndex || index2, 0, ["exit", listItem2, event[2]]);
|
4205
|
+
index2++;
|
4206
|
+
length++;
|
4207
|
+
}
|
4208
|
+
if (event[1].type === "listItemPrefix") {
|
4209
|
+
listItem2 = {
|
4210
|
+
type: "listItem",
|
4211
|
+
_spread: false,
|
4212
|
+
start: Object.assign({}, event[1].start),
|
4213
|
+
// @ts-expect-error: we’ll add `end` in a second.
|
4214
|
+
end: void 0
|
4215
|
+
};
|
4216
|
+
events.splice(index2, 0, ["enter", listItem2, event[2]]);
|
4217
|
+
index2++;
|
4218
|
+
length++;
|
4219
|
+
firstBlankLineIndex = void 0;
|
4220
|
+
atMarker = true;
|
4221
|
+
}
|
4222
|
+
}
|
4223
|
+
}
|
4224
|
+
events[start][1]._spread = listSpread;
|
4225
|
+
return length;
|
4226
|
+
}
|
4227
|
+
function setData(key, value) {
|
4228
|
+
data[key] = value;
|
4229
|
+
}
|
4230
|
+
function getData(key) {
|
4231
|
+
return data[key];
|
4232
|
+
}
|
4233
|
+
function opener(create, and) {
|
4234
|
+
return open;
|
4235
|
+
function open(token) {
|
4236
|
+
enter.call(this, create(token), token);
|
4237
|
+
if (and)
|
4238
|
+
and.call(this, token);
|
4239
|
+
}
|
4240
|
+
}
|
4241
|
+
function buffer() {
|
4242
|
+
this.stack.push({
|
4243
|
+
type: "fragment",
|
4244
|
+
children: []
|
4245
|
+
});
|
4246
|
+
}
|
4247
|
+
function enter(node2, token, errorHandler) {
|
4248
|
+
const parent = this.stack[this.stack.length - 1];
|
4249
|
+
parent.children.push(node2);
|
4250
|
+
this.stack.push(node2);
|
4251
|
+
this.tokenStack.push([token, errorHandler]);
|
4252
|
+
node2.position = {
|
4253
|
+
start: point(token.start)
|
4254
|
+
};
|
4255
|
+
return node2;
|
4256
|
+
}
|
4257
|
+
function closer(and) {
|
4258
|
+
return close;
|
4259
|
+
function close(token) {
|
4260
|
+
if (and)
|
4261
|
+
and.call(this, token);
|
4262
|
+
exit2.call(this, token);
|
4263
|
+
}
|
4264
|
+
}
|
4265
|
+
function exit2(token, onExitError) {
|
4266
|
+
const node2 = this.stack.pop();
|
4267
|
+
const open = this.tokenStack.pop();
|
4268
|
+
if (!open) {
|
4269
|
+
throw new Error(
|
4270
|
+
"Cannot close `" + token.type + "` (" + stringifyPosition({
|
4271
|
+
start: token.start,
|
4272
|
+
end: token.end
|
4273
|
+
}) + "): it’s not open"
|
4274
|
+
);
|
4275
|
+
} else if (open[0].type !== token.type) {
|
4276
|
+
if (onExitError) {
|
4277
|
+
onExitError.call(this, token, open[0]);
|
4278
|
+
} else {
|
4279
|
+
const handler = open[1] || defaultOnError;
|
4280
|
+
handler.call(this, token, open[0]);
|
4281
|
+
}
|
4282
|
+
}
|
4283
|
+
node2.position.end = point(token.end);
|
4284
|
+
return node2;
|
4285
|
+
}
|
4286
|
+
function resume() {
|
4287
|
+
return toString(this.stack.pop());
|
4288
|
+
}
|
4289
|
+
function onenterlistordered() {
|
4290
|
+
setData("expectingFirstListItemValue", true);
|
4291
|
+
}
|
4292
|
+
function onenterlistitemvalue(token) {
|
4293
|
+
if (getData("expectingFirstListItemValue")) {
|
4294
|
+
const ancestor = this.stack[this.stack.length - 2];
|
4295
|
+
ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);
|
4296
|
+
setData("expectingFirstListItemValue");
|
4297
|
+
}
|
4298
|
+
}
|
4299
|
+
function onexitcodefencedfenceinfo() {
|
4300
|
+
const data2 = this.resume();
|
4301
|
+
const node2 = this.stack[this.stack.length - 1];
|
4302
|
+
node2.lang = data2;
|
4303
|
+
}
|
4304
|
+
function onexitcodefencedfencemeta() {
|
4305
|
+
const data2 = this.resume();
|
4306
|
+
const node2 = this.stack[this.stack.length - 1];
|
4307
|
+
node2.meta = data2;
|
4308
|
+
}
|
4309
|
+
function onexitcodefencedfence() {
|
4310
|
+
if (getData("flowCodeInside"))
|
4311
|
+
return;
|
4312
|
+
this.buffer();
|
4313
|
+
setData("flowCodeInside", true);
|
4314
|
+
}
|
4315
|
+
function onexitcodefenced() {
|
4316
|
+
const data2 = this.resume();
|
4317
|
+
const node2 = this.stack[this.stack.length - 1];
|
4318
|
+
node2.value = data2.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
|
4319
|
+
setData("flowCodeInside");
|
4320
|
+
}
|
4321
|
+
function onexitcodeindented() {
|
4322
|
+
const data2 = this.resume();
|
4323
|
+
const node2 = this.stack[this.stack.length - 1];
|
4324
|
+
node2.value = data2.replace(/(\r?\n|\r)$/g, "");
|
4325
|
+
}
|
4326
|
+
function onexitdefinitionlabelstring(token) {
|
4327
|
+
const label = this.resume();
|
4328
|
+
const node2 = this.stack[this.stack.length - 1];
|
4329
|
+
node2.label = label;
|
4330
|
+
node2.identifier = normalizeIdentifier(
|
4331
|
+
this.sliceSerialize(token)
|
4332
|
+
).toLowerCase();
|
4333
|
+
}
|
4334
|
+
function onexitdefinitiontitlestring() {
|
4335
|
+
const data2 = this.resume();
|
4336
|
+
const node2 = this.stack[this.stack.length - 1];
|
4337
|
+
node2.title = data2;
|
4338
|
+
}
|
4339
|
+
function onexitdefinitiondestinationstring() {
|
4340
|
+
const data2 = this.resume();
|
4341
|
+
const node2 = this.stack[this.stack.length - 1];
|
4342
|
+
node2.url = data2;
|
4343
|
+
}
|
4344
|
+
function onexitatxheadingsequence(token) {
|
4345
|
+
const node2 = this.stack[this.stack.length - 1];
|
4346
|
+
if (!node2.depth) {
|
4347
|
+
const depth = this.sliceSerialize(token).length;
|
4348
|
+
node2.depth = depth;
|
4349
|
+
}
|
4350
|
+
}
|
4351
|
+
function onexitsetextheadingtext() {
|
4352
|
+
setData("setextHeadingSlurpLineEnding", true);
|
4353
|
+
}
|
4354
|
+
function onexitsetextheadinglinesequence(token) {
|
4355
|
+
const node2 = this.stack[this.stack.length - 1];
|
4356
|
+
node2.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2;
|
4357
|
+
}
|
4358
|
+
function onexitsetextheading() {
|
4359
|
+
setData("setextHeadingSlurpLineEnding");
|
4360
|
+
}
|
4361
|
+
function onenterdata(token) {
|
4362
|
+
const node2 = this.stack[this.stack.length - 1];
|
4363
|
+
let tail = node2.children[node2.children.length - 1];
|
4364
|
+
if (!tail || tail.type !== "text") {
|
4365
|
+
tail = text2();
|
4366
|
+
tail.position = {
|
4367
|
+
start: point(token.start)
|
4368
|
+
};
|
4369
|
+
node2.children.push(tail);
|
4370
|
+
}
|
4371
|
+
this.stack.push(tail);
|
4372
|
+
}
|
4373
|
+
function onexitdata(token) {
|
4374
|
+
const tail = this.stack.pop();
|
4375
|
+
tail.value += this.sliceSerialize(token);
|
4376
|
+
tail.position.end = point(token.end);
|
4377
|
+
}
|
4378
|
+
function onexitlineending(token) {
|
4379
|
+
const context = this.stack[this.stack.length - 1];
|
4380
|
+
if (getData("atHardBreak")) {
|
4381
|
+
const tail = context.children[context.children.length - 1];
|
4382
|
+
tail.position.end = point(token.end);
|
4383
|
+
setData("atHardBreak");
|
4384
|
+
return;
|
4385
|
+
}
|
4386
|
+
if (!getData("setextHeadingSlurpLineEnding") && config.canContainEols.includes(context.type)) {
|
4387
|
+
onenterdata.call(this, token);
|
4388
|
+
onexitdata.call(this, token);
|
4389
|
+
}
|
4390
|
+
}
|
4391
|
+
function onexithardbreak() {
|
4392
|
+
setData("atHardBreak", true);
|
4393
|
+
}
|
4394
|
+
function onexithtmlflow() {
|
4395
|
+
const data2 = this.resume();
|
4396
|
+
const node2 = this.stack[this.stack.length - 1];
|
4397
|
+
node2.value = data2;
|
4398
|
+
}
|
4399
|
+
function onexithtmltext() {
|
4400
|
+
const data2 = this.resume();
|
4401
|
+
const node2 = this.stack[this.stack.length - 1];
|
4402
|
+
node2.value = data2;
|
4403
|
+
}
|
4404
|
+
function onexitcodetext() {
|
4405
|
+
const data2 = this.resume();
|
4406
|
+
const node2 = this.stack[this.stack.length - 1];
|
4407
|
+
node2.value = data2;
|
4408
|
+
}
|
4409
|
+
function onexitlink() {
|
4410
|
+
const node2 = this.stack[this.stack.length - 1];
|
4411
|
+
if (getData("inReference")) {
|
4412
|
+
const referenceType = getData("referenceType") || "shortcut";
|
4413
|
+
node2.type += "Reference";
|
4414
|
+
node2.referenceType = referenceType;
|
4415
|
+
delete node2.url;
|
4416
|
+
delete node2.title;
|
4417
|
+
} else {
|
4418
|
+
delete node2.identifier;
|
4419
|
+
delete node2.label;
|
4420
|
+
}
|
4421
|
+
setData("referenceType");
|
4422
|
+
}
|
4423
|
+
function onexitimage() {
|
4424
|
+
const node2 = this.stack[this.stack.length - 1];
|
4425
|
+
if (getData("inReference")) {
|
4426
|
+
const referenceType = getData("referenceType") || "shortcut";
|
4427
|
+
node2.type += "Reference";
|
4428
|
+
node2.referenceType = referenceType;
|
4429
|
+
delete node2.url;
|
4430
|
+
delete node2.title;
|
4431
|
+
} else {
|
4432
|
+
delete node2.identifier;
|
4433
|
+
delete node2.label;
|
4434
|
+
}
|
4435
|
+
setData("referenceType");
|
4436
|
+
}
|
4437
|
+
function onexitlabeltext(token) {
|
4438
|
+
const string2 = this.sliceSerialize(token);
|
4439
|
+
const ancestor = this.stack[this.stack.length - 2];
|
4440
|
+
ancestor.label = decodeString(string2);
|
4441
|
+
ancestor.identifier = normalizeIdentifier(string2).toLowerCase();
|
4442
|
+
}
|
4443
|
+
function onexitlabel() {
|
4444
|
+
const fragment = this.stack[this.stack.length - 1];
|
4445
|
+
const value = this.resume();
|
4446
|
+
const node2 = this.stack[this.stack.length - 1];
|
4447
|
+
setData("inReference", true);
|
4448
|
+
if (node2.type === "link") {
|
4449
|
+
const children = fragment.children;
|
4450
|
+
node2.children = children;
|
4451
|
+
} else {
|
4452
|
+
node2.alt = value;
|
4453
|
+
}
|
4454
|
+
}
|
4455
|
+
function onexitresourcedestinationstring() {
|
4456
|
+
const data2 = this.resume();
|
4457
|
+
const node2 = this.stack[this.stack.length - 1];
|
4458
|
+
node2.url = data2;
|
4459
|
+
}
|
4460
|
+
function onexitresourcetitlestring() {
|
4461
|
+
const data2 = this.resume();
|
4462
|
+
const node2 = this.stack[this.stack.length - 1];
|
4463
|
+
node2.title = data2;
|
4464
|
+
}
|
4465
|
+
function onexitresource() {
|
4466
|
+
setData("inReference");
|
4467
|
+
}
|
4468
|
+
function onenterreference() {
|
4469
|
+
setData("referenceType", "collapsed");
|
4470
|
+
}
|
4471
|
+
function onexitreferencestring(token) {
|
4472
|
+
const label = this.resume();
|
4473
|
+
const node2 = this.stack[this.stack.length - 1];
|
4474
|
+
node2.label = label;
|
4475
|
+
node2.identifier = normalizeIdentifier(
|
4476
|
+
this.sliceSerialize(token)
|
4477
|
+
).toLowerCase();
|
4478
|
+
setData("referenceType", "full");
|
4479
|
+
}
|
4480
|
+
function onexitcharacterreferencemarker(token) {
|
4481
|
+
setData("characterReferenceType", token.type);
|
4482
|
+
}
|
4483
|
+
function onexitcharacterreferencevalue(token) {
|
4484
|
+
const data2 = this.sliceSerialize(token);
|
4485
|
+
const type = getData("characterReferenceType");
|
4486
|
+
let value;
|
4487
|
+
if (type) {
|
4488
|
+
value = decodeNumericCharacterReference(
|
4489
|
+
data2,
|
4490
|
+
type === "characterReferenceMarkerNumeric" ? 10 : 16
|
4491
|
+
);
|
4492
|
+
setData("characterReferenceType");
|
4493
|
+
} else {
|
4494
|
+
const result = decodeNamedCharacterReference(data2);
|
4495
|
+
value = result;
|
4496
|
+
}
|
4497
|
+
const tail = this.stack.pop();
|
4498
|
+
tail.value += value;
|
4499
|
+
tail.position.end = point(token.end);
|
4500
|
+
}
|
4501
|
+
function onexitautolinkprotocol(token) {
|
4502
|
+
onexitdata.call(this, token);
|
4503
|
+
const node2 = this.stack[this.stack.length - 1];
|
4504
|
+
node2.url = this.sliceSerialize(token);
|
4505
|
+
}
|
4506
|
+
function onexitautolinkemail(token) {
|
4507
|
+
onexitdata.call(this, token);
|
4508
|
+
const node2 = this.stack[this.stack.length - 1];
|
4509
|
+
node2.url = "mailto:" + this.sliceSerialize(token);
|
4510
|
+
}
|
4511
|
+
function blockQuote2() {
|
4512
|
+
return {
|
4513
|
+
type: "blockquote",
|
4514
|
+
children: []
|
4515
|
+
};
|
4516
|
+
}
|
4517
|
+
function codeFlow() {
|
4518
|
+
return {
|
4519
|
+
type: "code",
|
4520
|
+
lang: null,
|
4521
|
+
meta: null,
|
4522
|
+
value: ""
|
4523
|
+
};
|
4524
|
+
}
|
4525
|
+
function codeText2() {
|
4526
|
+
return {
|
4527
|
+
type: "inlineCode",
|
4528
|
+
value: ""
|
4529
|
+
};
|
4530
|
+
}
|
4531
|
+
function definition2() {
|
4532
|
+
return {
|
4533
|
+
type: "definition",
|
4534
|
+
identifier: "",
|
4535
|
+
label: null,
|
4536
|
+
title: null,
|
4537
|
+
url: ""
|
4538
|
+
};
|
4539
|
+
}
|
4540
|
+
function emphasis() {
|
4541
|
+
return {
|
4542
|
+
type: "emphasis",
|
4543
|
+
children: []
|
4544
|
+
};
|
4545
|
+
}
|
4546
|
+
function heading() {
|
4547
|
+
return {
|
4548
|
+
type: "heading",
|
4549
|
+
depth: void 0,
|
4550
|
+
children: []
|
4551
|
+
};
|
4552
|
+
}
|
4553
|
+
function hardBreak() {
|
4554
|
+
return {
|
4555
|
+
type: "break"
|
4556
|
+
};
|
4557
|
+
}
|
4558
|
+
function html() {
|
4559
|
+
return {
|
4560
|
+
type: "html",
|
4561
|
+
value: ""
|
4562
|
+
};
|
4563
|
+
}
|
4564
|
+
function image() {
|
4565
|
+
return {
|
4566
|
+
type: "image",
|
4567
|
+
title: null,
|
4568
|
+
url: "",
|
4569
|
+
alt: null
|
4570
|
+
};
|
4571
|
+
}
|
4572
|
+
function link() {
|
4573
|
+
return {
|
4574
|
+
type: "link",
|
4575
|
+
title: null,
|
4576
|
+
url: "",
|
4577
|
+
children: []
|
4578
|
+
};
|
4579
|
+
}
|
4580
|
+
function list2(token) {
|
4581
|
+
return {
|
4582
|
+
type: "list",
|
4583
|
+
ordered: token.type === "listOrdered",
|
4584
|
+
start: null,
|
4585
|
+
spread: token._spread,
|
4586
|
+
children: []
|
4587
|
+
};
|
4588
|
+
}
|
4589
|
+
function listItem(token) {
|
4590
|
+
return {
|
4591
|
+
type: "listItem",
|
4592
|
+
spread: token._spread,
|
4593
|
+
checked: null,
|
4594
|
+
children: []
|
4595
|
+
};
|
4596
|
+
}
|
4597
|
+
function paragraph() {
|
4598
|
+
return {
|
4599
|
+
type: "paragraph",
|
4600
|
+
children: []
|
4601
|
+
};
|
4602
|
+
}
|
4603
|
+
function strong() {
|
4604
|
+
return {
|
4605
|
+
type: "strong",
|
4606
|
+
children: []
|
4607
|
+
};
|
4608
|
+
}
|
4609
|
+
function text2() {
|
4610
|
+
return {
|
4611
|
+
type: "text",
|
4612
|
+
value: ""
|
4613
|
+
};
|
4614
|
+
}
|
4615
|
+
function thematicBreak2() {
|
4616
|
+
return {
|
4617
|
+
type: "thematicBreak"
|
4618
|
+
};
|
4619
|
+
}
|
4620
|
+
}
|
4621
|
+
function point(d) {
|
4622
|
+
return {
|
4623
|
+
line: d.line,
|
4624
|
+
column: d.column,
|
4625
|
+
offset: d.offset
|
4626
|
+
};
|
4627
|
+
}
|
4628
|
+
function configure(combined, extensions) {
|
4629
|
+
let index2 = -1;
|
4630
|
+
while (++index2 < extensions.length) {
|
4631
|
+
const value = extensions[index2];
|
4632
|
+
if (Array.isArray(value)) {
|
4633
|
+
configure(combined, value);
|
4634
|
+
} else {
|
4635
|
+
extension(combined, value);
|
4636
|
+
}
|
4637
|
+
}
|
4638
|
+
}
|
4639
|
+
function extension(combined, extension2) {
|
4640
|
+
let key;
|
4641
|
+
for (key in extension2) {
|
4642
|
+
if (own.call(extension2, key)) {
|
4643
|
+
if (key === "canContainEols") {
|
4644
|
+
const right = extension2[key];
|
4645
|
+
if (right) {
|
4646
|
+
combined[key].push(...right);
|
4647
|
+
}
|
4648
|
+
} else if (key === "transforms") {
|
4649
|
+
const right = extension2[key];
|
4650
|
+
if (right) {
|
4651
|
+
combined[key].push(...right);
|
4652
|
+
}
|
4653
|
+
} else if (key === "enter" || key === "exit") {
|
4654
|
+
const right = extension2[key];
|
4655
|
+
if (right) {
|
4656
|
+
Object.assign(combined[key], right);
|
4657
|
+
}
|
4658
|
+
}
|
4659
|
+
}
|
4660
|
+
}
|
4661
|
+
}
|
4662
|
+
function defaultOnError(left, right) {
|
4663
|
+
if (left) {
|
4664
|
+
throw new Error(
|
4665
|
+
"Cannot close `" + left.type + "` (" + stringifyPosition({
|
4666
|
+
start: left.start,
|
4667
|
+
end: left.end
|
4668
|
+
}) + "): a different token (`" + right.type + "`, " + stringifyPosition({
|
4669
|
+
start: right.start,
|
4670
|
+
end: right.end
|
4671
|
+
}) + ") is open"
|
4672
|
+
);
|
4673
|
+
} else {
|
4674
|
+
throw new Error(
|
4675
|
+
"Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
|
4676
|
+
start: right.start,
|
4677
|
+
end: right.end
|
4678
|
+
}) + ") is still open"
|
4679
|
+
);
|
4680
|
+
}
|
4681
|
+
}
|
4682
|
+
function preprocessMarkdown(markdown) {
|
4683
|
+
const withoutMultipleNewlines = markdown.replace(/\n{2,}/g, "\n");
|
4684
|
+
const withoutExtraSpaces = dedent(withoutMultipleNewlines);
|
4685
|
+
return withoutExtraSpaces;
|
4686
|
+
}
|
4687
|
+
function markdownToLines(markdown) {
|
4688
|
+
const preprocessedMarkdown = preprocessMarkdown(markdown);
|
4689
|
+
const { children } = fromMarkdown(preprocessedMarkdown);
|
4690
|
+
const lines = [[]];
|
4691
|
+
let currentLine = 0;
|
4692
|
+
function processNode(node2, parentType = "normal") {
|
4693
|
+
if (node2.type === "text") {
|
4694
|
+
const textLines = node2.value.split("\n");
|
4695
|
+
textLines.forEach((textLine, index2) => {
|
4696
|
+
if (index2 !== 0) {
|
4697
|
+
currentLine++;
|
4698
|
+
lines.push([]);
|
4699
|
+
}
|
4700
|
+
textLine.split(" ").forEach((word) => {
|
4701
|
+
if (word) {
|
4702
|
+
lines[currentLine].push({ content: word, type: parentType });
|
4703
|
+
}
|
4704
|
+
});
|
4705
|
+
});
|
4706
|
+
} else if (node2.type === "strong" || node2.type === "emphasis") {
|
4707
|
+
node2.children.forEach((contentNode) => {
|
4708
|
+
processNode(contentNode, node2.type);
|
4709
|
+
});
|
4710
|
+
}
|
4711
|
+
}
|
4712
|
+
children.forEach((treeNode) => {
|
4713
|
+
if (treeNode.type === "paragraph") {
|
4714
|
+
treeNode.children.forEach((contentNode) => {
|
4715
|
+
processNode(contentNode);
|
4716
|
+
});
|
4717
|
+
}
|
4718
|
+
});
|
4719
|
+
return lines;
|
4720
|
+
}
|
4721
|
+
function markdownToHTML(markdown) {
|
4722
|
+
const { children } = fromMarkdown(markdown);
|
4723
|
+
function output(node2) {
|
4724
|
+
if (node2.type === "text") {
|
4725
|
+
return node2.value.replace(/\n/g, "<br/>");
|
4726
|
+
} else if (node2.type === "strong") {
|
4727
|
+
return `<strong>${node2.children.map(output).join("")}</strong>`;
|
4728
|
+
} else if (node2.type === "emphasis") {
|
4729
|
+
return `<em>${node2.children.map(output).join("")}</em>`;
|
4730
|
+
} else if (node2.type === "paragraph") {
|
4731
|
+
return `<p>${node2.children.map(output).join("")}</p>`;
|
4732
|
+
}
|
4733
|
+
return `Unsupported markdown: ${node2.type}`;
|
4734
|
+
}
|
4735
|
+
return children.map(output).join("");
|
4736
|
+
}
|
4737
|
+
function splitTextToChars(text2) {
|
4738
|
+
if (Intl.Segmenter) {
|
4739
|
+
return [...new Intl.Segmenter().segment(text2)].map((s) => s.segment);
|
4740
|
+
}
|
4741
|
+
return [...text2];
|
4742
|
+
}
|
4743
|
+
function splitWordToFitWidth(checkFit, word) {
|
4744
|
+
const characters = splitTextToChars(word.content);
|
4745
|
+
return splitWordToFitWidthRecursion(checkFit, [], characters, word.type);
|
4746
|
+
}
|
4747
|
+
function splitWordToFitWidthRecursion(checkFit, usedChars, remainingChars, type) {
|
4748
|
+
if (remainingChars.length === 0) {
|
4749
|
+
return [
|
4750
|
+
{ content: usedChars.join(""), type },
|
4751
|
+
{ content: "", type }
|
4752
|
+
];
|
4753
|
+
}
|
4754
|
+
const [nextChar, ...rest] = remainingChars;
|
4755
|
+
const newWord = [...usedChars, nextChar];
|
4756
|
+
if (checkFit([{ content: newWord.join(""), type }])) {
|
4757
|
+
return splitWordToFitWidthRecursion(checkFit, newWord, rest, type);
|
4758
|
+
}
|
4759
|
+
if (usedChars.length === 0 && nextChar) {
|
4760
|
+
usedChars.push(nextChar);
|
4761
|
+
remainingChars.shift();
|
4762
|
+
}
|
4763
|
+
return [
|
4764
|
+
{ content: usedChars.join(""), type },
|
4765
|
+
{ content: remainingChars.join(""), type }
|
4766
|
+
];
|
4767
|
+
}
|
4768
|
+
function splitLineToFitWidth(line, checkFit) {
|
4769
|
+
if (line.some(({ content: content2 }) => content2.includes("\n"))) {
|
4770
|
+
throw new Error("splitLineToFitWidth does not support newlines in the line");
|
4771
|
+
}
|
4772
|
+
return splitLineToFitWidthRecursion(line, checkFit);
|
4773
|
+
}
|
4774
|
+
function splitLineToFitWidthRecursion(words, checkFit, lines = [], newLine = []) {
|
4775
|
+
if (words.length === 0) {
|
4776
|
+
if (newLine.length > 0) {
|
4777
|
+
lines.push(newLine);
|
4778
|
+
}
|
4779
|
+
return lines.length > 0 ? lines : [];
|
4780
|
+
}
|
4781
|
+
let joiner = "";
|
4782
|
+
if (words[0].content === " ") {
|
4783
|
+
joiner = " ";
|
4784
|
+
words.shift();
|
4785
|
+
}
|
4786
|
+
const nextWord = words.shift() ?? { content: " ", type: "normal" };
|
4787
|
+
const lineWithNextWord = [...newLine];
|
4788
|
+
if (joiner !== "") {
|
4789
|
+
lineWithNextWord.push({ content: joiner, type: "normal" });
|
4790
|
+
}
|
4791
|
+
lineWithNextWord.push(nextWord);
|
4792
|
+
if (checkFit(lineWithNextWord)) {
|
4793
|
+
return splitLineToFitWidthRecursion(words, checkFit, lines, lineWithNextWord);
|
4794
|
+
}
|
4795
|
+
if (newLine.length > 0) {
|
4796
|
+
lines.push(newLine);
|
4797
|
+
words.unshift(nextWord);
|
4798
|
+
} else if (nextWord.content) {
|
4799
|
+
const [line, rest] = splitWordToFitWidth(checkFit, nextWord);
|
4800
|
+
lines.push([line]);
|
4801
|
+
if (rest.content) {
|
4802
|
+
words.unshift(rest);
|
4803
|
+
}
|
4804
|
+
}
|
4805
|
+
return splitLineToFitWidthRecursion(words, checkFit, lines);
|
4806
|
+
}
|
4807
|
+
function applyStyle(dom, styleFn) {
|
4808
|
+
if (styleFn) {
|
4809
|
+
dom.attr("style", styleFn);
|
4810
|
+
}
|
4811
|
+
}
|
4812
|
+
function addHtmlSpan(element2, node2, width, classes, addBackground = false) {
|
4813
|
+
const fo = element2.append("foreignObject");
|
4814
|
+
const div = fo.append("xhtml:div");
|
4815
|
+
const label = node2.label;
|
4816
|
+
const labelClass = node2.isNode ? "nodeLabel" : "edgeLabel";
|
4817
|
+
div.html(
|
4818
|
+
`
|
4819
|
+
<span class="${labelClass} ${classes}" ` + (node2.labelStyle ? 'style="' + node2.labelStyle + '"' : "") + ">" + label + "</span>"
|
4820
|
+
);
|
4821
|
+
applyStyle(div, node2.labelStyle);
|
4822
|
+
div.style("display", "table-cell");
|
4823
|
+
div.style("white-space", "nowrap");
|
4824
|
+
div.style("max-width", width + "px");
|
4825
|
+
div.attr("xmlns", "http://www.w3.org/1999/xhtml");
|
4826
|
+
if (addBackground) {
|
4827
|
+
div.attr("class", "labelBkg");
|
4828
|
+
}
|
4829
|
+
let bbox = div.node().getBoundingClientRect();
|
4830
|
+
if (bbox.width === width) {
|
4831
|
+
div.style("display", "table");
|
4832
|
+
div.style("white-space", "break-spaces");
|
4833
|
+
div.style("width", width + "px");
|
4834
|
+
bbox = div.node().getBoundingClientRect();
|
4835
|
+
}
|
4836
|
+
fo.style("width", bbox.width);
|
4837
|
+
fo.style("height", bbox.height);
|
4838
|
+
return fo.node();
|
4839
|
+
}
|
4840
|
+
function createTspan(textElement, lineIndex, lineHeight) {
|
4841
|
+
return textElement.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", lineIndex * lineHeight - 0.1 + "em").attr("dy", lineHeight + "em");
|
4842
|
+
}
|
4843
|
+
function computeWidthOfText(parentNode, lineHeight, line) {
|
4844
|
+
const testElement = parentNode.append("text");
|
4845
|
+
const testSpan = createTspan(testElement, 1, lineHeight);
|
4846
|
+
updateTextContentAndStyles(testSpan, line);
|
4847
|
+
const textLength = testSpan.node().getComputedTextLength();
|
4848
|
+
testElement.remove();
|
4849
|
+
return textLength;
|
4850
|
+
}
|
4851
|
+
function computeDimensionOfText(parentNode, lineHeight, text2) {
|
4852
|
+
var _a;
|
4853
|
+
const testElement = parentNode.append("text");
|
4854
|
+
const testSpan = createTspan(testElement, 1, lineHeight);
|
4855
|
+
updateTextContentAndStyles(testSpan, [{ content: text2, type: "normal" }]);
|
4856
|
+
const textDimension = (_a = testSpan.node()) == null ? void 0 : _a.getBoundingClientRect();
|
4857
|
+
if (textDimension) {
|
4858
|
+
testElement.remove();
|
4859
|
+
}
|
4860
|
+
return textDimension;
|
4861
|
+
}
|
4862
|
+
function createFormattedText(width, g, structuredText, addBackground = false) {
|
4863
|
+
const lineHeight = 1.1;
|
4864
|
+
const labelGroup = g.append("g");
|
4865
|
+
const bkg = labelGroup.insert("rect").attr("class", "background");
|
4866
|
+
const textElement = labelGroup.append("text").attr("y", "-10.1");
|
4867
|
+
let lineIndex = 0;
|
4868
|
+
for (const line of structuredText) {
|
4869
|
+
const checkWidth = (line2) => computeWidthOfText(labelGroup, lineHeight, line2) <= width;
|
4870
|
+
const linesUnderWidth = checkWidth(line) ? [line] : splitLineToFitWidth(line, checkWidth);
|
4871
|
+
for (const preparedLine of linesUnderWidth) {
|
4872
|
+
const tspan = createTspan(textElement, lineIndex, lineHeight);
|
4873
|
+
updateTextContentAndStyles(tspan, preparedLine);
|
4874
|
+
lineIndex++;
|
4875
|
+
}
|
4876
|
+
}
|
4877
|
+
if (addBackground) {
|
4878
|
+
const bbox = textElement.node().getBBox();
|
4879
|
+
const padding = 2;
|
4880
|
+
bkg.attr("x", -padding).attr("y", -padding).attr("width", bbox.width + 2 * padding).attr("height", bbox.height + 2 * padding);
|
4881
|
+
return labelGroup.node();
|
4882
|
+
} else {
|
4883
|
+
return textElement.node();
|
4884
|
+
}
|
4885
|
+
}
|
4886
|
+
function updateTextContentAndStyles(tspan, wrappedLine) {
|
4887
|
+
tspan.text("");
|
4888
|
+
wrappedLine.forEach((word, index2) => {
|
4889
|
+
const innerTspan = tspan.append("tspan").attr("font-style", word.type === "emphasis" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", word.type === "strong" ? "bold" : "normal");
|
4890
|
+
if (index2 === 0) {
|
4891
|
+
innerTspan.text(word.content);
|
4892
|
+
} else {
|
4893
|
+
innerTspan.text(" " + word.content);
|
4894
|
+
}
|
4895
|
+
});
|
4896
|
+
}
|
4897
|
+
const createText = (el, text2 = "", {
|
4898
|
+
style = "",
|
4899
|
+
isTitle = false,
|
4900
|
+
classes = "",
|
4901
|
+
useHtmlLabels = true,
|
4902
|
+
isNode = true,
|
4903
|
+
width = 200,
|
4904
|
+
addSvgBackground = false
|
4905
|
+
} = {}) => {
|
4906
|
+
log.info("createText", text2, style, isTitle, classes, useHtmlLabels, isNode, addSvgBackground);
|
4907
|
+
if (useHtmlLabels) {
|
4908
|
+
const htmlText2 = markdownToHTML(text2);
|
4909
|
+
const node2 = {
|
4910
|
+
isNode,
|
4911
|
+
label: decodeEntities(htmlText2).replace(
|
4912
|
+
/fa[blrs]?:fa-[\w-]+/g,
|
4913
|
+
// cspell: disable-line
|
4914
|
+
(s) => `<i class='${s.replace(":", " ")}'></i>`
|
4915
|
+
),
|
4916
|
+
labelStyle: style.replace("fill:", "color:")
|
4917
|
+
};
|
4918
|
+
const vertexNode = addHtmlSpan(el, node2, width, classes, addSvgBackground);
|
4919
|
+
return vertexNode;
|
4920
|
+
} else {
|
4921
|
+
const structuredText = markdownToLines(text2);
|
4922
|
+
const svgLabel = createFormattedText(width, el, structuredText, addSvgBackground);
|
4923
|
+
return svgLabel;
|
4924
|
+
}
|
4925
|
+
};
|
4926
|
+
export {
|
4927
|
+
createText as a,
|
4928
|
+
computeDimensionOfText as c
|
4929
|
+
};
|