Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove right padding when a label contains HTML entities #3222

Merged
merged 1 commit into from Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions cypress/integration/rendering/stateDiagram-v2.spec.js
Expand Up @@ -509,4 +509,16 @@ stateDiagram-v2
expect(svg).to.not.have.attr('style');
});
});

it('v2 should render a state diagram and set the correct length of the labels', () => {
imgSnapshotTest(
`
stateDiagram-v2
[*] --> 1
1 --> 2: test({ foo#colon; 'far' })
2 --> [*]
`,
{ logLevel: 0, fontFamily: 'courier' }
);
});
});
3 changes: 2 additions & 1 deletion src/dagre-wrapper/createLabel.js
Expand Up @@ -2,6 +2,7 @@ import { select } from 'd3';
import { log } from '../logger'; // eslint-disable-line
import { getConfig } from '../config';
import { sanitizeText, evaluate } from '../diagrams/common/common';
import { decodeEntities } from '../mermaidAPI';

const sanitizeTxt = (txt) => sanitizeText(txt, getConfig());

Expand Down Expand Up @@ -52,7 +53,7 @@ const createLabel = (_vertexText, style, isTitle, isNode) => {
log.info('vertexText' + vertexText);
const node = {
isNode,
label: vertexText.replace(
label: decodeEntities(vertexText).replace(
/fa[lrsb]?:fa-[\w-]+/g,
(s) => `<i class='${s.replace(':', ' ')}'></i>`
),
Expand Down