`swift-markdown` doesn't detect Strong correctly in a specific case
Closed this issue · 1 comments
fumo1222 commented
swift-markdown
doesn't detect Strong in
**b`h`** + letters or numbers
Examples:
**b`h`**abc
**b`h`**3k
Strong is correctly detected when the strings right after the markdown start with a sign, such as:
Examples:
**b`h`**=ab
**b`h`**/
or there is a space, such as:
Example:
**b`h`** a
I think swift-markdown
should detect Strong in the first case as well.
Steps to reproduce
let markdown = "**b`h`**a"
let document = Document(parsing: markdown)
print("\(document.debugDescription())")
Expected output:
Document
└─ Paragraph
├─ Strong
│ ├─ Text "b"
│ └─ InlineCode `h`
└─ Text "a"
Actual Output:
** isn't detected as Bold but as plain text.
Document
└─ Paragraph
├─ Text "**b"
├─ InlineCode `h`
└─ Text "**a"
Similar situations where it works as expected
let markdown = "**b`h`** c"
Document
└─ Paragraph
├─ Strong
│ ├─ Text "b"
│ └─ InlineCode `h`
└─ Text " c"
let markdown = "**b`h`**="
Document
└─ Paragraph
├─ Strong
│ ├─ Text "b"
│ └─ InlineCode `h`
└─ Text "="
let markdown = "**`b`h**a"
Document
└─ Paragraph
├─ Strong
│ ├─ InlineCode `b`
│ └─ Text "h"
└─ Text "a"
let markdown = "**b~h~**a"
Document
└─ Paragraph
├─ Strong
│ ├─ Text "b"
│ └─ Strikethrough
│ └─ Text "h"
└─ Text "a"
let markdown = "**b*h***a"
Document
└─ Paragraph
├─ Strong
│ ├─ Text "b"
│ └─ Emphasis
│ └─ Text "h"
└─ Text "a"
Environment
- swift-markdown version: 0.4.0
- Xcode version: 15.4 (15F31d)
- macOS version: 14.3.1(23D60)
QuietMisdreavus commented
This is expected behavior. Emphasis delimiters cannot close emphasis if they are between punctuation and alphanumeric characters. This is part of the upstream GitHub-Flavored Markdown specification as well as the spec and implementation for its upstream CommonMark.