Skip to content
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-hexo to list of plugins #1248

Merged
merged 2 commits into from
Oct 25, 2023
Merged

Add remark-hexo to list of plugins #1248

merged 2 commits into from
Oct 25, 2023

Conversation

bennycode
Copy link
Contributor

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

I added a link to the remark-hexo plugin which I built.

Signed-off-by: Benny Neugebauer <[email protected]>
@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Oct 24, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5017a27) 100.00% compared to head (ef006d7) 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1248   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          142       142           
=========================================
  Hits           142       142           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

doc/plugins.md Outdated Show resolved Hide resolved
Signed-off-by: Benny Neugebauer <[email protected]>
@ChristianMurphy
Copy link
Member

Thanks @bennycode!
A few thoughts:

  1. running this as a transformer, creates a caveat that it may not work with other plugins which look for the { symbol (like MDX). If that is needed, you may need to parse at the micromark level: see https://github.com/micromark/micromark#extending-markdown and https://github.com/micromark/micromark#creating-a-micromark-extension
  2. If it continues as a transformer, consider leveraging https://github.com/syntax-tree/mdast-util-find-and-replace
  3. Is it intentional that the code does not have a license? Without a license it is not open source and others cannot use it. Consider a permissive license like MIT or Apache 2 for more adoption, or GPL or SSPL for stronger copyleft.
  4. In your tsconfig, consider setting module resolution to node16 to ensure compatibility with TypeScript with ESM

@bennycode
Copy link
Contributor Author

@ChristianMurphy, thanks for your thorough review and suggestions. I just added a license good call. The TSConfig that I am using is also set to node16 (for both, module & module resolution).

For your remarks regarding micromark and mdast-util-find-and-replace I need more context. What is so wrong about my technique? I was taking my inspiration from: https://github.com/remcohaszing/remark-mermaidjs/blob/main/index.ts & https://github.com/ntwcklng/gatsby-remark-embed-youtube/blob/master/src/index.js

@ChristianMurphy
Copy link
Member

ChristianMurphy commented Oct 24, 2023

What is so wrong about my technique?

It's not necessarily "wrong".
There may be some edge cases you are not considering:

  1. what happens when remark-hexo is used with other parser plugins like remark-mdx? remark-mdx is a parser plugin, it runs at the very beginning, when it sees { it inteprets it as a JSX block, it does not know about remark-hexo and will fail the document because {% is invalid JSX. With a micromark extension, you could potentially have both remark-mdx and remark-hexo run at the same time and work together. Alternatively, you can document "this may not work with remark-mdx or other plugins that use {}".
  2. There could be text before or after the Hexo template, currently that text will be erased/replaced. mdast-util-find-and-replace will keep the other surrounding text. (you could also do this with unist-util-visit but it is more involved)

@bennycode
Copy link
Contributor Author

Ah, thanks for the detailed info. I am using the remark-hexo plugin myself in an Astro blog (which uses Remark & Rehype) and is it was working fine I was assuming there is nothing wrong with it. Need to double check what happens with MDX files as I was only using the { syntax in MD files.

@ChristianMurphy
Copy link
Member

Again, you don't have to make them work together.
MDX and Hexo feel more like alternatives than something to use together.
But it could be something to document as an intended incompatibility to avoid people logging issues, since MDX is something commonly used with Astro.

@wooorm wooorm merged commit 618a9ad into remarkjs:main Oct 25, 2023
2 checks passed
@wooorm wooorm added 📚 area/docs This affects documentation 💪 phase/solved Post is done labels Oct 25, 2023
@wooorm
Copy link
Member

wooorm commented Oct 25, 2023

Thanks!

@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 area/docs This affects documentation 💪 phase/solved Post is done
Development

Successfully merging this pull request may close these issues.

5 participants