You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow custom options to be passed to default Markdown processors #202
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.
Thanks a lot for opening this issue. This case will be addressed by the upcoming 0.2.5 release which will support the following pattern:
importrehypeStringifyfrom'rehype-stringify'importremarkFrontmatterfrom'remark-frontmatter'importremarkParsefrom'remark-parse'importremark2rehypefrom'remark-rehype'makeSource({// your other options ...markdown: (builder)=>{builder.use(remarkFrontmatter).use(remarkParse).use(remark2rehype,{allowDangerousHtml: true}).use(rehypeStringify)}})
Activity
schickling commentedon May 10, 2022
Thanks a lot for opening this issue. This case will be addressed by the upcoming
0.2.5release which will support the following pattern:schickling commentedon May 11, 2022
This should be addressed with the
0.2.5release. 🎉