Closed escwxyz closed 1 year ago
Merging #1143 (c00117f) into main (1e488d0) will not change coverage. The diff coverage is
n/a
.
:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
Hi there!
This should be a rehype plugin. rehype is for HTML. remark is for markdown. You work with HTML. So you should work on the HTML AST. Some more info on this can be found here: https://github.com/remarkjs/remark-rehype#what-is-this
remark/rehype/rest of unified are also about ASTs. So, you have an object that represents a paragraph, with children, for example. You inject strings of HTML. Strings of HTML for the divs, strings of HTML for the icons. Injecting strings defeats the purpose of having ASTs. Other plugins can’t inspect them. They can’t be made safe. They don‘t work with MDX for example, or many other tools. There are many examples of rehype plugins that you can use as inspiration: https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins. One that looks somewhat like what you want to do is: https://github.com/rehypejs/rehype-picture/blob/main/index.js
You also use TypeScript, but don’t use the types for the AST.
You can use specific types from @types/mdast
/ @types/hast
, they subclass the abstract interfaces from @types/unist
into interfaces that are actually used.
If you then type your plugin, instead of accepting any
, you will find a much better user experience, because everything will be typed.
An example of how to type plugins is: https://github.com/remcohaszing/rehype-mdx-title/blob/6832b8c01097da83288319ddaa5d1e460d4e125a/index.ts#L23.
Other plugins can’t inspect them. They can’t be made safe. They don‘t work with MDX for example, or many other tools.
You're right, thanks for the detailed explanation and guidance! This was initially for the personal use with Astro, but as you have said, I would consider rewriting for rehype. Thanks!
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.
Cool! :)
Let me know if you have any further questions, good luck!
Initial checklist
Description of changes
This PR adds the plugin
remark-obsidian-callout
to the list of plugins, also seen on npm.