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

Incomplete display of HTML document, truncated at '#' in markdown document #5301

Closed
756yang opened this issue Sep 26, 2023 · 7 comments · May be fixed by #5618
Closed

Incomplete display of HTML document, truncated at '#' in markdown document #5301

756yang opened this issue Sep 26, 2023 · 7 comments · May be fixed by #5618
Labels
bug Something isn't working

Comments

@756yang
Copy link

756yang commented Sep 26, 2023

使用默认安装,将md文档处理为网页时,启动hexo网站服务,本地查看文档内容不全。

When using the default installation to process MD documents as web pages, starting the hexo website service may result in incomplete local viewing of document content.

### 数组

- 数组定义:`array_name=(value1 ... valuen)`<br>
  括号里面允许换行,value以空格或换行分隔
- 也可以单独定义数组各个分量:`array_name[i]=valuei` (i可以是数字).<br>
  即数组可以不定义就使用,也可以定义时赋初值,数组元素就像普通变量一样使用即可。
- 引用数组所有元素:`${array_name[*]}``${array_name[@]}`.<br>
  只会取得数组已定义元素值的列表
- 可以使用unset删除数组元素:`unset array_name[i]`<br>
- 使用`${#array_name[*]}``${#array_name[@]}`取得数组已定义的元素数量(数组长度)
- 使用`${#array_name[n]}`取得n号元素的长度,这些就像求串长一样。
- 数组切片:`${array_name[*]:position:length}``${array_name[@]:position:length}`.<br>
  这其实是对数组已定义元素值的列表进行切片,就像串取子串一样。

上面文档将只会显示部分处理内容:

The above document will only display partial processing content:

### 数组

- 数组定义:`array_name=(value1 ... valuen)`<br>
  括号里面允许换行,value以空格或换行分隔
- 也可以单独定义数组各个分量:`array_name[i]=valuei` (i可以是数字).<br>
  即数组可以不定义就使用,也可以定义时赋初值,数组元素就像普通变量一样使用即可。
- 引用数组所有元素:`${array_name[*]}``${array_name[@]}`.<br>
  只会取得数组已定义元素值的列表
- 可以使用unset删除数组元素:`unset array_name[i]`<br>
- 使用`$

经过多次验证,只会在正文包含'#'字符时出现异常。

After multiple verifications, exceptions will only occur when the body contains the '#' character.

版本信息:

npx hexo -v
INFO  Validating config
hexo: 6.3.0
hexo-cli: 4.3.1
os: win32 10.0.19044
node: 18.17.1
acorn: 8.8.2
ada: 2.5.0
ares: 1.19.1
brotli: 1.0.9
cldr: 43.1
icu: 73.2
llhttp: 6.0.11
modules: 108
napi: 9
nghttp2: 1.52.0
openssl: 3.1.2
simdutf: 3.2.12
tz: 2023c
undici: 5.22.1
unicode: 15.0
uv: 1.46.0
uvwasi: 0.0.18
v8: 10.2.154.26-node.26
zlib: 1.3
@756yang
Copy link
Author

756yang commented Sep 26, 2023

正文使用了 {# 就会稳定复现这个问题.
The use of {# in the main text will result in stable reproduction of this issue.

@756yang 756yang closed this as completed Sep 26, 2023
@756yang 756yang reopened this Sep 26, 2023
@756yang
Copy link
Author

756yang commented Sep 26, 2023

目前找到一个解决方法,改成这样就行了,烦:
{% raw %}{#{% endraw %}

@756yang 756yang closed this as completed Sep 26, 2023
@756yang
Copy link
Author

756yang commented Sep 26, 2023

还是希望能够修复这个BUG,手动更改md源文件太麻烦了。

要使hexo g正常处理,以下是md源文件需要改动的地方:

这里面的'{'字符不需要替换为'{% raw %}{{% endraw %}'

这里面的'{'字符需要替换为'{% raw %}{{% endraw %}'

'\{'也需要替换为'{% raw %}{{% endraw %}'

@756yang 756yang reopened this Sep 26, 2023
@D-Sketon
Copy link
Member

{# 被当做了Nunjucks 的注释

@D-Sketon
Copy link
Member

如果文章中不存在标签插件,可以在front-matter中添加disableNunjucks: true

@756yang
Copy link
Author

756yang commented Sep 26, 2023

如果文章中不存在标签插件,可以在front-matter中添加disableNunjucks: true

现在我的处理是用sed对md源文件进行处理:

sed -e 's:\(`[^`]*\){\([^`]*`\):\1{% raw %}{{% endraw %}\2:g'

这只解决部分情况(反引号包裹的代码里面出现'{'字符),但是也足够目前使用,这个BUG还是烦,先这样用着。

@uiolee uiolee added the enhancement New feature or request label Sep 28, 2023
@uiolee uiolee added bug Something isn't working and removed enhancement New feature or request labels Dec 21, 2023
@uiolee
Copy link
Member

uiolee commented Jan 14, 2024

hexo/lib/hexo/post.ts

Lines 146 to 151 in 6a91fb6

} else if (state === STATE_SWIG_COMMENT) { // From swig back to plain text
if (char === '#' && next_char === '}') {
idx++;
state = STATE_PLAINTEXT;
buffer = '';
}

Before Nunjucks rendering it,
{# and the following content have been dropped when exec escapeAllSwigTags()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants