hexo icon indicating copy to clipboard operation
hexo copied to clipboard

Hexo strips leading spaces in code blocks

Open TripleCamera opened this issue 1 year ago • 1 comments

Check List

  • [X] I have already read Docs page & Troubleshooting page.
  • [X] I have already searched existing issues and they are not help to me.
  • [X] I examined error or warning messages and it's difficult to solve.
  • [X] I am using the latest version of Hexo. (run hexo version to check)
  • [X] My Node.js is matched the required version.

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

[email protected] D:\GitHub\triplecamera.github.io
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

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

TripleCamera avatar Feb 18 '24 15:02 TripleCamera

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

uiolee avatar Feb 20 '24 13:02 uiolee

Hi, how is everything going?

TripleCamera avatar Mar 13 '24 08:03 TripleCamera

Cheers! :tada:

TripleCamera avatar Apr 07 '24 01:04 TripleCamera