mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-22 17:56:43 +02:00
Remove escaped quotes with backslash feature
This commit is contained in:
@@ -901,13 +901,8 @@ graph TD
|
||||
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
|
||||
);
|
||||
});
|
||||
it('67: allow escaping quotes with backslash', () => {
|
||||
imgSnapshotTest(`
|
||||
graph TD
|
||||
a_node("This has an escaped \\" in it") -- "edge string can escape too \\"" --> b_node
|
||||
`);
|
||||
});
|
||||
it('68: should be able to style default node independently', () => {
|
||||
|
||||
it('67: should be able to style default node independently', () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
flowchart TD
|
||||
|
@@ -610,13 +610,11 @@ For quotation marks, you can escape them with a backslash as well.
|
||||
```mermaid-example
|
||||
flowchart LR
|
||||
A["A double quote:#quot;"] --> B["A dec char:#9829;"]
|
||||
B --> C["This is a \"square\" vertex"]
|
||||
```
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
A["A double quote:#quot;"] --> B["A dec char:#9829;"]
|
||||
B --> C["This is a \"square\" vertex"]
|
||||
```
|
||||
|
||||
Numbers given are base 10, so `#` can be encoded as `#35;`. It is also supported to use HTML character names.
|
||||
|
@@ -91,7 +91,6 @@ export const addVertex = function (_id, textObj, type, style, classes, dir, prop
|
||||
if (textObj !== undefined) {
|
||||
config = configApi.getConfig();
|
||||
txt = sanitizeText(textObj.text.trim());
|
||||
txt = textObj.type === 'string' ? txt.replaceAll('\\"', '"') : txt;
|
||||
vertices[id].labelType = textObj.type;
|
||||
// strip quotes if string starts and ends with a quote
|
||||
if (txt[0] === '"' && txt[txt.length - 1] === '"') {
|
||||
|
@@ -598,13 +598,6 @@ describe('[Text] when parsing', () => {
|
||||
expect(() => flow.parser.parse(str)).toThrowError("Expecting 'SQE'");
|
||||
});
|
||||
|
||||
it('should parse escaped quotes in a string state', function () {
|
||||
//prettier-ignore
|
||||
flow.parser.parse('graph TD; A["This is a \\"()\\" in text"];'); //eslint-disable-line no-useless-escape
|
||||
const vert = flow.parser.yy.getVertices();
|
||||
expect(vert['A'].text).toBe('This is a "()" in text');
|
||||
});
|
||||
|
||||
it('should throw error', function () {
|
||||
const str = `graph TD; node[hello ) world] --> works`;
|
||||
expect(() => flow.parser.parse(str)).toThrowError("got 'PE'");
|
||||
|
@@ -61,7 +61,7 @@ Function arguments are optional: 'call <callbackname>()' simply executes 'callba
|
||||
<md_string>[^`"]+ { return "MD_STR";}
|
||||
<md_string>[`]["] { this.popState();}
|
||||
<*>["][`] { this.begin("md_string");}
|
||||
<string>(\\(?=\")\"|[^"])+ return "STR";
|
||||
<string>[^"]+ return "STR";
|
||||
<string>["] this.popState();
|
||||
<*>["] this.pushState("string");
|
||||
"style" return 'STYLE';
|
||||
|
@@ -392,7 +392,6 @@ For quotation marks, you can escape them with a backslash as well.
|
||||
```mermaid-example
|
||||
flowchart LR
|
||||
A["A double quote:#quot;"] --> B["A dec char:#9829;"]
|
||||
B --> C["This is a \"square\" vertex"]
|
||||
```
|
||||
|
||||
Numbers given are base 10, so `#` can be encoded as `#35;`. It is also supported to use HTML character names.
|
||||
|
Reference in New Issue
Block a user