Skip to content

Feature request: expose an option to define custom render function for block/inline components #23

@folliehiyuki

Description

@folliehiyuki

Proposal

Add a render option to MarkdownItMdcOptions interface, allowing users to define a custom function to render block/inline components. The default render (turning them into custom HTML elements) can be exported as the fallback value.

Since we're working with JSX components, it'd nice to support both async and sync render functions. This will require some workarounds with markdown-it parsing step (https://github.com/markdown-it/markdown-it/blob/master/docs/development.md#faq).

For the function signature, something like render(content: string, md: MarkdownIt, state: , inline: boolean) might suffix. md can be used to render the slot content inside the component, while state is useful when the document's front-matter data is needed.

Context

The model is a similar idea to https://mdit-plugins.github.io/tex.html.

I'm requesting this feature for the use of markdown-it within Lume. The static site generator has its own component system (can be accessed from each page's data) and supports markdown-it to render documents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions