Skip to content

Commit 18d3605

Browse files
committed
fix: 🐛 svg attr support
1 parent 203be2f commit 18d3605

File tree

5 files changed

+165
-2
lines changed

5 files changed

+165
-2
lines changed

.changeset/clear-facts-stand.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vue-markdown-next': patch
3+
---
4+
5+
fix: inline svg attr support

packages/docs/example/components.vue

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<Markdown
33
:content="testContent"
44
:components="components"
5-
:rehype-plugins="[[rehypeMermaid, { strategy: 'img-png' }]]"
5+
:remark-plugins="[remarkMath]"
6+
:rehype-plugins="[[rehypeMermaid, { strategy: 'inline-svg' }], rehypeKatex]"
67
>
78
<template #hr>
89
<t-divider align="left">Using TDesign Divider</t-divider>
@@ -20,6 +21,11 @@
2021
import { Markdown, VNodeRenderer } from 'vue-markdown-next';
2122
import { Divider as TDivider } from 'tdesign-vue-next';
2223
import rehypeMermaid from 'rehype-mermaid';
24+
import remarkMath from 'remark-math';
25+
// choose your favorite solution
26+
// import rehypeMathjax from 'rehype-mathjax';
27+
import rehypeKatex from 'rehype-katex';
28+
import 'katex/dist/katex.min.css';
2329
import { components } from './components';
2430
2531
const testContent = `
@@ -38,6 +44,30 @@ graph TD;
3844
C-->D;
3945
\`\`\`
4046
47+
以下是一段Markdown格式的LaTeX数学公式:
48+
49+
我是一个行内公式:$E=mc^2$
50+
51+
我是一个独立公式:
52+
$$
53+
\\sum_{i=1}^{n} x_i = x_1 + x_2 + \\ldots + x_n
54+
$$
55+
56+
我是一个带有分式的公式:
57+
$$
58+
\\frac{{n!}}{{k!(n-k)!}} = \\binom{n}{k}
59+
$$
60+
61+
我是一个带有上下标的公式:
62+
$$
63+
x^{2} + y^{2} = r^{2}
64+
$$
65+
66+
我是一个带有积分符号的公式:
67+
$$
68+
\\int_{a}^{b} f(x) \\, dx
69+
$$
70+
4171
4272
- Red
4373
- Green

packages/docs/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
"devDependencies": {
1414
"@types/lodash-es": "^4.17.12",
1515
"@vitejs/plugin-vue-jsx": "^4.1.1",
16+
"katex": "^0.16.21",
1617
"lodash-es": "^4.17.21",
1718
"postcss": "^8.4.49",
19+
"rehype-katex": "^7.0.1",
20+
"rehype-mathjax": "^7.1.0",
1821
"rehype-mermaid": "^3.0.0",
1922
"remark-gfm": "^4.0.0",
23+
"remark-math": "^6.0.0",
2024
"tdesign-vue-next": "^1.10.6",
2125
"unplugin-auto-import": "^0.19.0",
2226
"unplugin-vue-components": "^0.28.0",

packages/markdown/src/markdown.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export default defineComponent({
234234
...props.components,
235235
...componentsWithSlot.value,
236236
},
237+
elementAttributeNameCase: 'html',
237238
ignoreInvalidStyle: true,
238239
jsx: jsxWithChildren,
239240
jsxs: jsxWithChildren,

pnpm-lock.yaml

Lines changed: 124 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)