swiftlang / swift-markdown

A Swift package for parsing, building, editing, and analyzing Markdown documents.
https://swiftpackageindex.com/swiftlang/swift-markdown/documentation/markdown
Apache License 2.0
2.78k stars 190 forks source link

Strikethrough rendering should be configurable #168

Open rahilb opened 8 months ago

rahilb commented 8 months ago

It is expected that if I parse and then format a markdown document I should be able to get a rendered string that is identical to the input string, i.e. it should be possible to satisfy the condition markdownString == (parse(markdownString).format())

However parsing the following document:

~~line 1~~
~~line 2~~

and immediately calling .format()

results in the following string:

~line 1~
~line 2~

ExtendedMark defines strikethrough using ~~ https://www.markdownguide.org/extended-syntax/#strikethrough

Commonmark does not specify Strikethrough elements and all the specifications I can find call for ~~.

The library is able to parse the strikethrough element, e.g.

├─ Paragraph
│  ├─ Strikethrough
│  │  └─ Text "line 1"
│  ├─ SoftBreak
│  └─ Strikethrough
│     └─ Text "line 2"

Suggestion: Rendering of the Strikethrough ADT element should be configurable or changed to render as ~~.

QuietMisdreavus commented 8 months ago

Swift-Markdown is based the GitHub-Flavored Markdown specification, which allows one or two tildes for strikethrough. The formatting is only meant to be semantically equivalent to the input, not textually equivalent. We can use this issue to track configurable strikethrough markers, though, so that your example can still format as desired.