Skip to content

Strikethrough range incorrectly detected for multiline text #183

@shp7724

Description

@shp7724

The range for a multiline strikethrough is incorrectly detected when parsing a Markdown string using swift-markdown. Specifically, the detected range ends prematurely at the first line of the strikethrough block instead of spanning the entire multiline strikethrough content.

Steps to reproduce

let string = """
para1

~~this
is
multiline
strikethrough~~

para2
"""
let document = Document(parsing: string)
print(document.debugDescription(options: .printEverything))

Expected Output:

The strikethrough range should correctly span from the start of the first line to the end of the last line, i.e., from 3:1 to 6:16.

Actual Output:

The strikethrough range is detected as 3:1-3:16, which only covers the first line of the multiline strikethrough block:

Document @1:1-8:6 Root #2 #0
├─ Paragraph @1:1-1:6 #1
│  └─ Text @1:1-1:6 #2 "para1"
├─ Paragraph @3:1-6:16 #3
│  └─ Strikethrough @3:1-3:16 #4
│     ├─ Text @3:3-3:7 #5 "this"
│     ├─ SoftBreak #6
│     ├─ Text @4:1-4:3 #7 "is"
│     ├─ SoftBreak #8
│     ├─ Text @5:1-5:10 #9 "multiline"
│     ├─ SoftBreak #10
│     └─ Text @6:1-6:14 #11 "strikethrough"
└─ Paragraph @8:1-8:6 #12
   └─ Text @8:1-8:6 #13 "para2"

Strikethrough @3:1-3:16 #4

Environment:

  • swift-markdown version: 0.4.0
  • Xcode version: 15.4.0

Questions:

  • Is this behavior from the upstreams, such as cmark-gfm?
  • Can this possibly be fixed in a future release?

Related issues found:

Thank you for your assistance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions