From a554e405418941b8c7515b2ed571dccdbd4f9864 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 7 Nov 2022 11:14:48 -0800 Subject: [PATCH] add md code block tests --- .../todo/md_code_block_fenced/board.exp.json | 214 +++++ .../todo/md_code_block_fenced/sketch.exp.svg | 819 ++++++++++++++++++ .../md_code_block_indented/board.exp.json | 214 +++++ .../md_code_block_indented/sketch.exp.svg | 818 +++++++++++++++++ .../todo/md_code_inline/board.exp.json | 214 +++++ .../todo/md_code_inline/sketch.exp.svg | 815 +++++++++++++++++ e2etests/todo_test.go | 30 +- 7 files changed, 3122 insertions(+), 2 deletions(-) create mode 100644 e2etests/testdata/todo/md_code_block_fenced/board.exp.json create mode 100644 e2etests/testdata/todo/md_code_block_fenced/sketch.exp.svg create mode 100644 e2etests/testdata/todo/md_code_block_indented/board.exp.json create mode 100644 e2etests/testdata/todo/md_code_block_indented/sketch.exp.svg create mode 100644 e2etests/testdata/todo/md_code_inline/board.exp.json create mode 100644 e2etests/testdata/todo/md_code_inline/sketch.exp.svg diff --git a/e2etests/testdata/todo/md_code_block_fenced/board.exp.json b/e2etests/testdata/todo/md_code_block_fenced/board.exp.json new file mode 100644 index 000000000..7040a1f5d --- /dev/null +++ b/e2etests/testdata/todo/md_code_block_fenced/board.exp.json @@ -0,0 +1,214 @@ +{ + "name": "", + "shapes": [ + { + "id": "md", + "type": "text", + "pos": { + "x": 0, + "y": 226 + }, + "width": 157, + "height": 130, + "level": 1, + "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": "```\n{\n\tfenced: \"block\",\n\tof: \"json\",\n}\n```", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 157, + "labelHeight": 130 + }, + { + "id": "a", + "type": "", + "pos": { + "x": 22, + "y": 0 + }, + "width": 113, + "height": 126, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER" + }, + { + "id": "b", + "type": "", + "pos": { + "x": 22, + "y": 456 + }, + "width": 113, + "height": 126, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER" + } + ], + "connections": [ + { + "id": "(a -> md)[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "md", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 78.5, + "y": 126 + }, + { + "x": 78.5, + "y": 166 + }, + { + "x": 78.5, + "y": 186 + }, + { + "x": 78.5, + "y": 226 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null + }, + { + "id": "(md -> b)[0]", + "src": "md", + "srcArrow": "none", + "srcLabel": "", + "dst": "b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 78.5, + "y": 356 + }, + { + "x": 78.5, + "y": 396 + }, + { + "x": 78.5, + "y": 416 + }, + { + "x": 78.5, + "y": 456 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null + } + ] +} diff --git a/e2etests/testdata/todo/md_code_block_fenced/sketch.exp.svg b/e2etests/testdata/todo/md_code_block_fenced/sketch.exp.svg new file mode 100644 index 000000000..b8692feab --- /dev/null +++ b/e2etests/testdata/todo/md_code_block_fenced/sketch.exp.svg @@ -0,0 +1,819 @@ + +
{
+	fenced: "block",
+	of: "json",
+}
+
+
ab
\ No newline at end of file diff --git a/e2etests/testdata/todo/md_code_block_indented/board.exp.json b/e2etests/testdata/todo/md_code_block_indented/board.exp.json new file mode 100644 index 000000000..d2de66634 --- /dev/null +++ b/e2etests/testdata/todo/md_code_block_indented/board.exp.json @@ -0,0 +1,214 @@ +{ + "name": "", + "shapes": [ + { + "id": "md", + "type": "text", + "pos": { + "x": 0, + "y": 226 + }, + "width": 213, + "height": 29, + "level": 1, + "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": "{\n indented: \"block\",\n of: \"json\",\n}", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 213, + "labelHeight": 29 + }, + { + "id": "a", + "type": "", + "pos": { + "x": 50, + "y": 0 + }, + "width": 113, + "height": 126, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER" + }, + { + "id": "b", + "type": "", + "pos": { + "x": 50, + "y": 355 + }, + "width": 113, + "height": 126, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER" + } + ], + "connections": [ + { + "id": "(a -> md)[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "md", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 106.5, + "y": 126 + }, + { + "x": 106.5, + "y": 166 + }, + { + "x": 106.5, + "y": 186 + }, + { + "x": 106.5, + "y": 226 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null + }, + { + "id": "(md -> b)[0]", + "src": "md", + "srcArrow": "none", + "srcLabel": "", + "dst": "b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 106.5, + "y": 255 + }, + { + "x": 106.5, + "y": 295 + }, + { + "x": 106.5, + "y": 315 + }, + { + "x": 106.5, + "y": 355 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null + } + ] +} diff --git a/e2etests/testdata/todo/md_code_block_indented/sketch.exp.svg b/e2etests/testdata/todo/md_code_block_indented/sketch.exp.svg new file mode 100644 index 000000000..f0f7b544a --- /dev/null +++ b/e2etests/testdata/todo/md_code_block_indented/sketch.exp.svg @@ -0,0 +1,818 @@ + +

{ +indented: "block", +of: "json", +}

+
ab
\ No newline at end of file diff --git a/e2etests/testdata/todo/md_code_inline/board.exp.json b/e2etests/testdata/todo/md_code_inline/board.exp.json new file mode 100644 index 000000000..f4d6322b1 --- /dev/null +++ b/e2etests/testdata/todo/md_code_inline/board.exp.json @@ -0,0 +1,214 @@ +{ + "name": "", + "shapes": [ + { + "id": "md", + "type": "text", + "pos": { + "x": 38, + "y": 226 + }, + "width": 38, + "height": 29, + "level": 1, + "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": "`code`", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 38, + "labelHeight": 29 + }, + { + "id": "a", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 113, + "height": 126, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER" + }, + { + "id": "b", + "type": "", + "pos": { + "x": 0, + "y": 355 + }, + "width": 113, + "height": 126, + "level": 1, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER" + } + ], + "connections": [ + { + "id": "(a -> md)[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "md", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 56.5, + "y": 126 + }, + { + "x": 56.5, + "y": 166 + }, + { + "x": 56.5, + "y": 186 + }, + { + "x": 56.5, + "y": 226 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null + }, + { + "id": "(md -> b)[0]", + "src": "md", + "srcArrow": "none", + "srcLabel": "", + "dst": "b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 56.5, + "y": 255 + }, + { + "x": 56.5, + "y": 295 + }, + { + "x": 56.5, + "y": 315 + }, + { + "x": 56.5, + "y": 355 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null + } + ] +} diff --git a/e2etests/testdata/todo/md_code_inline/sketch.exp.svg b/e2etests/testdata/todo/md_code_inline/sketch.exp.svg new file mode 100644 index 000000000..41f2b9906 --- /dev/null +++ b/e2etests/testdata/todo/md_code_inline/sketch.exp.svg @@ -0,0 +1,815 @@ + +

code

+
ab
\ No newline at end of file diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index 8a6adebab..6e522a236 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -10,12 +10,38 @@ func testTodo(t *testing.T) { // https://github.com/terrastruct/d2/issues/24 // string monstrosity from not being able to escape backticks within string literals { - skip: true, - name: "backtick", + skip: false, + name: "md_code_inline", script: `md: |md ` + "`" + "code`" + ` | a -> md -> b +`, + }, + { + skip: false, + name: "md_code_block_fenced", + script: `md: |md +` + "```" + ` +{ + fenced: "block", + of: "json", +} +` + "```" + ` +| +a -> md -> b +`, + }, + { + skip: false, + name: "md_code_block_indented", + script: `md: |md + { + indented: "block", + of: "json", + } +| +a -> md -> b `, }, }