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

💡 RFC: provide hook for custom markdown renderer #239

Closed
shedali opened this issue May 24, 2021 · 9 comments · Fixed by #562
Closed

💡 RFC: provide hook for custom markdown renderer #239

shedali opened this issue May 24, 2021 · 9 comments · Fixed by #562
Assignees

Comments

@shedali
Copy link

shedali commented May 24, 2021

since MD is built-into Astro, it would make sense to provide this hook via some Astro config (or: let you provide a custom Astro plugin that takes over responsibility for rendering MD to HTML)

via discord

@matthewp
Copy link
Contributor

matthewp commented Jun 1, 2021

Currently we use remark to do Markdown rendering. Is the goal here to provide hooks so that a user can add support for additional markdown features (which could probably be done by adding remark plugins), or is the goal to completely take over and do ones own Markdown compilation?

@natemoo-re
Copy link
Member

IMO the point of migrating to remark was to leverage the extensive plugin ecosystem that supports remark. The way that we render markdown (interwoven in small snippets between elements) might be jarring to expose directly to users. But if anyone feels like handing rendering entirely over to users is a better solution, I'm interested to hear why!

@mgrn0
Copy link

mgrn0 commented Jun 9, 2021

If I understand correctly one use case would be to extend markdown files with custom extensions for e.g. integrating html snippets (for design systems) or to wrap some parts of default markdown with additional markup while rendered, adding footnotes and summaries of links, comments which should not be rendered in html but shall stay in markdown etc..?

@matthewp
Copy link
Contributor

Yep!

@akellbl4
Copy link

I didn't found this issue and tried to implement one of Remark plugins right in Astro.

I think it's a great idea to provide the hook for custom remark plugins. I would like to work on it because I'm in the process of migrating my site to Astro and I need remark-code-titles . I think it's the only thing that stops me from full migration.

@natemoo-re
Copy link
Member

@akellbl4 awesome, definitely let us know if you have any questions! The way renderers are implemented is probably similar to the way we'll handle this.

@akellbl4 akellbl4 mentioned this issue Jun 27, 2021
2 tasks
@akellbl4
Copy link

akellbl4 commented Jun 27, 2021

I've played with source code and written rough implementation.
I have two concerns for now:

  • headers collector could conflict with remark-slug I've added backward compatibility.
  • Should preinstalled plugins be removed?
  • I haven't found any docs on mode: 'md' | 'astro-md' and dropped it for fast implementation.

I would be happy to have any comments on my PR.

@wooorm
Copy link

wooorm commented Jun 27, 2021

Btw: I’d strongly suggest to also allow rehype plugins.
Markdown is used a lot to get to HTML. Historically, there was only remark, so a bunch of things were implemented in that space. But there are also many use cases that don’t really care about the input being markdown, or actually don’t have input markdown (e.g., html -> html), which also makes sense for Astro. So integrating with both would be my recommendation!

@natemoo-re
Copy link
Member

Thanks for chiming in @wooorm! #562 is in progress and adds support for both!

@FredKSchott FredKSchott changed the title provide hook for custom markdown renderer 💡 RFC: provide hook for custom markdown renderer Jun 30, 2021
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 a pull request may close this issue.

7 participants