theme-next/hexo-theme-next

图片块解析错误!

siaimes opened this issue · 23 comments

I agree and want to create new issue


示例代码

\`\`\`
1
\`\`\`
![2](3.jpg)

Expected behavior

1

[3.jpg]

Actual behavior

1

[3.jpg]
2

Steps to reproduce the behavior

Paste the code on any post to reproduce it!

  • Link to demo site with this bug: N/A
  • Link(s) to source code or any usefull link(s): N/A

Node.js and NPM Information

$ node -v && npm -v
v8.12.0
6.4.1

Package dependencies Information

$ cat package.json
{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.8.0"
  },
  "dependencies": {
    "braces": "^3.0.1",
    "eslint": "^5.16.0",
    "hexo": "^3.8.0",
    "hexo-deployer-git": "^1.0.0",
    "hexo-deployer-rsync": "^0.1.3",
    "hexo-fs": "^1.0.2",
    "hexo-generator-archive": "^0.1.4",
    "hexo-generator-baidu-sitemap": "^0.1.6",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-index": "^0.2.0",
    "hexo-generator-search": "^2.2.5",
    "hexo-generator-sitemap": "^1.2.0",
    "hexo-generator-tag": "^0.2.0",
    "hexo-recommended-posts": "^1.0.3",
    "hexo-renderer-ejs": "^0.3.0",
    "hexo-renderer-pandoc": "^0.2.5",
    "hexo-renderer-stylus": "^0.3.1",
    "hexo-server": "^0.2.2"
  }
}

Hexo Information

Hexo version

$ hexo -v
hexo: 3.8.0
hexo-cli: 1.1.0
os: Windows_NT 10.0.17763 win32 x64
http_parser: 2.8.0
node: 8.12.0
v8: 6.2.414.66
uv: 1.19.2
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 57
nghttp2: 1.32.0
napi: 3
openssl: 1.0.2p
icu: 60.1
unicode: 10.0
cldr: 32.0
tz: 2017c

Hexo Configuration

Theoretically independent of Hexo configuration

NexT Information

NexT Version:

  • Latest Master branch
  • Latest Release version
  • Old version

NexT Scheme:

  • All schemes
  • Muse
  • Mist
  • Pisces
  • Gemini

NexT Configuration:

I only modified sensitive information!

Other Information

看上去不是NexT的bug

@stevenjoezhang 我只是提出问题,内部什么情况就不知道啦,你们可以分析一下!

@ivan-nginx It’s English now.

@siaimes 能否换Hexo的默认主题,测试一下这个bug是否依然存在?

@stevenjoezhang 试了一下,全新的Hexo文件夹也会存在这个问题,那我去Hexo反馈一下这个bug吧,谢谢啦!

或者您试试把hexo-renderer-pandoc换成别的:

npm uninstall hexo-renderer-pandoc --save
npm install hexo-renderer-marked --save

@stevenjoezhang 全新的下载的hexo文件夹也受到我安装的包的影响吗?

嗷,那就是Hexo的锅了……

[2] caption is added by the theme through this line,

$imageWrapLink.append('<p class="image-caption">' + imageTitle + '</p>');

If you remove the above line, [2] will not be displayed as a caption if (3.jpg) is valid. But without that line, fancybox may break.

这个只在fancybox: true时启用

这个只在fancybox: true时启用

Indeed,

CONFIG.fancybox && NexT.utils.wrapImageWithFancyBox();

@siaimes
can you attach your theme's _config.yml? is fancybox enabled?
I tried ![2](3.jpg) while fancybox is disabled and I don't see [2] when (3.jpg) is a valid link.

@siaimes 能否换Hexo的默认主题,测试一下这个bug是否依然存在?

@stevenjoezhang 试了一下,全新的Hexo文件夹也会存在这个问题,那我去Hexo反馈一下这个bug吧,谢谢啦!

do you mean hexo-theme-landscape?
Note hexo-theme-landscape will add [2] caption even when fancybox is disabled.
If you remove this line in hexo-theme-landscape, the [2] caption will not be displayed (if 3.jpg exists). So, it's related to theme, not hexo itself.

@siaimes 能否换Hexo的默认主题,测试一下这个bug是否依然存在?

@stevenjoezhang 试了一下,全新的Hexo文件夹也会存在这个问题,那我去Hexo反馈一下这个bug吧,谢谢啦!

do you mean hexo-theme-landscape?
Note hexo-theme-landscape will add [2] caption even when fancybox is disabled.
If you remove this line in hexo-theme-landscape, the [2] caption will not be displayed (if 3.jpg exists). So, it's related to theme, not hexo itself.

In short, theme-next said that it is a problem with hexo. Hexo said that it is a problem caused by the theme. Anyway, I just raised a potential problem, and the rest is left to you. I can only try to avoid such usage.

If the issue is caused by fancybox, it should be independent of the code block...
Need to do more test

Anyway, I just raised a potential problem, and the rest is left to you. I can only try to avoid such usage.

I'm trying to troubleshoot the issue with you. The thing is I can't reproduce the bug, so I need more information from you. I requested more information in my previous comment,

So, can you please attach your theme's _config.yml?

If you can attach your post's md file (through pastebin.com), or even better, upload the whole blog to github (including the theme), it would help me tremendously to debug the issue.

I also suggested a workaround for you in my previous comments, by removing this line from hexo-theme-landscape; or if you're using hexo-theme-next then remove these lines, and check whether the issue still persists.

image
No markdown renderer. Try run this in bash.

npm install --save hexo-renderer-marked

image
No markdown renderer. Try run this in bash.

npm install --save hexo-renderer-marked

Thank you for your reply, but it doesn't seem to work.

Anyway, I just raised a potential problem, and the rest is left to you. I can only try to avoid such usage.

I'm trying to troubleshoot the issue with you. The thing is I can't reproduce the bug, so I need more information from you. I requested more information in my previous comment,

So, can you please attach your theme's _config.yml?

If you can attach your post's md file (through pastebin.com), or even better, upload the whole blog to github (including the theme), it would help me tremendously to debug the issue.

I also suggested a workaround for you in my previous comments, by removing this line from hexo-theme-landscape; or if you're using hexo-theme-next then remove these lines, and check whether the issue still persists.

The info that I requested so far from you is not on a whim, but to try to pinpoint the source of the issue and to confirm it. So far, I received no additional information/confirmation that is helpful to the cause.

Thank you for your attention to my question. I have uploaded my entire blog to my homepage. I hope that I have deleted all the privacy information, I will delete this project after 24 hours.

project

test page

The bug is caused by hexo-renderer-pandoc and has nothing to do with theme NexT.
Try:

npm uninstall hexo-renderer-pandoc --save
npm install hexo-renderer-marked --save

Anyone having similar issue, please refer to this workaround.

Maybe we need to prompt hexo-renderer-pandoc users about this issue in the documentation.

I just had a quick test with hexo-renderer-pandoc, figure it might be useful for the doc.
Assuming fancybox is disabled, if an image is preceded or followed by any characters or has a backslash at the end, caption would not be shown. Caption is only shown when the image has new line before and after.

aaa
![alt text](https://postimgs.org/img/logo.png)

![alt text](https://postimgs.org/img/logo.png)
bbb

![alt text](https://postimgs.org/img/logo.png)\

![alt text](https://postimgs.org/img/logo.png)

pandoc

pandoc:
  extensions:
    - '-implicit_figures'