hexojs / hexo

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

Hexo strips leading spaces in code blocks #5422

Closed TripleCamera closed 7 months ago

TripleCamera commented 9 months ago

Check List

Expected behavior

Leading spaces in code blocks are not stripped.

Actual behavior

Leading spaces in code blocks are stripped.

How to reproduce?

Render the following lines:

This is a paragraph.
This is a code block
with 4 spaces
at the beginning of
each line.

Here is a live example on my blog.

Is the problem still there under Safe mode?

Cannot generate pages at all under safe mode.

Your Node.js & npm version

v20.11.0
10.2.4

Your Hexo and Plugin version

hexo-site@0.0.0 D:\GitHub\triplecamera.github.io
├── 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-renderer-ejs@2.0.0
├── hexo-renderer-pandoc@0.4.0
├── hexo-renderer-stylus@3.0.1
├── hexo-server@3.0.0
├── hexo-theme-next@8.19.1
└── hexo@7.1.1

Your package.json

See https://github.com/TripleCamera/triplecamera.github.io.

Your site's _config.yml (Optional)

See https://github.com/TripleCamera/triplecamera.github.io.

Others

No response

uiolee commented 9 months ago

related code: https://github.com/hexojs/hexo-util/blob/1cf5b21ceeb0d2f9456f9003b9f956c43903d4ff/lib/highlight.ts#L23

https://github.com/hexojs/hexo-renderer-marked/commit/56cc5689334486fedd9a4d38e4233463d2cbdbc5 Looks like this feature was added ten years ago

TripleCamera commented 8 months ago

Hi, how is everything going?

TripleCamera commented 7 months ago

Cheers! :tada: