Skip to content

Commit f89aa8f

Browse files
authored
fix(plugin-markdown-hint): cleanup the env passed into renderInline (#397)
1 parent 3990e39 commit f89aa8f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { MarkdownEnv } from 'vuepress/markdown'
2+
3+
export type ClearMarkdownEnv = MarkdownEnv & {
4+
references?: unknown
5+
}
6+
7+
export const cleanMarkdownEnv = (env: ClearMarkdownEnv): ClearMarkdownEnv => ({
8+
filePath: env.filePath,
9+
filePathRelative: env.filePathRelative,
10+
base: env.base,
11+
references: env.references,
12+
})

plugins/markdown/plugin-markdown-hint/src/node/hint.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ensureLeadingSlash } from '@vuepress/helper'
55
import type { PluginWithOptions } from 'markdown-it'
66
import type { MarkdownEnv } from 'vuepress/markdown'
77
import { resolveLocalePath } from 'vuepress/shared'
8+
import { cleanMarkdownEnv } from './cleanMarkdownEnv.js'
89

910
import type { MarkdownHintPluginLocaleData } from './options.js'
1011

@@ -44,7 +45,8 @@ export const hint: PluginWithOptions<MarkdownItHintOptions> = (
4445
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
4546
info = options[localePath]?.[name]
4647
} else {
47-
info = md.renderInline(info, { ...env })
48+
console.log('\nenv: ', env)
49+
info = md.renderInline(info, cleanMarkdownEnv(env))
4850
}
4951

5052
return `<div class="hint-container ${name}">\n<p class="hint-container-title">${info || name}</p>\n`
@@ -71,7 +73,7 @@ export const hint: PluginWithOptions<MarkdownItHintOptions> = (
7173
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
7274
info = options[localePath]?.caution
7375
} else {
74-
info = md.renderInline(info, { ...env })
76+
info = md.renderInline(info, cleanMarkdownEnv(env))
7577
}
7678

7779
return `<div class="hint-container caution">\n<p class="hint-container-title">${
@@ -104,7 +106,7 @@ export const hint: PluginWithOptions<MarkdownItHintOptions> = (
104106
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
105107
info = options[localePath]?.details
106108
} else {
107-
info = md.renderInline(info, { ...env })
109+
info = md.renderInline(info, cleanMarkdownEnv(env))
108110
}
109111

110112
return `<details class="hint-container details"><summary>${

0 commit comments

Comments
 (0)