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

Curly brackets parse error? #5571

Open
5 tasks done
berrylium0078 opened this issue Nov 3, 2024 · 3 comments · May be fixed by #5618
Open
5 tasks done

Curly brackets parse error? #5571

berrylium0078 opened this issue Nov 3, 2024 · 3 comments · May be fixed by #5618
Labels
bug Something isn't working

Comments

@berrylium0078
Copy link

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

---
title: Hello World
---

123

`{#}`

234

`{{x}}`

Should look like

123

{#}

234

{{x}}

Actual behavior

屏幕截图_20241103_180328

How to reproduce?

just

hexo init blog
cd blog

and edit source/_posts/hello-world.md

then

hexo s

Is the problem still there under Safe mode?

Yes!

Your Node.js & npm version

v23.1.0
10.9.0

Your Hexo and Plugin version

(node:24317) ExperimentalWarning: CommonJS module /usr/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /usr/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
[email protected] /home/netro/Documents/blog
├── [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-deployer-git": "^4.0.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-markdown-it-plus": "^1.0.6",
    "hexo-renderer-stylus": "^3.0.1",
    "hexo-server": "^3.0.0",
    "hexo-theme-landscape": "^1.0.0",
    "hexo-theme-redefine": "^2.7.3",
    "katex": "^0.16.11",
    "markdown-it": "^14.1.0",
    "markdown-it-attrs": "^4.2.0",
    "markdown-it-imsize": "^2.0.1",
    "markdown-it-mathjax3": "^4.3.2",
    "markdown-it-task-lists": "^2.1.1",
    "markdown-it-toc": "^1.1.0"
  }
}

Your site's _config.yml (Optional)

No response

Others

Changing the second line to { #} would fix the problem. What a weird bug!

p.s. I encountered this bug when trying to use mathjax \def and a note block in the same file.

For example:

$\def\sqr#1{#1^2}$

{% note danger %}
danger note
{% endnote %}

Adding a space between the { and # also works in this scenario.

@uiolee uiolee added the bug Something isn't working label Nov 3, 2024
@uiolee
Copy link
Member

uiolee commented Nov 3, 2024

Similar to #5301, {# is considered a comment in nunjucks and is discarded.

#5301 (comment)

@isHarryh
Copy link

isHarryh commented Jan 3, 2025

I also encountered the similar problem. But hexo raised an ERROR related to Nunjucks:

Unhandled rejection Nunjucks Error: _posts/XXX.md [Line xxx, Column xxx] expected variable end

The line caused this error is a MathJax expression which has double curly brackets:

s = \int_{t_1}^{t_2} \sqrt{{\Psi'}^2(t) \cdot {\Phi'}^2(t)} \text d t
                          👆 here

which should be rendered like this:

image

When I separate the double curly brackets, everything goes well.

s = \int_{t_1}^{t_2} \sqrt{ {\Psi'}^2(t) \cdot {\Phi'}^2(t)} \text d t
                          👆 here

Here comes my stack trace:

    at formatNunjucksError (F:\Repos\Blog\node_modules\hexo\lib\extend\tag.ts:189:13)
    at F:\Repos\Blog\node_modules\hexo\lib\extend\tag.ts:280:29
    at tryCatcher (F:\Repos\Blog\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (F:\Repos\Blog\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (F:\Repos\Blog\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (F:\Repos\Blog\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (F:\Repos\Blog\node_modules\bluebird\js\release\promise.js:725:18)
    at _drainQueueStep (F:\Repos\Blog\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (F:\Repos\Blog\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (F:\Repos\Blog\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues (F:\Repos\Blog\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (node:internal/timers:491:21)

@D-Sketon D-Sketon linked a pull request Jan 18, 2025 that will close this issue
2 tasks
@D-Sketon
Copy link
Member

s = \int_{t_1}^{t_2} \sqrt{{\Psi'}^2(t) \cdot {\Phi'}^2(t)} \text d t

You should wrap it in a {% raw %} tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants