Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/light-bears-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/doom": patch
---

fix: render unsupported directives as text
1 change: 1 addition & 0 deletions fixture-docs/zh/directive.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
试一下:测试 试一下
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"dependencies": {
"@cspell/eslint-plugin": "^8.19.4 || ^9.1.5",
"@eslint-react/eslint-plugin": "^1.52.3",
"@inquirer/prompts": "^7.6.0",
"@inquirer/prompts": "^7.7.1",
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
"@playwright/browser-chromium": "^1.54.1",
"@rsbuild/plugin-react": "^1.3.4",
Expand All @@ -70,7 +70,7 @@
"@rspress/plugin-algolia": "2.0.0-beta.21",
"@rspress/plugin-llms": "2.0.0-beta.21",
"@rspress/shared": "2.0.0-beta.21",
"@shikijs/transformers": "^3.8.0",
"@shikijs/transformers": "^3.8.1",
"@total-typescript/ts-reset": "^0.6.1",
"chokidar": "^4.0.3",
"cli-progress": "^3.12.0",
Expand All @@ -83,9 +83,11 @@
"globals": "^16.3.0",
"html-tag-names": "^2.1.0",
"md-attr-parser": "^1.3.0",
"mdast-util-directive": "^3.1.0",
"mdast-util-mdx": "^3.0.0",
"mdast-util-mdx-jsx": "^3.2.0",
"mdast-util-phrasing": "^4.1.0",
"mdast-util-to-markdown": "^2.1.2",
"mdast-util-to-string": "^4.0.0",
"mermaid": "^11.9.0",
"openai": "^5.10.1",
Expand All @@ -112,14 +114,14 @@
"remark-message-control": "^8.0.0",
"remark-stringify": "^11.0.0",
"rspress": "2.0.0-beta.21",
"shiki": "^3.8.0",
"shiki": "^3.8.1",
"simple-git": "^3.28.0",
"string-width": "^7.2.0",
"swagger2openapi": "^7.0.8",
"tinyglobby": "^0.2.14",
"type-fest": "^4.41.0",
"typescript": "^5.8.3",
"typescript-eslint": "^8.37.0",
"typescript-eslint": "^8.38.0",
"unified": "^11.0.5",
"unified-lint-rule": "^3.0.1",
"unist-util-position": "^5.0.0",
Expand All @@ -133,12 +135,12 @@
"@changesets/cli": "^2.29.5",
"@eslint/js": "^9.31.0",
"@swc-node/register": "^1.10.10",
"@swc/core": "1.12.14",
"@swc/core": "1.13.1",
"@types/cli-progress": "^3.11.6",
"@types/ejs": "^3.1.5",
"@types/mdast": "^4.0.4",
"@types/node": "^22.16.4",
"@types/picomatch": "^4.0.0",
"@types/node": "^22.16.5",
"@types/picomatch": "^4.0.1",
"@types/pluralize": "^0.0.33",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
Expand Down
11 changes: 9 additions & 2 deletions src/plugins/directives/remark-directives.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { Root } from 'mdast'
import { directiveToMarkdown } from 'mdast-util-directive'
import { toMarkdown } from 'mdast-util-to-markdown'
import type { Plugin } from 'unified'
import { visit } from 'unist-util-visit'

export const remarkDirectives: Plugin<[], Root> = function () {
return (root) => {
visit(root, (node) => {
visit(root, (node, index, parent) => {
if (
node.type !== 'containerDirective' &&
node.type !== 'leafDirective' &&
Expand All @@ -21,7 +23,12 @@ export const remarkDirectives: Plugin<[], Root> = function () {
break
}
default: {
return
parent!.children[index!] = {
type: 'text',
value: toMarkdown(node, {
extensions: [directiveToMarkdown()],
}),
}
}
}
})
Expand Down
Loading