Skip to content

Nested GFM strikethrough breaks into sibling deletes on round-trip #3

Description

@ChristianMurphy

Initial checklist

Affected package

mdast-util-gfm 3.1.0, mdast-util-to-markdown 2.1.2, mdast-util-from-markdown 2.0.3

Steps to reproduce

Input (9 bytes):

~~a~a~a~~

tree₁ has delete > [text, delete > text, text]:

{
  "type": "delete",
  "children": [
    { "type": "text", "value": "a" },
    { "type": "delete", "children": [{ "type": "text", "value": "a" }] },
    { "type": "text", "value": "a" }
  ]
}

stringify:

~~a~~a~~a~~

tree₂ flattens to three siblings:

{
  "type": "paragraph",
  "children": [
    { "type": "delete", "children": [{ "type": "text", "value": "a" }] },
    { "type": "text", "value": "a" },
    { "type": "delete", "children": [{ "type": "text", "value": "a" }] }
  ]
}
import {fromMarkdown} from 'mdast-util-from-markdown'
import {toMarkdown} from 'mdast-util-to-markdown'
import {gfm} from 'micromark-extension-gfm'
import {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm'

const opts = {extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()]}
const tree1 = fromMarkdown('~~a~a~a~~', opts)
const text2 = toMarkdown(tree1, {extensions: [gfmToMarkdown()]})
const tree2 = fromMarkdown(text2, opts)

Actual behavior

Adjacent ~~ closing + ~~ opening delimiters parse as sibling strikethrough spans instead of nested ones. Analogous to the nested-emphasis issue but for GFM strikethrough.

Expected behavior

Nested delete with text siblings preserves nesting across round-trip, same as the equivalent emphasis cases should.

Runtime

node v24.13.1

Package manager

No response

Operating system

Ubuntu (WSL2)

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤞 phase/openPost is being triaged manually

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions