Skip to content

Commit a822450

Browse files
committed
even more clean up
1 parent f832981 commit a822450

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
"sharp": "^0.33.4",
106106
"tailwindcss-scoped-preflight": "^3.0.4",
107107
"textarea-markdown-editor": "^1.0.4",
108-
"unified": "^11.0.5"
108+
"unified": "^11.0.5",
109+
"unist-util-remove": "^4.0.0"
109110
},
110111
"devDependencies": {
111112
"@babel/preset-typescript": "^7.15.0",

scripts/generate-md-exports.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import rehypeRemark from 'rehype-remark';
99
import remarkGfm from 'remark-gfm';
1010
import remarkStringify from 'remark-stringify';
1111
import {unified} from 'unified';
12+
import {remove} from 'unist-util-remove';
1213

1314
let root = process.cwd();
1415
while (!existsSync(path.join(root, 'package.json'))) {
@@ -37,7 +38,15 @@ export const genMDFromHTML = async (source, target) => {
3738
properties: {},
3839
children: tree,
3940
}))
40-
.use(rehypeRemark, {document: false})
41+
.use(rehypeRemark, {
42+
document: false,
43+
handlers: {
44+
// Remove buttons as they usually get confusing in markdown, especially since we use them as tab headers
45+
button() {},
46+
},
47+
})
48+
// We end up with empty inline code blocks, probably from some tab logic in the HTML, remove them
49+
.use(() => tree => remove(tree, {type: 'inlineCode', value: ''}))
4150
.use(remarkGfm)
4251
.use(remarkStringify)
4352
.process(text)

yarn.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12402,6 +12402,15 @@ unist-util-remove-position@^4.0.0:
1240212402
"@types/unist" "^2.0.0"
1240312403
unist-util-visit "^4.0.0"
1240412404

12405+
unist-util-remove@^4.0.0:
12406+
version "4.0.0"
12407+
resolved "https://registry.yarnpkg.com/unist-util-remove/-/unist-util-remove-4.0.0.tgz#94b7d6bbd24e42d2f841e947ed087be5c82b222e"
12408+
integrity sha512-b4gokeGId57UVRX/eVKej5gXqGlc9+trkORhFJpu9raqZkZhU0zm8Doi05+HaiBsMEIJowL+2WtQ5ItjsngPXg==
12409+
dependencies:
12410+
"@types/unist" "^3.0.0"
12411+
unist-util-is "^6.0.0"
12412+
unist-util-visit-parents "^6.0.0"
12413+
1240512414
unist-util-stringify-position@^3.0.0:
1240612415
version "3.0.3"
1240712416
resolved "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.3.tgz"

0 commit comments

Comments
 (0)