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 configuration passthrough for remark-rehype #518

Closed
wants to merge 2 commits into from

Conversation

marcus-crane
Copy link

Description

This change adds the ability to pass configuration from _config.ts down to remark-rehype.

It can be useful for users who need to customise how footnotes are rendered for Markdown files (such as when using Littlefoot as well as a few other things should they be needed.

Related Issues

Implements #517

Check List

  • Have you read the
    CODE OF CONDUCT
  • Have you read the document
    CONTRIBUTING
    • One pull request per feature. If you want to do more than one thing,
      send multiple pull request.
    • Write tests.
    • Run deno fmt to fix the code format before commit.
    • Document any change in the CHANGELOG.md.

Signed-off-by: Marcus Crane <marcus@utf9k.net>
Signed-off-by: Marcus Crane <marcus@utf9k.net>
@marcus-crane
Copy link
Author

marcus-crane commented Nov 29, 2023

While there are no tests included, I'll note that I've run through a bunch of manual tests with my own site against the latest master branch.

Overwriting the defaults work as expected (Dangerous HTML renders by default but can be stubbed out if the user chooses) as well as extra options like footnote overrides working.

Probably some tests could be written but I figure if there are none for Remark already, why start now 😉

On a side note, I think there is probably value in exporting remark types through to _config.ts as currently Options just takes untyped arrays and objects so it's not clear from your site config what options are possible. That's a story for another time though.

@@ -27,6 +27,9 @@ export interface Options {
/** List of rehype plugins to use */
rehypePlugins?: unknown[];

/** Configuration for remark-rehype */
remarkRehype?: object;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change this option to remarkOptions object for consistency with rehypePlugins and to make clear that it contains the options for rehype, not the remarkRehype option itself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I wasn't quite clear on whether remark-rehype was still technically a remark plugin or if it was a standalone thing of sorts but yeah, that makes more sense

@oscarotero
Copy link
Member

Hi @marcus-crane
Thanks for this. Just a couple of comments:

@marcus-crane
Copy link
Author

Ah! That explains a lot re: main being v2 oops. I'll fix that up 🙂

@marcus-crane
Copy link
Author

Closing this until I open a proper PR from the v1 branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants