Fix:修复公式中存在<>符号时导出svg报错的问题
This commit is contained in:
parent
ce49fcb511
commit
7ba11be42b
@ -1,6 +1,6 @@
|
|||||||
import katex from 'katex'
|
import katex from 'katex'
|
||||||
import Quill from 'quill'
|
import Quill from 'quill'
|
||||||
import { getChromeVersion } from '../utils/index'
|
import { getChromeVersion, htmlEscape } from '../utils/index'
|
||||||
import { getBaseStyleText, getFontStyleText } from './FormulaStyle'
|
import { getBaseStyleText, getFontStyleText } from './FormulaStyle'
|
||||||
|
|
||||||
// 数学公式支持插件
|
// 数学公式支持插件
|
||||||
@ -58,7 +58,7 @@ class Formula {
|
|||||||
let node = super.create(value)
|
let node = super.create(value)
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
katex.render(value, node, self.config)
|
katex.render(value, node, self.config)
|
||||||
node.setAttribute('data-value', value)
|
node.setAttribute('data-value', htmlEscape(value))
|
||||||
}
|
}
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
@ -110,11 +110,7 @@ class Formula {
|
|||||||
for (const el of els)
|
for (const el of els)
|
||||||
nodeText = nodeText.replace(
|
nodeText = nodeText.replace(
|
||||||
el.outerHTML,
|
el.outerHTML,
|
||||||
`\$${el
|
`\$${htmlEscape(el.getAttribute('data-value'))}\$`
|
||||||
.getAttribute('data-value')
|
|
||||||
.replaceAll('&', '&')
|
|
||||||
.replaceAll('<', '<')
|
|
||||||
.replaceAll('>', '>')}\$`
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return nodeText
|
return nodeText
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user