next-theme / hexo-theme-next

🎉 Elegant and powerful theme for Hexo.
https://theme-next.js.org
Other
2.31k stars 411 forks source link

前端渲染 mathjax 时,本地搜索的高亮功能会破坏含有高亮文字的公式段 #782

Closed JoyWonderful closed 1 week ago

JoyWonderful commented 1 month ago

Issue Checklist

Expected behavior

公式在前端正常被 mathjax 渲染

Actual behavior

截图中,下方是正确渲染的(没有 highlight= 参数),上方是被 highlight=进制 参数高亮所破坏的公式(页面已经加载完成)。

我测试了一下,NexT 主题的的文档网站也有这个问题,在公式示例页面的网址后添加参数 highlight=e 后,e=mc^2 的公式渲染被破坏了。如图:

math-nextdocbrok.png

Steps to reproduce the behavior

在网址后添加 highlight= 参数,与公式内容有重合时(公式内容被高亮),公式就无法在前端被正常渲染。未重合的公式可以正常渲染。
也就是在本地搜索框中的结果链接。

像这样: just-abrok.jpeg

Node.js and NPM Information

node: v18.16.0
npm: 9.5.1

Package dependencies Information

hexo-site@0.0.0 
├── hexo-deployer-git@4.0.0      
├── hexo-generator-archive@1.0.0 
├── hexo-generator-category@1.0.0
├── hexo-generator-index@2.0.0   
├── hexo-generator-searchdb@1.4.1
├── hexo-generator-tag@1.0.0
├── hexo-hide-posts@0.4.2
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-marked@4.1.0
├── hexo-renderer-stylus@2.1.0
├── hexo-server@2.0.0
├── hexo-theme-landscape@0.0.3
└── hexo@5.4.2

Hexo Configuration

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: JoyWonderful的小窝
subtitle: Be HardWorking Every Day.
description: ''
keywords:
author: JoyWonderful
language: zh-CN
timezone: ''

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://joywonderful.github.io
permalink: /posts/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: false
  line_number: false
  auto_detect: false
  tab_replace: ''
  wrap: false
  hljs: false
prismjs:
  enable: true
  preprocess: true
  line_number: false
  tab_replace: ''

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 5
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: git
  repository: git@github.com:JoyWonderful/joywonderful.github.io.git
  branch: main

NexT Configuration

math:
  # Default (false) will load mathjax / katex script on demand.
  # That is it only render those page which has `mathjax: true` in front-matter.
  # If you set it to true, it will load mathjax / katex script EVERY PAGE.
  every_page: false

  mathjax:
    enable: true
    # Available values: none | ams | all
    tags: none

  katex:
    enable: false
    # See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
    copy_tex: false

Other Information

Broswer: Edge 123.0.2420.65

welcome[bot] commented 1 month ago

Thanks for opening this issue, maintainers will get back to you as soon as possible!