Skip to content

Build your personal knowledge base with Trilium Notes

feat(codemirror): colour Mermaid mind map nodes by level

Elian Doran00aa1aa8aeea
diff --git a/.claude/skills/developing-mermaid-highlighting/SKILL.md b/.claude/skills/developing-mermaid-highlighting/SKILL.md
index 6a955ff654..60351a641a 100644
--- a/.claude/skills/developing-mermaid-highlighting/SKILL.md
+++ b/.claude/skills/developing-mermaid-highlighting/SKILL.md
@@ -105,9 +105,12 @@ extension (Mermaid-Chart/vscode-mermaid-chart, `syntaxes/`) only lists keywords.
indentation-based ones (mindmap, kanban) need a context tracker.
2. **`highlight.ts`** maps node names to tags with `styleTags`, using `@external propSource … from
"./highlight.js"` in the grammar. **`tokens.ts`** only if the grammar needs external tokenizers.
+ A literal (`"(("`) is a node, and so can be styled, only when the grammar's `@tokens` block
+ declares it; otherwise it stays anonymous and unstyled.
3. **Tags** go in `tags/index.ts`. Give each one a standard parent
- (`Tag.define(t.keyword)`): themes style standard tags only, so a parentless tag renders unstyled
- (mindmap's `lineText1..5` are, deliberately or not).
+ (`Tag.define(t.keyword)`): themes style standard tags only, so a parentless tag renders unstyled.
+ Mindmap's five `lineText` tags, one per tree level, were parentless until they took `keyword`,
+ `typeName`, `string`, `number` and `propertyName`.
4. **Teach the dispatcher.** In `parsers/mermaid/mermaid.grammar`, add the node to both the `@top`
alternatives and the `@external tokens diagramText` list; in `parsers/mermaid/tokens.ts` add each
keyword the diagram starts with to `diagramMap` (`radar-beta`, …). `diagramMap` matches with
diff --git a/packages/codemirror/src/languages/mermaid/mermaid.spec.ts b/packages/codemirror/src/languages/mermaid/mermaid.spec.ts
index ea76b82274..d698069680 100644
--- a/packages/codemirror/src/languages/mermaid/mermaid.spec.ts
+++ b/packages/codemirror/src/languages/mermaid/mermaid.spec.ts
@@ -177,14 +177,27 @@ describe("shape metadata", () => {
expect(styles("kanban\n todo\n A[Task]@{ priority: high")).toContain(`priority ${key}`);
expect(styles("kanban\n todo\n A[Task]@{").at(-1)).toBe("@{ tok-meta");
});
+});
- function styles(doc: string) {
- const result: string[] = [];
- highlightTree(mermaidLanguage.parser.parse(doc), classHighlighter, (from, to, style) => {
- result.push(`${doc.slice(from, to)} ${style}`);
- });
- return result;
- }
+describe("mindmap highlighting", () => {
+ it("colours each node by its level, and ids, shapes, icons and classes apart", () => {
+ const doc = [
+ "mindmap", " root((mindmap))", " Origins", " Long history",
+ " ::icon(fa fa-book)", " :::urgent", " Buzan", " Research",
+ " Automatic creation", " Uses", " Argument mapping",
+ " Pen and paper", " id[Tools]"
+ ].join("\n");
+ expect(styles(doc)).toEqual([
+ "mindmap tok-typeName", "root tok-variableName", "(( tok-punctuation",
+ "mindmap tok-keyword", ")) tok-punctuation", "Origins tok-typeName",
+ "Long history tok-string", ":: tok-punctuation", "icon tok-keyword",
+ "( tok-punctuation", "fa fa-book tok-atom", ") tok-punctuation",
+ "::: tok-punctuation", "urgent tok-className", "Buzan tok-number",
+ "Research tok-typeName", "Automatic creation tok-string", "Uses tok-number",
+ "Argument mapping tok-propertyName", "Pen and paper tok-keyword",
+ "id tok-variableName", "[ tok-punctuation", "Tools tok-typeName", "] tok-punctuation"
+ ]);
+ });
});
describe("kanban grammar", () => {
@@ -252,3 +265,12 @@ describe("foldByIndent", () => {
expect(foldAt("a", 1)).toBeNull();
});
});
+
+/** Each highlighted range of `doc` as its text and classes, in document order. */
+function styles(doc: string) {
+ const result: string[] = [];
+ highlightTree(mermaidLanguage.parser.parse(doc), classHighlighter, (from, to, style) => {
+ result.push(`${doc.slice(from, to)} ${style}`);
+ });
+ return result;
+}
diff --git a/packages/codemirror/src/languages/mermaid/parsers/mindmap/highlight.ts b/packages/codemirror/src/languages/mermaid/parsers/mindmap/highlight.ts
index 0afb21e0b3..3801a0cc74 100644
--- a/packages/codemirror/src/languages/mermaid/parsers/mindmap/highlight.ts
+++ b/packages/codemirror/src/languages/mermaid/parsers/mindmap/highlight.ts
@@ -1,13 +1,25 @@
-import { styleTags } from "@lezer/highlight";
+import { styleTags, tags as t } from "@lezer/highlight";
import { mindmapTags } from "../../tags/index.js";
export const mindmapHighlighting = styleTags({
- DiagramName: mindmapTags.diagramName,
- Directive: mindmapTags.directive,
- LineComment: mindmapTags.lineComment,
- LineText1: mindmapTags.lineText1,
- LineText2: mindmapTags.lineText2,
- LineText3: mindmapTags.lineText3,
- LineText4: mindmapTags.lineText4,
- LineText5: mindmapTags.lineText5
+ "( ) (( )) {{ }}": t.paren,
+ "[ ]": t.squareBracket,
+ ":: :::": t.punctuation,
+ "DiagramName": mindmapTags.diagramName,
+ "Directive": mindmapTags.directive,
+ "Icon": mindmapTags.keyword,
+ "LineComment": mindmapTags.lineComment,
+ "LineText1": mindmapTags.lineText1,
+ "LineText2": mindmapTags.lineText2,
+ "LineText3": mindmapTags.lineText3,
+ "LineText4": mindmapTags.lineText4,
+ "LineText5": mindmapTags.lineText5,
+ [lineTextsIn("NodeId")]: mindmapTags.nodeId,
+ [lineTextsIn("IconLine")]: mindmapTags.icon,
+ [lineTextsIn("ClassLine")]: mindmapTags.className
});
+
+/** A selector for the text of a line, whatever its level, as a child of `parent`. */
+function lineTextsIn(parent: string) {
+ return [ 1, 2, 3, 4, 5 ].map((level) => `${parent}/LineText${level}`).join(" ");
+}
diff --git a/packages/codemirror/src/languages/mermaid/parsers/mindmap/mindmap.grammar b/packages/codemirror/src/languages/mermaid/parsers/mindmap/mindmap.grammar
index 6f4c40cd19..b3e1885ca4 100644
--- a/packages/codemirror/src/languages/mermaid/parsers/mindmap/mindmap.grammar
+++ b/packages/codemirror/src/languages/mermaid/parsers/mindmap/mindmap.grammar
@@ -61,10 +61,12 @@ Line {
IconLine |
ClassLine |
ShapedText |
- lineText ShapedText
+ NodeId ShapedText
)
}
+NodeId { lineText }
+
DiagramName { kw<"mindmap"> }
Icon { kw<"icon"> }
@@ -86,6 +88,7 @@ kw<term> { @specialize<word, term> }
@tokens {
spaces { ($[ \t\f] | "\\" $[\n\r])+ }
word { @asciiLetter+ }
+ "(" ")" "((" "))" "[" "]" "{{" "}}" "::" ":::"
}
@external tokens newlines from "./tokens.js" { newline, newlineEmpty }
diff --git a/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.terms.ts b/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.terms.ts
index ef25829404..ffe8bd2bce 100644
--- a/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.terms.ts
+++ b/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.terms.ts
@@ -1,7 +1,7 @@
// AUTO-GENERATED by scripts/build_mermaid_grammars.mts from the grammar in this directory.
// This file was generated by lezer-generator. You probably shouldn't edit it.
export const
- indent = 18,
+ indent = 29,
LineComment = 1,
Directive = 2,
LineText1 = 3,
@@ -9,12 +9,13 @@ export const
LineText3 = 5,
LineText4 = 6,
LineText5 = 7,
- newline = 19,
- newlineEmpty = 20,
+ newline = 30,
+ newlineEmpty = 31,
MindmapDiagram = 8,
DiagramName = 9,
Line = 10,
IconLine = 11,
- Icon = 12,
- ClassLine = 13,
- ShapedText = 14
+ Icon = 13,
+ ClassLine = 16,
+ ShapedText = 18,
+ NodeId = 25
diff --git a/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.ts b/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.ts
index 207d141165..bc6f1f97ba 100644
--- a/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.ts
+++ b/packages/codemirror/src/languages/mermaid/parsers/mindmap/parser.ts
@@ -3,21 +3,21 @@
import {LRParser} from "@lezer/lr"
import {indentation, comments, lineTextType, newlines, trackIndent} from "./tokens.js"
import {mindmapHighlighting} from "./highlight.js"
-const spec_word = {__proto__:null,mindmap:48, icon:54}
+const spec_word = {__proto__:null,mindmap:70, icon:74}
export const parser = LRParser.deserialize({
version: 14,
- states: "&fO`QjOOOOQb'#Ck'#CkQhQjOOQmQjOOOOQb'#Ce'#CeOOQb-E6i-E6iOrQkO'#CfOOQb'#Cl'#ClQmQjOOO!cQnO,59QOOQb-E6j-E6jOOQb'#Cu'#CuO!|QjO'#CgO#RQnO'#CiO#RQnO'#C{O#RQnO'#DOO#RQnO'#DPO#RQnO'#DSO#RQnO'#DTO#RQnO'#DUOOQb'#Cj'#CjO#dQjO1G.lOOQb1G.l1G.lO#nQjO,59ROOQb'#Ch'#ChOOQb,59T,59TO#sQjO,59gO#xQjO,59jO#}QjO,59kO$SQjO,59nO$XQjO,59oO$^QjO,59pOOQb7+$W7+$WO#RQnO1G.mOOQb1G/R1G/ROOQb1G/U1G/UOOQb1G/V1G/VOOQb1G/Y1G/YOOQb1G/Z1G/ZOOQb1G/[1G/[O$cQjO7+$XOOQb<<Gs<<Gs",
- stateData: "$h~OfOSdOSPOSQOS~OcPOhSO~OcPO~OcUO~ObXOaYXcYX~Ol_OmbOp^Ot`OuaOycO~ORZOSZOTZOUZOVZOj[On]O~P}OkhO~ORZOSZOTZOUZOVZO~OaYicYi~P}OlqO~OqrO~OmsO~OutO~OtuO~OlvO~OzwO~OmyO~O",
- goto: "#[yPPPPPPPPPz}!R!U!R!X!_!ePPPPPPPP!kPPPPP#WPP#W#WPP#W#W#WRROTVRWRfXRg[QfXRpeQQORTQQWRRYWQeXQi]Qj^Qk_Ql`QmaQnbQocRxqTdXe",
- nodeNames: "⚠ LineComment Directive LineText1 LineText2 LineText3 LineText4 LineText5 MindmapDiagram DiagramName Line IconLine Icon ClassLine ShapedText",
- maxTerm: 42,
+ states: "&lO`QjOOOOQb'#Cv'#CvQhQjOOQmQjOOOOQb'#Ce'#CeOOQb-E6t-E6tOrQkO'#CfOOQb'#Cw'#CwQmQjOOO!cQnO,59QOOQb-E6u-E6uOOQb'#DQ'#DQO!|QjO'#CgO#RQnO'#ClO#RQnO'#DSO#RQnO'#DTO#RQnO'#DUO#RQnO'#DVO#RQnO'#DWO#RQnO'#DXOOQb'#Cn'#CnO#dQjO1G.lOOQb1G.l1G.lO}QjO1G.lO$OQjO,59ROOQb'#Ci'#CiOOQb,59W,59WO$TQjO,59nO$YQjO,59oO$_QjO,59pO$dQjO,59qO$iQjO,59rO$nQjO,59sOOQb7+$W7+$WO#RQnO1G.mOOQb1G/Y1G/YOOQb1G/Z1G/ZOOQb1G/[1G/[OOQb1G/]1G/]OOQb1G/^1G/^OOQb1G/_1G/_O$sQjO7+$XOOQb<<Gs<<Gs",
+ stateData: "$x~OqOSoOSPOSQOS~OnPOsSO~OnPO~OnUO~OmXOlYXnYX~O^_O_bOc^Oe`OfaOgcO~ORZOSZOTZOUZOVZO[[Oa]O~P}OuiO~ORZOSZOTZOUZOVZO~O^iX_iXciXeiXfiXgiXlYinYi~O^rO~OdsO~O_tO~OfuO~OevO~O^wO~OhxO~O_zO~O",
+ goto: "#b|PPPPPPPPP}!Q!UP!XPP!UP![PPPPPP!b!e!kPPPPPPPP!qP#^#^#^#^#^#^RROTVRWRfXRh[QfXRqgRgXQQORTQQWRRYWQeXQj]Qk^Ql_Qm`QnaQobQpcRyrTdXg",
+ nodeNames: "⚠ LineComment Directive LineText1 LineText2 LineText3 LineText4 LineText5 MindmapDiagram DiagramName Line IconLine :: Icon ( ) ClassLine ::: ShapedText [ ] (( )) {{ }} NodeId",
+ maxTerm: 43,
context: trackIndent,
propSources: [mindmapHighlighting],
skippedNodes: [0,1,2],
repeatNodeCount: 2,
- tokenData: "$b~R]XYz[]zpqzxy!fyz!s![!]#Q!c!}#e!}#O#p#O#P!]#P#Q#u#T#o#e#o#p#z#q#r$V~!PSf~XYz[]zpqz#O#P!]~!`QYZz]^z~!kPl~xy!n~!sOt~~!xPm~yz!{~#QOu~~#TP![!]#W~#]Pj~![!]#`~#eOn~~#jQg~!c!}#e#T#o#e~#uOp~~#zOq~~#}P#o#p$Q~$VOy~~$YP#q#r$]~$bOz~",
+ tokenData: "$b~R]XYz[]zpqzxy!fyz!s![!]#Q!c!}#e!}#O#p#O#P!]#P#Q#u#T#o#e#o#p#z#q#r$V~!PSq~XYz[]zpqz#O#P!]~!`QYZz]^z~!kP^~xy!n~!sOe~~!xP_~yz!{~#QOf~~#TP![!]#W~#]P[~![!]#`~#eOa~~#jQr~!c!}#e#T#o#e~#uOc~~#zOd~~#}P#o#p$Q~$VOg~~$YP#q#r$]~$bOh~",
tokenizers: [indentation, comments, lineTextType, 0, newlines],
topRules: {"MindmapDiagram":[0,8]},
- specialized: [{term: 23, get: (value: keyof typeof spec_word) => spec_word[value] || -1}],
+ specialized: [{term: 34, get: (value: keyof typeof spec_word) => spec_word[value] || -1}],
tokenPrec: 0
})
diff --git a/packages/codemirror/src/languages/mermaid/parsers/mindmap/tokens.ts b/packages/codemirror/src/languages/mermaid/parsers/mindmap/tokens.ts
index b0ef34d29d..311d18634f 100644
--- a/packages/codemirror/src/languages/mermaid/parsers/mindmap/tokens.ts
+++ b/packages/codemirror/src/languages/mermaid/parsers/mindmap/tokens.ts
@@ -2,7 +2,9 @@ import { ExternalTokenizer, ContextTracker } from "@lezer/lr";
import { findDirectiveLength, lineLength } from "../mermaid/tokens.js";
import {
+ ClassLine,
Directive,
+ IconLine,
LineComment,
newline as newlineToken,
newlineEmpty,
@@ -69,7 +71,7 @@ export const lineTextType = new ExternalTokenizer((input, stack) => {
input.next === braceL
) {
if (chars > 0) {
- input.acceptToken(stack.context.lineType);
+ input.acceptToken(lineType(stack.context));
return;
} else return;
}
@@ -80,7 +82,7 @@ export const lineTextType = new ExternalTokenizer((input, stack) => {
input.next === braceR) &&
chars > 0
) {
- input.acceptToken(stack.context.lineType);
+ input.acceptToken(lineType(stack.context));
return;
}
@@ -88,7 +90,7 @@ export const lineTextType = new ExternalTokenizer((input, stack) => {
chars++;
}
- input.acceptToken(stack.context.lineType);
+ input.acceptToken(lineType(stack.context));
});
const tabDepth = (depth: number) => {
@@ -137,9 +139,23 @@ function startsLine(input: InputStream) {
}
}
-const indentTracker = {
- lineType: LineText1
-};
+/** A node line: its indentation and its depth in the tree, the root being 0. */
+interface Node {
+ indent: number;
+ level: number;
+ parent: Node | null;
+ hash: number;
+}
+
+/**
+ * The nodes a new line can nest under, each indented deeper than the one before, and the current
+ * line, which joins them at the next line unless it is a decoration: an icon or class line.
+ */
+interface Context {
+ nodes: Node | null;
+ line: Node;
+ decoration: boolean;
+}
const countIndent = (space: string) => {
let depth = 0;
@@ -148,17 +164,31 @@ const countIndent = (space: string) => {
return depth;
};
-const getLineType = (depth: number) => {
- return LineTextTokens[depth % 5];
-};
+/** The token of the text on a line, one of five that cycle with the line's level. */
+function lineType(context: Context) {
+ return LineTextTokens[context.line.level % LineTextTokens.length];
+}
-export const trackIndent = new ContextTracker({
- start: indentTracker,
+/**
+ * Tracks the level of each line as Mermaid nests nodes: under the last node indented less deeply.
+ * `::icon()` and `:::class` lines decorate the node before them, so nothing nests under them.
+ */
+export const trackIndent = new ContextTracker<Context>({
+ // No line has started yet; as a decoration, the placeholder never joins `nodes`.
+ start: { nodes: null, line: { indent: -1, level: 0, parent: null, hash: 0 }, decoration: true },
shift(context, term, stack, input: InputStreamWithRead) {
- if (term === indent) {
- const depth = countIndent(input.read(input.pos, stack.pos));
- context.lineType = getLineType(depth);
- }
- return context;
- }
+ if (term !== indent) return context;
+ const nodes = context.decoration ? context.nodes : context.line;
+ const width = countIndent(input.read(input.pos, stack.pos));
+ let parent = nodes;
+ while (parent && parent.indent >= width) parent = parent.parent;
+ const level = parent ? parent.level + 1 : 0;
+ const hash = ((parent?.hash ?? 0) * 31 + width + 1) | 0;
+ return { nodes, line: { indent: width, level, parent, hash }, decoration: false };
+ },
+ reduce(context, term) {
+ return term === IconLine || term === ClassLine ? { ...context, decoration: true } : context;
+ },
+ hash: (context) => (((context.nodes?.hash ?? 0) * 31 + context.line.hash) * 2
+ + (context.decoration ? 1 : 0)) | 0
});
diff --git a/packages/codemirror/src/languages/mermaid/tags/index.ts b/packages/codemirror/src/languages/mermaid/tags/index.ts
index 35fdb87fce..323e595e87 100644
--- a/packages/codemirror/src/languages/mermaid/tags/index.ts
+++ b/packages/codemirror/src/languages/mermaid/tags/index.ts
@@ -10,14 +10,20 @@ export const mermaidTags = {
};
export const mindmapTags = {
+ className: Tag.define(t.className),
diagramName: Tag.define(mermaidTags.diagramName),
directive: Tag.define(mermaidTags.directive),
+ icon: Tag.define(t.atom),
+ keyword: Tag.define(t.keyword),
lineComment: Tag.define(t.lineComment),
- lineText1: Tag.define(),
- lineText2: Tag.define(),
- lineText3: Tag.define(),
- lineText4: Tag.define(),
- lineText5: Tag.define()
+ // The text of a node, by its level in the tree: the root, its children, and so on, then over
+ // again from the sixth level.
+ lineText1: Tag.define(t.keyword),
+ lineText2: Tag.define(t.typeName),
+ lineText3: Tag.define(t.string),
+ lineText4: Tag.define(t.number),
+ lineText5: Tag.define(t.propertyName),
+ nodeId: Tag.define(t.variableName)
};
export const pieTags = {
diff --git a/packages/codemirror/src/languages/mermaid/test/mindmap.txt b/packages/codemirror/src/languages/mermaid/test/mindmap.txt
index f10d9c77b5..83d52bc8f9 100644
--- a/packages/codemirror/src/languages/mermaid/test/mindmap.txt
+++ b/packages/codemirror/src/languages/mermaid/test/mindmap.txt
@@ -68,7 +68,7 @@ id[I am a square]
==>
-MindmapDiagram(DiagramName,Line(LineText1,ShapedText(LineText1)))
+MindmapDiagram(DiagramName,Line(NodeId(LineText1),ShapedText(LineText1)))
# RoundedSquare
@@ -77,7 +77,7 @@ id(I am a rounded square)
==>
-MindmapDiagram(DiagramName,Line(LineText1,ShapedText(LineText1)))
+MindmapDiagram(DiagramName,Line(NodeId(LineText1),ShapedText(LineText1)))
# Circle
@@ -86,7 +86,7 @@ id((I am a circle))
==>
-MindmapDiagram(DiagramName,Line(LineText1,ShapedText(LineText1)))
+MindmapDiagram(DiagramName,Line(NodeId(LineText1),ShapedText(LineText1)))
# Bang
@@ -95,7 +95,7 @@ id))I am a bang((
==>
-MindmapDiagram(DiagramName,Line(LineText1,ShapedText(LineText1)))
+MindmapDiagram(DiagramName,Line(NodeId(LineText1),ShapedText(LineText1)))
# Cloud
@@ -104,7 +104,7 @@ id)I am a cloud(
==>
-MindmapDiagram(DiagramName,Line(LineText1,ShapedText(LineText1)))
+MindmapDiagram(DiagramName,Line(NodeId(LineText1),ShapedText(LineText1)))
# Hexagon
@@ -113,7 +113,7 @@ id{{I am a hexagon}}
==>
-MindmapDiagram(DiagramName,Line(LineText1,ShapedText(LineText1)))
+MindmapDiagram(DiagramName,Line(NodeId(LineText1),ShapedText(LineText1)))
# IconLine
@@ -126,7 +126,7 @@ Root
==>
-MindmapDiagram(DiagramName,Line(LineText1),Line(LineText2),Line(IconLine(Icon,LineText2)),Line(LineText2,ShapedText(LineText2)),Line(IconLine(Icon,LineText2)))
+MindmapDiagram(DiagramName,Line(LineText1),Line(LineText2),Line(IconLine(Icon,LineText2)),Line(NodeId(LineText2),ShapedText(LineText2)),Line(IconLine(Icon,LineText2)))
# ClassLine
@@ -139,7 +139,7 @@ Root
==>
-MindmapDiagram(DiagramName,Line(LineText1),Line(LineText2,ShapedText(LineText2)),Line(ClassLine(LineText2)),Line(LineText2,ShapedText(LineText2)),Line(LineText2))
+MindmapDiagram(DiagramName,Line(LineText1),Line(NodeId(LineText2),ShapedText(LineText2)),Line(ClassLine(LineText2)),Line(NodeId(LineText2),ShapedText(LineText2)),Line(LineText2))
# Shape at the start of a line
@@ -148,7 +148,7 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(ShapedText(LineText3)))
+MindmapDiagram(DiagramName,Line(ShapedText(LineText1)))
# Tab indentation
@@ -159,7 +159,7 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(LineText5),Line(LineText4),Line(LineText4))
+MindmapDiagram(DiagramName,Line(LineText1),Line(LineText2),Line(LineText2))
# Root on the diagram line (unsupported, parses as empty lines)
@@ -190,7 +190,7 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(LineText3),LineComment,Line(LineText5),LineComment,Line(LineText5))
+MindmapDiagram(DiagramName,Line(LineText1),LineComment,Line(LineText2),LineComment,Line(LineText2))
# Directive below the root
@@ -201,7 +201,7 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(LineText3),Directive,Line(LineText5))
+MindmapDiagram(DiagramName,Line(LineText1),Directive,Line(LineText2))
# Multi-line directive
@@ -214,7 +214,7 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(LineText3),Directive,Line(LineText5))
+MindmapDiagram(DiagramName,Line(LineText1),Directive,Line(LineText2))
# Percent signs inside a node's text
@@ -224,7 +224,7 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(LineText3),Line(LineText5,ShapedText(LineText5)))
+MindmapDiagram(DiagramName,Line(LineText1),Line(NodeId(LineText2),ShapedText(LineText2)))
# Comment after a shape
@@ -235,7 +235,7 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(LineText3),Line(LineText5,ShapedText(LineText5)),LineComment,Line(LineText5,ShapedText(LineText5)),LineComment)
+MindmapDiagram(DiagramName,Line(LineText1),Line(NodeId(LineText2),ShapedText(LineText2)),LineComment,Line(NodeId(LineText2),ShapedText(LineText2)),LineComment)
# Comment after a line starting with a hash
@@ -247,4 +247,44 @@ mindmap
==>
-MindmapDiagram(DiagramName,Line(LineText3),Line,LineComment,Line(LineText5))
+MindmapDiagram(DiagramName,Line(LineText1),Line,LineComment,Line(LineText2))
+
+# Levels follow the nesting, not the indentation width
+
+mindmap
+ root
+ a
+ b
+ c
+ d
+
+==>
+
+MindmapDiagram(DiagramName,Line(LineText1),Line(LineText2),Line(LineText3),Line(LineText2),Line(LineText3))
+
+# Levels past the fifth start over
+
+mindmap
+root
+ A
+ B
+ C
+ D
+ E
+
+==>
+
+MindmapDiagram(DiagramName,Line(LineText1),Line(LineText2),Line(LineText3),Line(LineText4),Line(LineText5),Line(LineText1))
+
+# Icon and class lines are not nodes
+
+mindmap
+root
+ a
+ ::icon(x)
+ :::big
+ b
+
+==>
+
+MindmapDiagram(DiagramName,Line(LineText1),Line(LineText2),Line(IconLine(Icon,LineText3)),Line(ClassLine(LineText3)),Line(LineText3))