Skip to content

Allow custom options to be passed to default Markdown processors #202

Closed
@causztic

Description

@causztic

From here: contentlayerdev/website#43

Context

Some platforms like Github allows raw HTML tags to be used in Markdown. This can be useful if creators want to include raw HTML from trusted sources, or want to introduce extra layout and semantic flexibilities that would be hard to implement with only Markdown tags / require extra post-processing.

Current Situation

ContentLayer's Markdown processing middleware currently does not provide this possibility.

For this to work in ContentLayer, remark-rehype requires an additional option of { allowDangerousHtml: true } , which allows the processor to pass the nodes as-is, so that it can be parsed again either by rehype-raw or rehype-stringify.

Proposal

To allow for this to happen, we can allow options specified in contentlayer.config.js (maybe something like
remarkRehypeOptions for remark-rehype, as an example) to be passed into the respective default processors. Since this is optional, users will have to be aware of its security implications (if any) and enable them consciously.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions