syntax-tree / mdast-util-gfm-table

mdast extension to parse and serialize GFM tables
https://unifiedjs.com
MIT License
12 stars 7 forks source link

Test for escaping of HTML chars in table #1

Closed SamyPesse closed 3 years ago

SamyPesse commented 3 years ago

Initial checklist

Description of changes

Hello 👋

I'm investigating an issue where the formatting to markdown doesn't escape HTML chars in a table cell.

I'm still new to contribute to remark/mdast/etc, this PR is only started with a failing test till I deep dive more into the issue.

For example, considering the following table:

| A | B |
| :--- | :--- |
| C | <D E> |

it's parsed as the following table cell:

{
    "type": "tableCell",
    "children": [
        {
            "type": "text",
            "value": "<D E>"
        }
    ],
    ...
}

which then using remark-stringily (and this module under it), output:

| A | B |
| :--- | :--- |
| C | <D E> |

💥 which crash at parsing because <D E> is not recognised as HTML.

wooorm commented 3 years ago

Hi Samy!

Hmm, I seem to be able to reproduce it: https://codesandbox.io/s/micromark-debug-forked-myv26?file=/src/index.js

wooorm commented 3 years ago

Think the problem is that table cells aren’t marked as phrasing, and so non of the escapes for that construct work: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/unsafe.js

github-actions[bot] commented 3 years ago

Hi! This was closed. Team: If this was merged, please describe when this is likely to be released. Otherwise, please add one of the no/* labels.

wooorm commented 3 years ago

Released https://github.com/syntax-tree/mdast-util-gfm-table/releases/tag/1.0.1!

SamyPesse commented 3 years ago

Thank you @wooorm 🙌