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

Custom Unified.js Plugins (Admonitions + Type Links) #154

Merged
merged 10 commits into from
Oct 28, 2024

Conversation

YetAnotherClown
Copy link
Collaborator

@YetAnotherClown YetAnotherClown commented Aug 19, 2024

This PR introduces one new Remark plugin and a new Remark-Rehype Handler, both of which resolve issues or outdated features resulting from the upgrade to Docusaurus v3 and the major bump of dependencies.

Remark-Rehype Handlers for Admonitions

docusaurus-plugin-moonwave now uses a custom remark plugin that uses remark-directive to turn commonmark directives in markdown into Docusaurus-style admonitions.

These new handlers adds support for:

  • Inline Directives :note[Some description]
  • Leaf Directives ::note[Some description]
  • Markdown in admonition heading
  • Nested admonitions

This is ultimately a replacement for remark-admonitions, which is outdated and not used in Docusaurus v3 anymore, Docusaurus now has a built-in admonition plugin.

By replacing it, we get access to new features brought with remark-directive, and a custom handlers to allow us to replace Docusaurus admonitions with our own by replacing markdown directives directly with our own admonition components in the future.

Extended Link References Plugin

In the updated version of Unified, they patched Link References with no definitions, e.g. [label]. While they consider this parsing to be a bug, Moonwave of course used it for type links. This plugin includes a Micromark syntax extension and an extension for mdast-util-from-markdown which re-adds support for this syntax.

Other

  • Added back support for GitHub Flavored Markdown which was removed in remark-parse version bump.

@YetAnotherClown YetAnotherClown changed the title Support Docusaurus v3 Admonitions Custom Unified.js Plugins (Admonitions + Type Links) Sep 30, 2024
This was removed in remark-parse when they moved to Micromark
- Use of Semicolons as Methods, `foo:bar()`, `:foo()`

- Docusaurus V2 Admonition titles, `:::name Some Title`
The previous use of `style` did not work in the new Admonition Remark plugin
@YetAnotherClown YetAnotherClown merged commit 93fe073 into master Oct 28, 2024
1 check passed
@YetAnotherClown YetAnotherClown deleted the admonitions branch October 28, 2024 21:00
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.

1 participant