diff --git a/github-action/dist/index.js b/github-action/dist/index.js index cc79399..3514620 100644 --- a/github-action/dist/index.js +++ b/github-action/dist/index.js @@ -164629,9 +164629,10 @@ const removeRustdocTools = (dom) => { }; const transformCodeBlocks = (dom) => { - Array.from(dom.window.document.querySelectorAll("pre")).forEach((element) => - element.parentNode.removeChild(element) - ); + Array.from(dom.window.document.querySelectorAll("pre")).forEach((element) => { + element.prepend(dom.window.document.createTextNode("```rs\r")); + element.append(dom.window.document.createTextNode("\r```")); + }); }; const transform = async (contents, crate) => { @@ -164649,7 +164650,7 @@ const transform = async (contents, crate) => { const res = transformedContents[key].map((item) => { const dom = new JSDOM(item.content); removeRustdocTools(dom); - // transformCodeBlocks(dom); + transformCodeBlocks(dom); transformLinks(dom, crate); const serialized = serializeDOM(dom); @@ -164658,7 +164659,14 @@ const transform = async (contents, crate) => { const mdast = toMdast(hast); - const doc = unified().use(stringify).stringify(mdast); + let doc = unified().use(stringify).stringify(mdast); + + doc + .match(/ *```rs[\s\S]*```/g) + .map((codeblock) => [codeblock, codeblock.replace(/^ {4}/gm, "")]) + .forEach(([original, replacement]) => { + doc = doc.replace(original, replacement); + }); return { path: item.path,