Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档 标题内容带有下划线(_)时,在preview模式下,生成目录时把标题内容中的下划线(_)删除了 #1543

Open
sunshineshenjin opened this issue Jan 19, 2024 · 0 comments
Assignees

Comments

@sunshineshenjin
Copy link

sunshineshenjin commented Jan 19, 2024

描述问题

在文档使用 preview 进行渲染时,生成的目录会把标题中带有的下划线给去掉。

例如:文档正文中有一个二级标题:教_程, 渲染成目录时,文字变成了 教程, 把原本内容的下划线去掉了。

渲染逻辑如下:

       const previewElement = document.getElementById('preview')
        const outlineElement = document.getElementById('outline')
        VditorPreview.preview(previewElement, this.docContent, {
          lang: 'zh_CN',
          cdn: vditorCDN,
          mode: 'editor',
          hljs: {
            enable: true,
            // style: 'dracula',
          },
          markdown: {
            toc: true,
            sanitize: false
          },
          after: () => {
            this.loading = false
            VditorPreview.outlineRender(document.getElementById('preview'), outlineElement)
            console.log(outlineElement.innerText)
            if (outlineElement.innerText.trim() !== '') {
              outlineElement.style.display = 'block'
            } else {
              outlineElement.style.display = 'none'
            }
          },

期待的结果

期待渲染目录时正确渲染原本的标题。

截屏或录像

官方示例中的问题:
image

实际项目中的问题:
image

版本信息

vue3, vidtor3.9.8

@sunshineshenjin sunshineshenjin changed the title 文档 标题内容带有下划线(_)时,在preview模式下,目录总提取的标题去掉了下划线(_) 文档 标题内容带有下划线(_)时,在preview模式下,生成目录时把标题内容中的下划线(_)删除了 Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants