mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-30 11:16:12 +08:00
refactor(docs): tooltip plugin (#10440)
* refactor(docs): tooltip plugin * refactor(docs): tooltip plugin
This commit is contained in:
parent
fe66c08fa5
commit
36c5aed076
@ -8,7 +8,7 @@ export default (md: MarkdownIt): void => {
|
||||
}
|
||||
|
||||
md.inline.ruler.before('emphasis', 'tooltip', (state, silent) => {
|
||||
const tooltipRegExp = /^\^\[([^\]]*)\](\[[^\]]*\])?/
|
||||
const tooltipRegExp = /^\^\[([^\]]*)\](`[^`]*`)?/
|
||||
const str = state.src.slice(state.pos, state.posMax)
|
||||
|
||||
if (!tooltipRegExp.test(str)) return false
|
||||
@ -19,10 +19,8 @@ export default (md: MarkdownIt): void => {
|
||||
if (!result) return false
|
||||
|
||||
const token = state.push('tooltip', 'tooltip', 0)
|
||||
token.content = result[1]
|
||||
token.info = (result[2] || '')
|
||||
.replace(/^\[([^\]]*)\]$/, '$1')
|
||||
.replace(/^`([^`]*)`$/, '$1')
|
||||
token.content = result[1].replace(/\\\|/g, '|')
|
||||
token.info = (result[2] || '').replace(/^`(.*)`$/, '$1')
|
||||
token.level = state.level
|
||||
state.pos += result[0].length
|
||||
|
||||
|
@ -126,14 +126,10 @@ const findModule = (type: string): string | undefined => {
|
||||
}
|
||||
|
||||
const rewriteType = (str: string): string => {
|
||||
if (/\^\[/.test(str)) {
|
||||
if (/\^\[([^\]]*)\](`[^`]*`)?/.test(str)) {
|
||||
return str
|
||||
.replaceAll(/\^\[([^\]]*)\](\[[^\]]*\])?/g, (_, type, details) => {
|
||||
return (
|
||||
(details || '')
|
||||
.replace(/^\[([^\]]*)\]$/, '$1')
|
||||
.replace(/^`([^`]*)`$/, '$1') || type
|
||||
)
|
||||
.replaceAll(/\^\[([^\]]*)\](`[^`]*`)?/g, (_, type, details) => {
|
||||
return details ? details.replace(/^`(.*)`$/, '$1') : type
|
||||
})
|
||||
.replaceAll(/\[[^\]]*\]\([^)]*\)/g, '')
|
||||
} else if (/<.*>/.test(str)) {
|
||||
|
Loading…
Reference in New Issue
Block a user