fix: markdown nav title

This commit is contained in:
王观伟
2023-06-05 10:44:23 +08:00
parent 661fdd7f91
commit 6edc15611e

View File

@@ -86,10 +86,10 @@ const MarkdownNavbar: FC<MarkdownNavbarProps> = (props) => {
const getNavStructure: (source: string) => Nav[] = (source) => {
const contentWithoutCode = source
.replace(/```[^`\n]*\n+[^```]+```\n+/g, "")
.replace(/^[^#]+\n/g, "")
.replace(/(?:[^\n#]+)#+\s([^#\n]+)\n*/g, "") // 匹配行内出现 # 号的情况
.replace(/^#\s[^#\n]*\n+/, "")
.replace(/```[^`\n]*\n+[^```]+```\n+/g, "")
.replace(/`([^`\n]+)`/g, "$1")
.replace(/\*\*?([^*\n]+)\*\*?/g, "$1")
.replace(/__?([^_\n]+)__?/g, "$1")