Way to properly override data.toMarkdownExtensions? #265
-
Hey, not sure if this repo is the right place to post. Feel free to redirect me as you see fit. I am trying to override remark gfm's autolink feature. Looked into its source code and found that I basically need to fill the following with my own: micromarkExtensions.push(gfm(settings))
fromMarkdownExtensions.push(gfmFromMarkdown())
toMarkdownExtensions.push(gfmToMarkdown(settings)) My unified instance looks like the following unified()
.data('fromMarkdownExtensions', [
gfmFootnoteFromMarkdown(),
gfmStrikethroughFromMarkdown(),
gfmTableFromMarkdown(),
gfmTaskListItemFromMarkdown(),
])
.data('micromarkExtensions', [gfm({})])
// @ts-ignore
.data('toMarkdownExtensions', [gfmToMarkdown({})])
.use(remarkParse) Everything seems to work perfectly. However, it requires the ugly Am I missing something or is this just a bug in typing? |
Beta Was this translation helpful? Give feedback.
Answered by
ChristianMurphy
Aug 21, 2025
Replies: 1 comment 4 replies
-
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
mturoci
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welcome @mturoci 👋
Order matters in typescript, you are referencing data properties before remark has been added to the unified typings, that may be part of it.
Remark does register those data props
https://github.com/remarkjs/remark/blob/ed7b185d304adaf5aa80fc78a912603a5cd6e85a/packages/remark-parse/index.d.ts#L44
https://github.com/remarkjs/remark/blob/ed7b185d304adaf5aa80fc78a912603a5cd6e85a/packages/remark-stringify/index.d.ts#L43
You could create a plugin as gfm itself does https://github.com/remarkjs/remark-gfm/blob/main/lib/index.js
Note how the plugin def…