question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flowchart parsing issue with CRLF

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
GDFabercommented, Sep 26, 2019

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.

0reactions
IOrlandonicommented, Sep 27, 2019

Thank you everyone for your contributions!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found