@@ -26,9 +26,24 @@ export const getRemark = () =>
2626
2727/**
2828 * Retrieves an instance of Remark configured to output stringified HTML code
29- * including parsing Code Boxes with syntax highlighting
3029 */
3130export const getRemarkRehype = ( ) =>
31+ unified ( )
32+ . use ( remarkParse )
33+ // We make Rehype ignore existing HTML nodes (just the node itself, not its children)
34+ // as these are nodes we manually created during the rehype process
35+ // We also allow dangerous HTML to be passed through, since we have HTML within our Markdown
36+ // and we trust the sources of the Markdown files
37+ . use ( remarkRehype , { allowDangerousHtml : true , passThrough } )
38+ // We allow dangerous HTML to be passed through, since we have HTML within our Markdown
39+ // and we trust the sources of the Markdown files
40+ . use ( rehypeStringify , { allowDangerousHtml : true } ) ;
41+
42+ /**
43+ * Retrieves an instance of Remark configured to output stringified HTML code
44+ * including parsing Code Boxes with syntax highlighting
45+ */
46+ export const getRemarkRehypeWithShiki = ( ) =>
3247 unified ( )
3348 . use ( remarkParse )
3449 // We make Rehype ignore existing HTML nodes (just the node itself, not its children)
@@ -38,8 +53,6 @@ export const getRemarkRehype = () =>
3853 . use ( remarkRehype , { allowDangerousHtml : true , passThrough } )
3954 // This is a custom ad-hoc within the Shiki Rehype plugin, used to highlight code
4055 // and transform them into HAST nodes
41- // @TODO : Get rid of @shikijis/rehype and use our own Rehype plugin for Shiki
42- // since we have CJS/ESM nodes. (Base off from the nodejs/nodejs.org repository)
4356 . use ( syntaxHighlighter )
4457 // We allow dangerous HTML to be passed through, since we have HTML within our Markdown
4558 // and we trust the sources of the Markdown files
@@ -58,10 +71,7 @@ export const getRemarkRecma = () =>
5871 // as these are nodes we manually created during the generation process
5972 // We also allow dangerous HTML to be passed through, since we have HTML within our Markdown
6073 // and we trust the sources of the Markdown files
61- . use ( remarkRehype , {
62- allowDangerousHtml : true ,
63- passThrough,
64- } )
74+ . use ( remarkRehype , { allowDangerousHtml : true , passThrough } )
6575 // Any `raw` HTML in the markdown must be converted to AST in order for Recma to understand it
6676 . use ( rehypeRaw , { passThrough } )
6777 . use ( ( ) => singletonShiki )
0 commit comments