From 1744c8279561e23a8bb8ad25dae2f9bfbdec2933 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Sat, 9 Aug 2025 19:07:44 +0200 Subject: [PATCH] WIP 6 --- .../diagrams/flowchart/parser/flowParser.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flowParser.ts b/packages/mermaid/src/diagrams/flowchart/parser/flowParser.ts index 4b15f76fe..00aba8c11 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flowParser.ts +++ b/packages/mermaid/src/diagrams/flowchart/parser/flowParser.ts @@ -766,6 +766,7 @@ class LezerFlowParser { tokenType === 'END' || tokenType === 'STYLE' || tokenType === 'CLASS' || + tokenType === 'LINK_TARGET' || tokenType === 'CLASSDEF' || tokenType === 'CLICK' || tokenType === 'HREF' || @@ -3793,6 +3794,38 @@ class LezerFlowParser { return this.parsePipeDelimitedText(tokens, startIndex, firstArrow); } + // Special-case: dotted labelled simple edge like: A -. Label .- B (length 1..) + // After firstArrow ('-.'), expect: LABEL (NODE_STRING), CLOSING LINK ('.-','..-','...-'), TARGET (Identifier/NODE_STRING/DIR) + if ( + firstArrow === '-.' && + i + 2 < tokens.length && + tokens[i].type === 'NODE_STRING' && + tokens[i + 1].type === 'LINK' && + /^(\.+)-$/.test(tokens[i + 1].value) && + (tokens[i + 2].type === 'Identifier' || + tokens[i + 2].type === 'NODE_STRING' || + tokens[i + 2].type === 'DIR') + ) { + const labelToken = tokens[i]; + const closingLink = tokens[i + 1].value; // e.g., '.-', '..-', '...-' + const targetToken = tokens[i + 2]; + + const dotCount = (closingLink.match(/\./g) || []).length; // 1..N + const targetId = targetToken.value; + i = i + 3; // consume label, closing link, and target + + const arrowCanonical = `-${'.'.repeat(dotCount)}-`; + return { + arrow: arrowCanonical, + targetId, + text: labelToken.value, + type: 'arrow_open', + stroke: 'dotted', + length: dotCount, + nextIndex: i, + }; + } + // Simple arrow pattern: A --> B (but B might be a shaped vertex like B(text)) if ( i >= tokens.length ||