bitcrowd / mdast-util-from-adf

Convert from Atlassian Document Format to Markdown Abstract Syntax Tree
MIT License
11 stars 1 forks source link

Add support for `expand` nodes #25

Closed pmeinhardt closed 2 years ago

pmeinhardt commented 2 years ago

See this issue on Tickety Tick for additional context and examples.

pmeinhardt commented 2 years ago

Update: I've looked into converting expand ADF nodes into <details> + <summary> in the MDAST/Markdown output. MDAST HTML nodes only accept content as a plain string and no nested nodes. This means either:

  1. Any children of an expand ADF node would have to be converted to plain HTML and stringified. We would need to apply this package itself in combination with other MDAST/HAST packages to the child nodes (see this example). This does not seem like a desirable approach to me, mostly for complexity reasons and the necessity to pull in more dependencies (likely to conflict with packages in scenarios where mdast-util-from-adf is supposed to be used). 😬
  2. I've checked what happens if we create multiple sibling MDAST nodes from an expand. When subsequently converting this yields the desired result – however with an unsolved problem: 🪃
    1. HTML node with content <details>
    2. HTML node with content <summary> + expand title + </summary>
    3. dummy content as a stand-in for the experiment (as in a proper conversion, the MDAST tree resulting from conversion of expand would have to be attached with a single root, a "transparent" node which does not exist at the moment)
    4. HTML node with content </details>
  3. An "easy" fix for now could be to just ignore the expand and continue processing its children instead. This means the ADF expand will not be represented in the MDAST output, but its children/content will. 🧽
  4. Are there other solutions? 🤔