diff --git a/d2renderers/textmeasure/markdown.go b/d2renderers/textmeasure/markdown.go index 3b538759b..943c86a78 100644 --- a/d2renderers/textmeasure/markdown.go +++ b/d2renderers/textmeasure/markdown.go @@ -85,6 +85,7 @@ func init() { markdownRenderer = goldmark.New( goldmark.WithRendererOptions( goldmarkHtml.WithUnsafe(), + goldmarkHtml.WithXHTML(), ), ) } diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index 2bfb4d5a5..31acccc44 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -925,6 +925,28 @@ x -> y: { stroke-dash: 5 } } +`, + }, + { + name: "md_2space_newline", + script: ` +markdown: { + md: |md +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +| +} +`, + }, + { + name: "md_backslash_newline", + script: ` +markdown: { + md: |md +Lorem ipsum dolor sit amet, consectetur adipiscing elit,\ +sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +| +} `, }, } diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json new file mode 100644 index 000000000..921aedf67 --- /dev/null +++ b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json @@ -0,0 +1,81 @@ +{ + "name": "", + "shapes": [ + { + "id": "markdown", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 930, + "height": 124, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "markdown", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 129, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER" + }, + { + "id": "markdown.md", + "type": "text", + "pos": { + "x": 50, + "y": 50 + }, + "width": 830, + "height": 24, + "level": 2, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 830, + "labelHeight": 24 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg new file mode 100644 index 000000000..00a2aa962 --- /dev/null +++ b/e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg @@ -0,0 +1,789 @@ + +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
\ No newline at end of file diff --git a/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json b/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json new file mode 100644 index 000000000..fb14fef9c --- /dev/null +++ b/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json @@ -0,0 +1,81 @@ +{ + "name": "", + "shapes": [ + { + "id": "markdown", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 980, + "height": 174, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "markdown", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 129, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER" + }, + { + "id": "markdown.md", + "type": "text", + "pos": { + "x": 87, + "y": 87 + }, + "width": 830, + "height": 24, + "level": 2, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 830, + "labelHeight": 24 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/stable/md_2space_newline/elk/sketch.exp.svg b/e2etests/testdata/stable/md_2space_newline/elk/sketch.exp.svg new file mode 100644 index 000000000..1c040e680 --- /dev/null +++ b/e2etests/testdata/stable/md_2space_newline/elk/sketch.exp.svg @@ -0,0 +1,789 @@ + +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
\ No newline at end of file diff --git a/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json new file mode 100644 index 000000000..d87168272 --- /dev/null +++ b/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json @@ -0,0 +1,81 @@ +{ + "name": "", + "shapes": [ + { + "id": "markdown", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 930, + "height": 124, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "markdown", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 129, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER" + }, + { + "id": "markdown.md", + "type": "text", + "pos": { + "x": 50, + "y": 50 + }, + "width": 830, + "height": 24, + "level": 2, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\\\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 830, + "labelHeight": 24 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/stable/md_backslash_newline/dagre/sketch.exp.svg b/e2etests/testdata/stable/md_backslash_newline/dagre/sketch.exp.svg new file mode 100644 index 000000000..00a2aa962 --- /dev/null +++ b/e2etests/testdata/stable/md_backslash_newline/dagre/sketch.exp.svg @@ -0,0 +1,789 @@ + +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
\ No newline at end of file diff --git a/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json b/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json new file mode 100644 index 000000000..0d2e9869d --- /dev/null +++ b/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json @@ -0,0 +1,81 @@ +{ + "name": "", + "shapes": [ + { + "id": "markdown", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 980, + "height": 174, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "markdown", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 129, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER" + }, + { + "id": "markdown.md", + "type": "text", + "pos": { + "x": 87, + "y": 87 + }, + "width": 830, + "height": 24, + "level": 2, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\\\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 830, + "labelHeight": 24 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/stable/md_backslash_newline/elk/sketch.exp.svg b/e2etests/testdata/stable/md_backslash_newline/elk/sketch.exp.svg new file mode 100644 index 000000000..1c040e680 --- /dev/null +++ b/e2etests/testdata/stable/md_backslash_newline/elk/sketch.exp.svg @@ -0,0 +1,789 @@ + +markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+
\ No newline at end of file