fix: inconsistent MathML rendering & erroneous <br />s being added #5483
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📑 Summary
Resolves #5435
📏 Design Decisions
1)
As mentioned in the PR, differences between the default fonts for each OS was not taken into account when I implemented the
useLegacyMathML
config option. As a result, there is currently no way to force Mermaid to fallback to using KaTeX's stylesheets if they are provided. To allow this to be done, I added an additional config optionforceLegacyMathML
to explicitly tell Mermaid to default to CSS-based rendering.Ideally this should be changed to a single config option that takes one of 3 values but I don't know what the protocol for deprecating config options are.
2)
While fixing the above I noticed the spacing for some equations in flowchart vertices were incorrect. This was due to an erroneous
<br />
tags being added by the regex replacementvertexText.replace(/\\n|\n/g, '<br />')
being triggered on unintended line breaks in the template string inrenderKatex()
.Before:
After:
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.develop
branch