Symbitic / remark-plugins

Remark plugins for Markbook
MIT License
14 stars 7 forks source link

remark-deflist: remark-attr not working on links in definition term #12

Open brandonweiss opened 3 years ago

brandonweiss commented 3 years ago

I’m using MDX and I added remark-deflist as a plugin so I could so something like this:

term

: description and here is a <ExternalLink href="http://somewhere.com">link</ExternalLink>

I assumed that would work but it seems to throw an error. I don’t totally understand why, but MDX is new-ish and has some quirks so when I hit one I usually work around it.

Next I tried remark-attr and did something like this.

term

: description and here is a [link](https://somewhere.com){ target="_blank" rel="noopener noreferrer" }.

This didn’t work either which seemed a bit more surprising. I thought maybe it was a plugin ordering thing, like remark-deflist had to be before remark-attr but that didn't seem to make a difference.

I’m a bit new to remark so I’m not sure whether this should work or not, but it seems like it should?

simpixelated commented 3 years ago

I think the issue might be here: https://github.com/Symbitic/remark-plugins/blob/master/packages/remark-deflist/src/index.js#L44 where it's using mdast-util-from-markdown, which by default only parses Markdown. However it accepts an options array of extensions, so I think for our use case, would need to include mdast-util-mdx-jsx.