@ts-graphviz/ast 2.0.4 → 2.0.5-next-026e7d1a8f96034e4475bbc8626a8be8fa7b925c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ts-graphviz/ast
2
2
 
3
+ ## 2.0.5-next-026e7d1a8f96034e4475bbc8626a8be8fa7b925c
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1204](https://github.com/ts-graphviz/ts-graphviz/pull/1204) [`03bafa0`](https://github.com/ts-graphviz/ts-graphviz/commit/03bafa0e10b43807b5568df4ffba720752a0ac02) Thanks [@kamiazya](https://github.com/kamiazya)! - Fix string escaping in DOT language
8
+
3
9
  ## 2.0.4
4
10
 
5
11
  ### Patch Changes
package/lib/ast.cjs CHANGED
@@ -47,7 +47,17 @@ function wrapByPair(l, r) {
47
47
  function leftPadWith(left) {
48
48
  return (value) => left + value;
49
49
  }
50
- const escape = (value) => value.replace(/\\/g, "\\\\").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/"/g, '\\"');
50
+ const escape = (value) => value.replace(/(?<!\\)"|[\r\n]/g, escapeReplacer);
51
+ function escapeReplacer(match) {
52
+ switch (match) {
53
+ case "\r":
54
+ return "\\r";
55
+ case "\n":
56
+ return "\\n";
57
+ default:
58
+ return '\\"';
59
+ }
60
+ }
51
61
  const splitByLine = (value) => value.split(EOL);
52
62
  const indent = (style, size, eol) => common.pipe(
53
63
  splitByLine,
package/lib/ast.js CHANGED
@@ -45,7 +45,17 @@ function wrapByPair(l, r) {
45
45
  function leftPadWith(left) {
46
46
  return (value) => left + value;
47
47
  }
48
- const escape = (value) => value.replace(/\\/g, "\\\\").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/"/g, '\\"');
48
+ const escape = (value) => value.replace(/(?<!\\)"|[\r\n]/g, escapeReplacer);
49
+ function escapeReplacer(match) {
50
+ switch (match) {
51
+ case "\r":
52
+ return "\\r";
53
+ case "\n":
54
+ return "\\n";
55
+ default:
56
+ return '\\"';
57
+ }
58
+ }
49
59
  const splitByLine = (value) => value.split(EOL);
50
60
  const indent = (style, size, eol) => pipe(
51
61
  splitByLine,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-graphviz/ast",
3
- "version": "2.0.4",
3
+ "version": "2.0.5-next-026e7d1a8f96034e4475bbc8626a8be8fa7b925c",
4
4
  "description": "Graphviz AST(Abstract Syntax Tree) Utilities",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/ts-graphviz/ts-graphviz#readme",