@@ -29,6 +29,22 @@ export const getRemark = () =>
2929 * including parsing Code Boxes with syntax highlighting
3030 */
3131export const getRemarkRehype = ( ) =>
32+ unified ( )
33+ . use ( remarkParse )
34+ // We make Rehype ignore existing HTML nodes (just the node itself, not its children)
35+ // as these are nodes we manually created during the rehype process
36+ // We also allow dangerous HTML to be passed through, since we have HTML within our Markdown
37+ // and we trust the sources of the Markdown files
38+ . use ( remarkRehype , { allowDangerousHtml : true , passThrough } )
39+ // We allow dangerous HTML to be passed through, since we have HTML within our Markdown
40+ // and we trust the sources of the Markdown files
41+ . use ( rehypeStringify , { allowDangerousHtml : true } ) ;
42+
43+ /**
44+ * Retrieves an instance of Remark configured to output stringified HTML code
45+ * including parsing Code Boxes with syntax highlighting
46+ */
47+ export const getRemarkRehypeWithShiki = ( ) =>
3248 unified ( )
3349 . use ( remarkParse )
3450 // We make Rehype ignore existing HTML nodes (just the node itself, not its children)
@@ -38,8 +54,6 @@ export const getRemarkRehype = () =>
3854 . use ( remarkRehype , { allowDangerousHtml : true , passThrough } )
3955 // This is a custom ad-hoc within the Shiki Rehype plugin, used to highlight code
4056 // 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)
4357 . use ( syntaxHighlighter )
4458 // We allow dangerous HTML to be passed through, since we have HTML within our Markdown
4559 // and we trust the sources of the Markdown files
@@ -58,10 +72,7 @@ export const getRemarkRecma = () =>
5872 // as these are nodes we manually created during the generation process
5973 // We also allow dangerous HTML to be passed through, since we have HTML within our Markdown
6074 // and we trust the sources of the Markdown files
61- . use ( remarkRehype , {
62- allowDangerousHtml : true ,
63- passThrough,
64- } )
75+ . use ( remarkRehype , { allowDangerousHtml : true , passThrough } )
6576 // Any `raw` HTML in the markdown must be converted to AST in order for Recma to understand it
6677 . use ( rehypeRaw , { passThrough } )
6778 . use ( ( ) => singletonShiki )
0 commit comments