{"record":{"id":"6fff18cbe7410250","repo":"mermaid-js/mermaid","slug":"line-origlineno-unexpected-indentation-without","errorCode":null,"errorMessage":"Line ${origLineNo}: Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes.","messagePattern":"Line (.+?): Unexpected indentation without box-drawing characters\\. In box-drawing format, use ├── or └── prefixes for indented nodes\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/treeView/boxDrawingPreprocessor.ts","lineNumber":196,"sourceCode":"        );\n      }\n\n      const indent = INDENT_UNIT.repeat(depth);\n      outputLines.push(indent + content);\n      outLineNo++;\n      lineMap.set(outLineNo, origLineNo);\n    } else if (/^[\\s─━│┃└┗├┣]+$/.test(normalized)) {\n      // Entire line is box-drawing decoration and whitespace — skip\n      continue;\n    } else if (ALL_BOX_CHARS.test(normalized)) {\n      // Has box chars but no branch char — likely content containing a box char (e.g. \"Section ─ A.txt\")\n      // Treat as root-level item\n      outputLines.push(line);\n      outLineNo++;\n      lineMap.set(outLineNo, origLineNo);\n    } else if (/^\\s+/.test(normalized)) {\n      // Leading whitespace without box chars in box mode → likely mixed format\n      throw new Error(\n        `Line ${origLineNo}: Unexpected indentation without box-drawing characters. ` +\n          `In box-drawing format, use ├── or └── prefixes for indented nodes.`\n      );\n    } else {\n      // No box chars, no leading whitespace → root-level item (depth 0)\n      outputLines.push(line);\n      outLineNo++;\n      lineMap.set(outLineNo, origLineNo);\n    }\n  }\n\n  return { text: outputLines.join('\\n'), lineMap };\n}\n","sourceCodeStart":178,"sourceCodeEnd":210,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/treeView/boxDrawingPreprocessor.ts#L178-L210","documentation":"In box-drawing mode, indentation is conveyed by branch connectors (├──/└──), not by leading whitespace. If a line has leading whitespace but contains no box-drawing characters at all, the preprocessor treats it as a mixed-format input and throws, reporting the original line number, because the intended nesting cannot be determined.","triggerScenarios":"A treeView diagram auto-detected as (or set to) box-drawing mode that contains lines indented with plain spaces/tabs and no ├/└/─/│ glyphs.","commonSituations":"Mixing an indentation-based tree with a box-drawing tree in one diagram; pasting source code snippets with leading spaces inside a box-drawing tree; editors that convert tabs to spaces breaking connectors; partial format migration.","solutions":["Make every indented line use ├── or └── connectors so it is unambiguously box-drawing.","Switch the whole diagram to indentation format so no box chars are present and auto-detection picks indentation mode.","Remove the offending whitespace-indented lines or de-indent them to depth 0.","Normalise the editor to preserve box-drawing characters and avoid space-indenting children."],"exampleFix":"// before — mixed formats (box mode + space indent)\n├── root\n    childA\n    childB\n\n// after — consistent box-drawing\n├── root\n├── childA\n├── childB","handlingStrategy":"validation","validationCode":"// In box mode, reject whitespace-indented lines that have no box glyphs\nconst BOX = /[├└┗│┃─━]/;\nfor (let i = 0; i < lines.length; i++) {\n  if (/^\\s+/.test(lines[i]) && !BOX.test(lines[i])) {\n    throw new Error(`Line ${i + 1}: indentation without box characters`);\n  }\n}","typeGuard":"const isMixedFormatError = (e): boolean =>\n  e instanceof Error && /Unexpected indentation without box-drawing/.test(e.message);","tryCatchPattern":"try {\n  await mermaid.run({ nodes: [el] });\n} catch (e) {\n  if (e instanceof Error && /Unexpected indentation without box-drawing/.test(e.message)) {\n    // normalise the whole tree to one format (box-drawing or indentation)\n  } else { throw e; }\n}","preventionTips":["Use one tree format per diagram; don't mix indentation and box connectors.","Configure the editor to preserve box-drawing characters.","De-indent stray lines or convert them to ├── form."],"tags":["treeview","box-drawing","preprocessor","mixed-format","indentation"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}