Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for expand nodes #25

Closed
pmeinhardt opened this issue Sep 9, 2022 · 1 comment · Fixed by #26
Closed

Add support for expand nodes #25

pmeinhardt opened this issue Sep 9, 2022 · 1 comment · Fixed by #26

Comments

@pmeinhardt
Copy link
Collaborator

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

pmeinhardt added a commit to pmeinhardt/mdast-util-from-adf that referenced this issue Sep 9, 2022
@pmeinhardt
Copy link
Collaborator Author

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? 🤔

pmeinhardt added a commit to pmeinhardt/mdast-util-from-adf that referenced this issue Oct 11, 2022
For now, ADF `expand` and `nestedExpand` nodes will be skipped, meaning
the nodes themselves do not create a counterpart in the resulting MDAST
tree. Their child nodes however will be processed and attached to the
output tree.

An alternative to skipping "expand" nodes could be to represent them as
a sequence of MDAST nodes:

1. HTML node: `<details>`
2. HTML node: `<summary>` + expand node title + `</summary>`
3. MDAST nodes for the "expand" node content (the current output)
4. HTML node: `</details>`

This produces adequate output when converting the ADF to Markdown and
HTML. However, it also comes with its own set of challenges and arguably
makes the MDAST tree representation look rather odd, with HTML nodes
containing invalid HTML content. The opening and closing `<details>`
tags are not valid on their own – though the MDAST documentation
explicitly states that HTML nodes do not need to contain "valid or
complete HTML" (https://github.com/syntax-tree/mdast#html).

For the moment, we go with the "simple" path of ignoring expand nodes.

bitcrowd#25
pmeinhardt added a commit to pmeinhardt/mdast-util-from-adf that referenced this issue Oct 11, 2022
For now, ADF `expand` and `nestedExpand` nodes will be skipped, meaning
the nodes themselves do not create a counterpart in the resulting MDAST
tree. Their child nodes however will be processed and attached to the
output tree.

An alternative to skipping "expand" nodes could be to represent them as
a sequence of MDAST nodes:

1. HTML node: `<details>`
2. HTML node: `<summary>` + expand node title + `</summary>`
3. MDAST nodes for the "expand" node content (the current output)
4. HTML node: `</details>`

This produces adequate output when converting the ADF to Markdown and
HTML. However, it also comes with its own set of challenges and arguably
makes the MDAST tree representation look rather odd, with HTML nodes
containing invalid HTML content. The opening and closing `<details>`
tags are not valid on their own – though the MDAST documentation
explicitly states that HTML nodes do not need to contain "valid or
complete HTML" (https://github.com/syntax-tree/mdast#html).

For the moment, we go with the "simple" path of ignoring expand nodes.

bitcrowd#25
pmeinhardt added a commit to pmeinhardt/mdast-util-from-adf that referenced this issue Oct 11, 2022
For now, ADF `expand` and `nestedExpand` nodes will be skipped, meaning
the nodes themselves do not create a counterpart in the resulting MDAST
tree. Their child nodes however will be processed and attached to the
output tree.

An alternative to skipping "expand" nodes could be to represent them as
a sequence of MDAST nodes:

1. HTML node: `<details>`
2. HTML node: `<summary>` + expand node title + `</summary>`
3. MDAST nodes for the "expand" node content (the current output)
4. HTML node: `</details>`

This produces adequate output when converting the ADF to Markdown and
HTML. However, it also comes with its own set of challenges and arguably
makes the MDAST tree representation look rather odd, with HTML nodes
containing invalid HTML content. The opening and closing `<details>`
tags are not valid on their own – though the MDAST documentation
explicitly states that HTML nodes do not need to contain "valid or
complete HTML" (https://github.com/syntax-tree/mdast#html).

For the moment, we go with the "simple" path of ignoring expand nodes.

bitcrowd#25
pmeinhardt added a commit to pmeinhardt/mdast-util-from-adf that referenced this issue Oct 11, 2022
For now, ADF `expand` and `nestedExpand` nodes will be skipped, meaning
the nodes themselves do not create a counterpart in the resulting MDAST
tree. Their child nodes however will be processed and attached to the
output tree.

An alternative to skipping "expand" nodes could be to represent them as
a sequence of MDAST nodes:

1. HTML node: `<details>`
2. HTML node: `<summary>` + expand node title + `</summary>`
3. MDAST nodes for the "expand" node content (the current output)
4. HTML node: `</details>`

This produces adequate output when converting the ADF to Markdown and
HTML. However, it also comes with its own set of challenges and arguably
makes the MDAST tree representation look rather odd, with HTML nodes
containing invalid HTML content. The opening and closing `<details>`
tags are not valid on their own – though the MDAST documentation
explicitly states that HTML nodes do not need to contain "valid or
complete HTML" (https://github.com/syntax-tree/mdast#html).

For the moment, we go with the "simple" path of ignoring expand nodes.

bitcrowd#25
klappradla pushed a commit that referenced this issue Oct 13, 2022
For now, ADF `expand` and `nestedExpand` nodes will be skipped, meaning
the nodes themselves do not create a counterpart in the resulting MDAST
tree. Their child nodes however will be processed and attached to the
output tree.

An alternative to skipping "expand" nodes could be to represent them as
a sequence of MDAST nodes:

1. HTML node: `<details>`
2. HTML node: `<summary>` + expand node title + `</summary>`
3. MDAST nodes for the "expand" node content (the current output)
4. HTML node: `</details>`

This produces adequate output when converting the ADF to Markdown and
HTML. However, it also comes with its own set of challenges and arguably
makes the MDAST tree representation look rather odd, with HTML nodes
containing invalid HTML content. The opening and closing `<details>`
tags are not valid on their own – though the MDAST documentation
explicitly states that HTML nodes do not need to contain "valid or
complete HTML" (https://github.com/syntax-tree/mdast#html).

For the moment, we go with the "simple" path of ignoring expand nodes.

#25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant