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

Codeblock highlight incorrectly for rust 'lifetime specifier'. #5595

Closed
5 tasks done
sshelll opened this issue Dec 24, 2024 · 2 comments
Closed
5 tasks done

Codeblock highlight incorrectly for rust 'lifetime specifier'. #5595

sshelll opened this issue Dec 24, 2024 · 2 comments

Comments

@sshelll
Copy link

sshelll commented Dec 24, 2024

Check List

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

Expected behavior

Highlight rust code correctly.

I've tested on the official demo site of highlightjs, it's correct:

image

Actual behavior

For this snippet:

fn main() {
    let hello: &'static str = "hello";
    {
        let world = String::from("world");
        let world = &world;
        debug(hello, world);
    }
}

Since the lifetime specifier for rust starts with an 「'」, hexo / highlightjs seems to treat all the characters after it to a single string:
image

How to reproduce?

  1. hexo init
  2. hexo new post test
  3. put the rust code snippet in to a codeblock
  4. hexo generate && hexo server

Is the problem still there under Safe mode?

Yes!

Your Node.js & npm version

node -v && npm -v
v23.5.0
10.9.2

Your Hexo and Plugin version

npm ls --depth 0
[email protected] /Users/xxxx/tmp/hexo_test/test
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Your 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": "7.3.0"
  },
  "dependencies": {
    "hexo": "^7.3.0",
    "hexo-generator-archive": "^2.0.0",
    "hexo-generator-category": "^2.0.0",
    "hexo-generator-index": "^4.0.0",
    "hexo-generator-tag": "^2.0.0",
    "hexo-renderer-ejs": "^2.0.0",
    "hexo-renderer-marked": "^6.3.0",
    "hexo-renderer-stylus": "^3.0.1",
    "hexo-server": "^3.0.0",
    "hexo-theme-landscape": "^1.0.0"
  }
}

Your site's _config.yml (Optional)

default, unchanged

Others

No response

@D-Sketon
Copy link
Member

@sshelll
Copy link
Author

sshelll commented Dec 25, 2024

highlightjs/highlight.js#4190

Thanks,I'll closed the issue and track that one.

BTW, I wonder if any changes should be made in hexo conf after highlightjs fixed that issue?

@sshelll sshelll closed this as completed Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants