hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.17k stars 4.81k forks source link

Hexo failed to highlight codefence inside a blockquote. #5147

Closed sakurawald closed 1 year ago

sakurawald commented 1 year ago

Check List

Please check followings before submitting a new issue.

Expected behavior

The codes inside a blockquote should be rendered the same as MarkedDemo. But hexo didn't. I am not sure whether this is is the problem of hexo or marked.js

image

image

Actual behavior

The codes insides a blockquote are actually rendered in-correctly. (The ">" should not be a part of the codes.)

image

image

How to reproduce?

Try to write down this.

>```java
>This is the first line.
>This is the second line.
>This is the thrid line.
>```

Is the problem still there under "Safe mode"?

YES !

Environment & Settings

Node.js & npm version(node -v && npm -v)

 ~/Workspace/Github/sakurawald.github.io   main ±  node -v
v16.19.0
 ~/Workspace/Github/sakurawald.github.io   main ±  npm -v
9.2.0

Your site _config.yml (Optional)

I have tested the "default highlight", "highlightjs" and "prismjs".
All of them behave the same.

Hexo and Plugin version(npm ls --depth 0)

 ✘  ~/Workspace/Github/sakurawald.github.io   main ±  npm ls --depth 0
hexo-site@0.0.0 /home/sakurawald/Workspace/Github/sakurawald.github.io
├── hexo-deployer-git@3.0.0
├── hexo-filter-mermaid-diagrams@1.0.5
├── hexo-generator-archive@2.0.0
├── hexo-generator-category@2.0.0
├── hexo-generator-index@3.0.0
├── hexo-generator-tag@2.0.0
├── hexo-migrator-wordpress@2.1.2
├── hexo-renderer-ejs@2.0.0
├── hexo-renderer-kramed@0.1.4
├── hexo-renderer-pug@3.0.0
├── hexo-renderer-stylus@2.1.0
├── hexo-server@3.0.0
├── hexo@6.3.0
├── pjax@0.2.8
└── remove@0.1.5

Your package.json 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": "6.3.0"
  },
  "dependencies": {
    "hexo": "^6.3.0",
    "hexo-deployer-git": "^3.0.0",
    "hexo-filter-mermaid-diagrams": "^1.0.5",
    "hexo-generator-archive": "^2.0.0",
    "hexo-generator-category": "^2.0.0",
    "hexo-generator-index": "^3.0.0",
    "hexo-generator-tag": "^2.0.0",
    "hexo-migrator-wordpress": "^2.1.2",
    "hexo-renderer-ejs": "^2.0.0",
    "hexo-renderer-kramed": "^0.1.4",
    "hexo-renderer-pug": "^3.0.0",
    "hexo-renderer-stylus": "^2.1.0",
    "hexo-server": "^3.0.0",
    "pjax": "^0.2.8",
    "remove": "^0.1.5"
  }
}

Others

Though I use "kramed", but I test on "marked" too, both of them have the same bug. Maybe this is not a bug of the markdown render, but a bug of hexo.

sakurawald commented 1 year ago

If you don't enable the highlight plugins. Then everything goes well. image

stevenjoezhang commented 1 year ago

Try adding some spaces between '>' and '```'

> ```java
> This is the first line.
> This is the second line.
> This is the thrid line.
> ```
sakurawald commented 1 year ago

The reason for the error is that the highlight function is called at the wrong time. If you call the highlight function manually, then everything goes well. Anyway, there are still some rendering problems on hexo.