Flowchart parsing issue with CRLF
See original GitHub issueDescribe the bug Mermaid sometimes fails to parse valid flowchart input if new lines are encoded as CRLF instead of LF. This causes unexpected behaviour when using subgraphs, and potentially in other situations too. This may occur when static content served by Windows systems is fed to Mermaid.
Potential root cause
This might be caused by flow.jison defining NEWLINE
as \n
instead of the more platform independent regex \r?\n
.
Workarounds
- Convert CRLF to LF, either programmatically or on the file system
- Migrate away from Windows
To Reproduce See codepen and snippet below. The last statement results in a parsing error in the console.
const dotest = (test, input) => {
try {
mermaid.render(test, input, () => {});
} catch (err) {
console.error("Error in %s:\n\n%s", test, err);
}
};
mermaid.initialize({startOnLoad: false});
dotest("Test1", "graph LR\nsubgraph\nA --> B\nend");
dotest("Test2", "graph LR\r\nsubgraph\r\nA --> B\r\nend");
Expected behavior No errors are written to the console.
Desktop (please complete the following information):
- Mermaid: 8.2.3
- OS: Windows 7
- Browser: Google Chrome
- Version: 75.0.3770.142
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
mermaid in wiki showing error for valid flowchart
I am getting this error for a flow chart that shows up correctly in most other markdown rendering tools: Parse error on line...
Read more >Line breaks no longer work in Mermaid diagrams - GitLab.org
Mermaid renders labels in two ways depending on whether flowchart.htmlLabels is enabled or not, so whitelisting tags, parsing HTML, and ...
Read more >Mermaid CLI - how do you escape characters? - Stack Overflow
I'm using the Mermaid CLI to generate a flowchart (http://knsv.github.io/mermaid/ ...
Read more >Carriage Return characters are being stripped after parsing an ...
After parsing an XML doc containing CRLF control chars, it will strip the Carriage Return characters and the output only contains Line Feed ......
Read more >Review of 'mermaid - flowcharts, diagrams, etc.'
Review of 'mermaid - flowcharts, diagrams, etc.' Apr 13, 2020 ... mermaid.cli@0.5.1 # Use C.UTF-8 locale to avoid issues with ASCII encoding ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This seems to me like a good start for someone who is new to the project. I’d like to give it a try if that’s ok for you.
Thank you everyone for your contributions!