Unexpected output from GFM tables (mdast-util-gfm-table) #57
-
Hi, I hope this is the right place to ask about ContextWe've recently migrated from react-markdown 4 to 7, and I'm running into a issue where the existing markdown data is producing different results. We want to use the GFM tables extension, but we do NOT want the autolinking functionality in GFM as we are recording links that we don't want people visiting - think "www.badguys.com sucks" Previously we used the whole remark-gfm package, and then went used remark-disable-tokenizers to remove the autolinking. This worked because the autolinks came out as In newer versions of remark, this distinction has been dropped , so we had to stop using remark-gfm (as it is an all-or-nothing affair) and just use mdast-util-gfm-table to provide us the tables. ProblemWith new versions of remark, a heading that immediately follows a table gets added to the table. With a slight modification to the example found here, I have this: import { fromMarkdown } from 'mdast-util-from-markdown'
import { gfmTableFromMarkdown, gfmTableToMarkdown } from 'mdast-util-gfm-table'
import { toMarkdown } from 'mdast-util-to-markdown'
import { gfmTable } from 'micromark-extension-gfm-table'
const tableMarkdown = `
| AA | BB | CC |
|-----|-----|-----|
| aa | bb | cc |
# Not included in table
`
const tree = fromMarkdown(tableMarkdown, {
extensions: [gfmTable],
mdastExtensions: [gfmTableFromMarkdown],
})
console.log(toMarkdown(tree, { extensions: [gfmTableToMarkdown()] })) Which unfortunately produces this:
If you change the heading to a blockquote, we end up with what I'd expect:
I've been trying to work out whether this is just a vaguery in the GFM flavour, so I found the spec here which says:
I wanted to check headings are considered block-level items, and this site seems to agree by including both headings and blockquotes under the "Block Elements" section. Finally, confident that this is a bug, I checked with a couple of online editors, all of which separate out the heading from the table.
Not included in tableI suppose I could look into which libraries they are using, but I don't want to remove all the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
seems to be a bug! |
Beta Was this translation helpful? Give feedback.
seems to be a bug!