Skip to content

Add configuration passthrough for remark-rehype#518

Closed
marcus-crane wants to merge 2 commits into
lumeland:mainfrom
marcus-crane:remark-rehype
Closed

Add configuration passthrough for remark-rehype#518
marcus-crane wants to merge 2 commits into
lumeland:mainfrom
marcus-crane:remark-rehype

Conversation

@marcus-crane
Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread plugins/remark.ts
rehypePlugins?: unknown[];

/** Configuration for remark-rehype */
remarkRehype?: object;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@marcus-crane
Copy link
Copy Markdown
Author

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

@marcus-crane
Copy link
Copy Markdown
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.

2 participants