Skip to content

8.1的#5616转换了注释内容再渲染,导致标签插件和代码块中的注释部分失效 #5716

@chanwj

Description

@chanwj

Check List

  • I have already read Docs page & Troubleshooting page.
  • I have already searched existing issues and they are not help to me.
  • I examined error or warning messages and it's difficult to solve.
  • I am using the latest version of Hexo. (run hexo version to check)
  • My Node.js is matched the required version.

Expected behavior

  1. 在常见的分栏Tab标签插件和Timeline时间线标签插件中,往往会使用<!-- tab [tabName] --><!-- endtab --><!-- timeline 4月28日 --><!-- endtimeline -->等注释进行内容划分。
  2. 在代码块以及行内代码中包含<!-- -->文本时,应该按普通文本的样式显示出来,输出示例:<code><!-- 注释内容 --></code>

Actual behavior

在更新8.1版本后,发现包含注释内容的标签插件和代码块出现问题。经排查发现是 #5616 的合并增加了注释转换然后再渲染内容导致的。
目前,以上两个场景生成的情况如下:

  1. 分栏Tab标签插件和Timeline时间线标签插件都无法显示内容,被注释包裹的部分完全丢失。
  2. 代码块和行内代码中的注释文本无法显示:
    • 代码块:注释文本的位置只显示空行,在页面或者控制台都没有文本内容。
    • 行内代码:在控制台发现该内容变成了真正的注释,仅在控制台可见。

How to reproduce?

  1. 寻找任意一个支持包含注释内容标签插件的主题进行测试,比如:

{% timeline title[,style] %}

Any Content

{% endtimeline %}

  1. 在代码块里测试注释内容能否显示
{% timeline title[,style] %}

<!-- timeline title -->

Any Content

<!-- endtimeline -->

{% endtimeline %}
  1. 在行内代码中输入注释内容测试文本能否显示

<!-- tab [tabName] -->

Is the problem still there under Safe mode?

Y

Your Node.js & npm version

node 20.19.0

Your Hexo and Plugin version

hexo 8.1.0

Your package.json

"dependencies": {
    "hexo": "^8.1.0",
    "hexo-abbrlink": "^2.2.1",
    "hexo-blog-encrypt": "^3.1.9",
    "hexo-generator-archive": "^2.0.0",
    "hexo-generator-category": "^2.0.0",
    "hexo-generator-index": "^4.0.0",
    "hexo-generator-searchdb": "^1.5.0",
    "hexo-generator-sitemap": "^3.0.1",
    "hexo-generator-tag": "^2.0.0",
    "hexo-htmlnano-mini": "^2.0.1",
    "hexo-pangu": "^0.4.1",
    "hexo-renderer-markdown-it": "^7.1.1",
    "hexo-renderer-pug": "^3.0.0",
    "hexo-renderer-stylus": "^3.0.1",
    "hexo-server": "^3.0.0",
    "hexo-wordcount": "^6.0.1",
    "markdown-it-task-checkbox": "^1.0.6"
  }

Your site's _config.yml (Optional)

Others

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions