diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index a71bf8156..0f1acdec8 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -1,6 +1,7 @@ #### Features ๐Ÿš€ - `--center` flag centers the SVG in the containing viewbox. [#1056](https://github.com/terrastruct/d2/pull/1056) +- Strikethrough in Markdown with `~~`. [#1059](https://github.com/terrastruct/d2/pull/1059) #### Improvements ๐Ÿงน diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index e6946bf56..30cdb8455 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -805,6 +805,8 @@ ww -> ff.gg - Visits always give pleasure: if not on arrival, then on the departure *Festivity Level 1*: Your guests are chatting amiably with each other. + +test ~~strikethrough~~ test | x -> hey -> y diff --git a/e2etests/testdata/stable/markdown/dagre/board.exp.json b/e2etests/testdata/stable/markdown/dagre/board.exp.json index daea96734..73b2e530e 100644 --- a/e2etests/testdata/stable/markdown/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown/dagre/board.exp.json @@ -11,7 +11,7 @@ "y": 166 }, "width": 531, - "height": 187, + "height": 227, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +30,7 @@ "fields": null, "methods": null, "columns": null, - "label": "# Every frustum longs to be a cone\n\n- A continuing flow of paper is sufficient to continue the flow of paper\n- Please remain calm, it's no use both of us being hysterical at the same time\n- Visits always give pleasure: if not on arrival, then on the departure\n\n*Festivity Level 1*: Your guests are chatting amiably with each other.", + "label": "# Every frustum longs to be a cone\n\n- A continuing flow of paper is sufficient to continue the flow of paper\n- Please remain calm, it's no use both of us being hysterical at the same time\n- Visits always give pleasure: if not on arrival, then on the departure\n\n*Festivity Level 1*: Your guests are chatting amiably with each other.\n\ntest ~~strikethrough~~ test", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -39,7 +39,7 @@ "bold": false, "underline": false, "labelWidth": 531, - "labelHeight": 187, + "labelHeight": 227, "zIndex": 0, "level": 1 }, @@ -89,7 +89,7 @@ "type": "rectangle", "pos": { "x": 239, - "y": 453 + "y": 493 }, "width": 54, "height": 66, @@ -202,21 +202,21 @@ "labelPosition": "", "labelPercentage": 0, "route": [ - { - "x": 265.5, - "y": 353 - }, { "x": 265.5, "y": 393 }, { "x": 265.5, - "y": 413 + "y": 433 }, { "x": 265.5, "y": 453 + }, + { + "x": 265.5, + "y": 493 } ], "isCurve": true, diff --git a/e2etests/testdata/stable/markdown/dagre/sketch.exp.svg b/e2etests/testdata/stable/markdown/dagre/sketch.exp.svg index e1b005ec1..8e693ced5 100644 --- a/e2etests/testdata/stable/markdown/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown/dagre/sketch.exp.svg @@ -1,23 +1,23 @@ -

Every frustum longs to be a cone

+

Every frustum longs to be a cone

  • A continuing flow of paper is sufficient to continue the flow of paper
  • Please remain calm, it's no use both of us being hysterical at the same time
  • Visits always give pleasure: if not on arrival, then on the departure

Festivity Level 1: Your guests are chatting amiably with each other.

-
xy - +

test strikethrough test

+
xy +
\ No newline at end of file diff --git a/e2etests/testdata/stable/markdown/elk/board.exp.json b/e2etests/testdata/stable/markdown/elk/board.exp.json index b163a67a9..19b4f1ff2 100644 --- a/e2etests/testdata/stable/markdown/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown/elk/board.exp.json @@ -11,7 +11,7 @@ "y": 148 }, "width": 531, - "height": 187, + "height": 227, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -30,7 +30,7 @@ "fields": null, "methods": null, "columns": null, - "label": "# Every frustum longs to be a cone\n\n- A continuing flow of paper is sufficient to continue the flow of paper\n- Please remain calm, it's no use both of us being hysterical at the same time\n- Visits always give pleasure: if not on arrival, then on the departure\n\n*Festivity Level 1*: Your guests are chatting amiably with each other.", + "label": "# Every frustum longs to be a cone\n\n- A continuing flow of paper is sufficient to continue the flow of paper\n- Please remain calm, it's no use both of us being hysterical at the same time\n- Visits always give pleasure: if not on arrival, then on the departure\n\n*Festivity Level 1*: Your guests are chatting amiably with each other.\n\ntest ~~strikethrough~~ test", "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", @@ -39,7 +39,7 @@ "bold": false, "underline": false, "labelWidth": 531, - "labelHeight": 187, + "labelHeight": 227, "zIndex": 0, "level": 1 }, @@ -89,7 +89,7 @@ "type": "rectangle", "pos": { "x": 250, - "y": 405 + "y": 445 }, "width": 54, "height": 66, @@ -195,11 +195,11 @@ "route": [ { "x": 277.5, - "y": 335 + "y": 375 }, { "x": 277.5, - "y": 405 + "y": 445 } ], "animated": false, diff --git a/e2etests/testdata/stable/markdown/elk/sketch.exp.svg b/e2etests/testdata/stable/markdown/elk/sketch.exp.svg index ef7c4e479..a551be31f 100644 --- a/e2etests/testdata/stable/markdown/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown/elk/sketch.exp.svg @@ -1,23 +1,23 @@ -

Every frustum longs to be a cone

+

Every frustum longs to be a cone

  • A continuing flow of paper is sufficient to continue the flow of paper
  • Please remain calm, it's no use both of us being hysterical at the same time
  • Visits always give pleasure: if not on arrival, then on the departure

Festivity Level 1: Your guests are chatting amiably with each other.

-
xy - +

test strikethrough test

+
xy +
\ No newline at end of file diff --git a/lib/textmeasure/markdown.go b/lib/textmeasure/markdown.go index bb9cdaa46..52501a7ac 100644 --- a/lib/textmeasure/markdown.go +++ b/lib/textmeasure/markdown.go @@ -8,6 +8,7 @@ import ( "github.com/PuerkitoBio/goquery" "github.com/yuin/goldmark" + "github.com/yuin/goldmark/extension" goldmarkHtml "github.com/yuin/goldmark/renderer/html" "golang.org/x/net/html" @@ -82,6 +83,9 @@ func init() { goldmarkHtml.WithUnsafe(), goldmarkHtml.WithXHTML(), ), + goldmark.WithExtensions( + extension.Strikethrough, + ), ) }