mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-22 12:16:22 +01:00
Compare commits
2 Commits
refactor/s
...
fix/7194-k
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2698a7870 | ||
|
|
31eb2fbf3e |
5
.changeset/giant-comics-wear.md
Normal file
5
.changeset/giant-comics-wear.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'mermaid': patch
|
||||
---
|
||||
|
||||
fix: render newlines in flowchart nodes containing KaTeX equations
|
||||
@@ -33,4 +33,70 @@ describe('Katex', () => {
|
||||
// { fontFamily: 'courier' }
|
||||
// );
|
||||
// });
|
||||
|
||||
describe('Katex with newlines (issue #7194)', () => {
|
||||
it('5: should render newlines in plain text nodes with math', () => {
|
||||
imgSnapshotTest(
|
||||
`graph TD
|
||||
plainmath["line 0
|
||||
line 1
|
||||
$$x=42$$
|
||||
line 2"]`,
|
||||
{ fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
it('6: should render newlines in markdown nodes with math', () => {
|
||||
imgSnapshotTest(
|
||||
`graph TD
|
||||
markdownmath["\`line 0
|
||||
line 1
|
||||
$$x=42$$
|
||||
line 2\`"]`,
|
||||
{ fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
it('7: should render multiple math equations with newlines between them', () => {
|
||||
imgSnapshotTest(
|
||||
`graph TD
|
||||
multimath["$$a=1$$
|
||||
text between
|
||||
$$b=2$$"]`,
|
||||
{ fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
it('8: should render newlines before and after math in markdown', () => {
|
||||
imgSnapshotTest(
|
||||
`graph TD
|
||||
beforeafter["\`line before
|
||||
$$x=42$$
|
||||
line after\`"]`,
|
||||
{ fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
it('9: should render complex example with multiple nodes containing math and newlines', () => {
|
||||
imgSnapshotTest(
|
||||
`graph TD
|
||||
plain["line 0
|
||||
line 1"]
|
||||
markdown["\`line 0
|
||||
line 1\`"]
|
||||
plainmath["line 0
|
||||
line 1
|
||||
$$x=42$$
|
||||
line 2"]
|
||||
markdownmath["\`line 0
|
||||
line 1
|
||||
$$x=42$$
|
||||
\`"]
|
||||
plain --> markdown
|
||||
markdown --> plainmath
|
||||
plainmath --> markdownmath`,
|
||||
{ fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -248,7 +248,9 @@ export const createText = async (
|
||||
const decodedReplacedText = await replaceIconSubstring(decodeEntities(htmlText), config);
|
||||
|
||||
//for Katex the text could contain escaped characters, \\relax that should be transformed to \relax
|
||||
const inputForKatex = text.replace(/\\\\/g, '\\');
|
||||
const inputForKatex = hasKatex(text)
|
||||
? markdownToHTML(text.replace(/\\\\/g, '\\'), config)
|
||||
: text.replace(/\\\\/g, '\\');
|
||||
|
||||
const node = {
|
||||
isNode,
|
||||
|
||||
Reference in New Issue
Block a user