From 2ab9f434e16cf6128289ae71bc82b5c9dae6cf67 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 12 Feb 2023 12:01:33 -0800 Subject: [PATCH] escape using html --- .../diagram_wider_than_tooltip/sketch.exp.svg | 2 +- .../appendix/testdata/links/sketch.exp.svg | 2 +- .../tooltip_wider_than_diagram/sketch.exp.svg | 2 +- d2renderers/d2svg/d2svg.go | 2 +- e2etests/regression_test.go | 9 ++ .../ampersand-escape/dagre/board.exp.json | 130 ++++++++++++++++++ .../ampersand-escape/dagre/sketch.exp.svg | 68 +++++++++ .../ampersand-escape/elk/board.exp.json | 130 ++++++++++++++++++ .../ampersand-escape/elk/sketch.exp.svg | 68 +++++++++ .../dagre_special_ids/dagre/sketch.exp.svg | 2 +- .../dagre_special_ids/elk/sketch.exp.svg | 2 +- .../stable/links/dagre/sketch.exp.svg | 2 +- .../testdata/stable/links/elk/sketch.exp.svg | 2 +- .../dagre/sketch.exp.svg | 2 +- .../elk/sketch.exp.svg | 2 +- .../stable/tooltips/dagre/sketch.exp.svg | 2 +- .../stable/tooltips/elk/sketch.exp.svg | 2 +- lib/svg/text.go | 7 +- 18 files changed, 419 insertions(+), 17 deletions(-) create mode 100644 e2etests/testdata/regression/ampersand-escape/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/ampersand-escape/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/ampersand-escape/elk/board.exp.json create mode 100644 e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg diff --git a/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg b/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg index d2aee73c9..cf50b884e 100644 --- a/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg +++ b/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg @@ -39,7 +39,7 @@ width="1433" height="1589" viewBox="-146 -71 1433 1589">&∈ + + + + + + + + + + + + +beans & ricefoo&bar + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/ampersand-escape/elk/board.exp.json b/e2etests/testdata/regression/ampersand-escape/elk/board.exp.json new file mode 100644 index 000000000..72514d740 --- /dev/null +++ b/e2etests/testdata/regression/ampersand-escape/elk/board.exp.json @@ -0,0 +1,130 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "h&y", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 98, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "beans & rice", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "&∈", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 21, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "foo", + "type": "rectangle", + "pos": { + "x": 130, + "y": 12 + }, + "width": 69, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "foo", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 24, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"&bar\"", + "type": "rectangle", + "pos": { + "x": 219, + "y": 12 + }, + "width": 81, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "&bar", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 36, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg b/e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg new file mode 100644 index 000000000..4af4dc8e3 --- /dev/null +++ b/e2etests/testdata/regression/ampersand-escape/elk/sketch.exp.svg @@ -0,0 +1,68 @@ + +&∈ + + + + + + + + + + + + +beans & ricefoo&bar + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg b/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg index 35734e017..dfc6918e6 100644 --- a/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="1071" height="452" viewBox="-102 -102 1071 452">