Check List
Expected behavior
The Post:
---
title: Hello World
date: 2021-10-09 21:50:25
refplus: true
---
<!-- more -->
Test {% ref self %}.
## Ref
{% references %}
[self] {% post_link hello-world hello-world %}
{% endreferences %}
All Markdown content between the ref and endreferences tags is rendered properly. And ## Ref is rendered as an h2 element.
Actual behavior
All Markdown content between the ref and endreferences tags is escaped, resulting in unrendered text.
How to reproduce?
sudo apt install npm
sudo npm install hexo@7.3.0 -g
hexo init testenv
cd testenv
npm install hexo-reference-plus
cd source/_posts/
tee >hello-world.md <<EOF
---
title: Hello World
date: 2021-10-09 21:50:25
refplus: true
---
<!-- more -->
Test {% ref self %}.
## Ref
{% references %}
[self] {% post_link hello-world hello-world %}
{% endreferences %}
EOF
Is the problem still there under Safe mode?
Yes
Your Node.js & npm version
Your Hexo and Plugin version
hexo-site@0.0.0 /home/admin/test/testenv
├── hexo-generator-archive@2.0.0
├── hexo-generator-category@2.0.0
├── hexo-generator-index@4.0.0
├── hexo-generator-tag@2.0.0
├── hexo-reference-plus@1.1.0
├── hexo-renderer-ejs@2.0.0
├── hexo-renderer-marked@7.0.0
├── hexo-renderer-stylus@3.0.1
├── hexo-server@3.0.0
├── hexo-theme-landscape@1.0.0
└── hexo@7.3.0
Your package.json
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "hexo generate",
"clean": "hexo clean",
"deploy": "hexo deploy",
"server": "hexo server"
},
"hexo": {
"version": "7.3.0"
},
"dependencies": {
"hexo": "^7.3.0",
"hexo-generator-archive": "^2.0.0",
"hexo-generator-category": "^2.0.0",
"hexo-generator-index": "^4.0.0",
"hexo-generator-tag": "^2.0.0",
"hexo-reference-plus": "^1.1.0",
"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-marked": "^7.0.0",
"hexo-renderer-stylus": "^3.0.1",
"hexo-server": "^3.0.0",
"hexo-theme-landscape": "^1.0.0"
}
}
Your site's _config.yml (Optional)
Others
I discovered this bug is caused by the escapeAllSwigTags function:
The ref and references tags share the same prefix. When escapeAllSwigTags uses endref to identify block-level tags, all content between {% ref xxx %} and {% endreferences %} is incorrectly escaped, resulting in unrendered Markdown.
This is clearly a bug:
- The tag plugin functioned correctly with Hexo four years ago.
- Plugins are restricted from sharing prefixes, and patterns like
end${plugin_name} in text will also cause ambiguity.
Check List
hexo versionto check)Expected behavior
The Post:
All Markdown content between the
refandendreferencestags is rendered properly. And## Refis rendered as anh2element.Actual behavior
All Markdown content between the ref and endreferences tags is escaped, resulting in unrendered text.
How to reproduce?
Is the problem still there under
Safe mode?Yes
Your Node.js & npm version
Your Hexo and Plugin version
Your
package.json{ "name": "hexo-site", "version": "0.0.0", "private": true, "scripts": { "build": "hexo generate", "clean": "hexo clean", "deploy": "hexo deploy", "server": "hexo server" }, "hexo": { "version": "7.3.0" }, "dependencies": { "hexo": "^7.3.0", "hexo-generator-archive": "^2.0.0", "hexo-generator-category": "^2.0.0", "hexo-generator-index": "^4.0.0", "hexo-generator-tag": "^2.0.0", "hexo-reference-plus": "^1.1.0", "hexo-renderer-ejs": "^2.0.0", "hexo-renderer-marked": "^7.0.0", "hexo-renderer-stylus": "^3.0.1", "hexo-server": "^3.0.0", "hexo-theme-landscape": "^1.0.0" } }Your site's
_config.yml(Optional)Others
I discovered this bug is caused by the
escapeAllSwigTagsfunction:The
refandreferencestags share the same prefix. WhenescapeAllSwigTagsusesendrefto identify block-level tags, all content between{% ref xxx %}and{% endreferences %}is incorrectly escaped, resulting in unrendered Markdown.This is clearly a bug:
end${plugin_name}in text will also cause ambiguity.