-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add remark-merge-data
to list of plugins
#1410
Conversation
Signed-off-by: Andreas Opferkuch <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1410 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 142 138 -4
=========================================
- Hits 142 138 -4 ☔ View full report in Codecov by Sentry. |
Thanks for sharing @s-h-a-d-o-w! |
Thanks for the feedback! I agree that the README wasn't sufficiently clear. I wrote that while being very focused on my use case, so I didn't notice that it's lacking context. What do you think? https://github.com/s-h-a-d-o-w/remark-merge-data/blob/36cb97274229e69073037eb1744f2ab42c7c33d7/README.md |
The additional docs help! |
Nope, that was a PR. I waited for your approval before merging and releasing it. Which I have done just now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
A few thoughts
- This check may not be needed https://github.com/s-h-a-d-o-w/remark-merge-data/blob/e996968112056045034a5b9a1bb14157aa80fb20/src/index.ts#L43-L48,
isYaml
could be used to create a discriminated union https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#discriminating-unions, which would allow this to be split https://github.com/s-h-a-d-o-w/remark-merge-data/blob/e996968112056045034a5b9a1bb14157aa80fb20/src/index.ts#L7-L30 and TypeScript to give an error if the incorrect data type is passed in - Would data truly be unknown? or could it be constrained to be JSON? https://github.com/sindresorhus/type-fest?tab=readme-ov-file#json
- https://github.com/s-h-a-d-o-w/remark-merge-data/blob/e996968112056045034a5b9a1bb14157aa80fb20/src/index.ts#L63-L66 This will only support hard-coded meta attributes, if you also want to support dynamic, you may want to look to see if https://github.com/remcohaszing/rehype-mdx-code-props#readme could be supported as well
This comment has been minimized.
This comment has been minimized.
That's a great shout, thanks! (I released a new version with that just before.)
I did this but then I realized—people might get creative with what they use. For example, they could use a proxy to track usage. As long as the engine can read from it like it's an object, it's fine by me. On the flip side, I'm not sure that the stricter type would yield much benefit here. (But I wasn't aware is this being in type-fest, maybe it'll come in handy in the future. Thanks!)
Since this plugin can be used with other remark plugins, rehype would be too late? Also, I can't envision how this could be useful for selecting which blocks to merge. Finally, unless I misunderstand something, it's only dynamic at runtime, so I could only match the prop declarations—which seems to me essentially the same as matching strings. |
I understand, and I see it a different way.
It would be if it is purely used as a remark plugin.
That's fair, if you don't have a use case for it, don't add it. |
How so? |
The main example you link to as motivating this is about generating rehype/HTML output https://aop.software/blog/2025-02-17_graphs-in-blogs/ |
But the HTML output is generated by other plugins. This plugin only serves to share global data that is eventually used by those plugins. |
Initial checklist
Description of changes
Adds
remark-merge-data
to list of plugins.One use case for this is to share configuration across chart definitions when creating charts using code, like in my article here (which uses
remark-kroki
): https://aop.software/blog/2025-01-31_evaluating-llrt/ (code that makes use ofremark-merge-data
)