Candinya / Kratos-Rebirth

一个可爱而现代的 Hexo 主题
GNU General Public License v3.0
630 stars 80 forks source link

博客文章中代码块显示不完整 #110

Closed xhege closed 2 years ago

xhege commented 2 years ago

文章中的Java代码块只能单行显示不清楚,代码高亮暗色背景不生效,没有代码复制按钮 主题_config.yml配置如下:

Candinya commented 2 years ago

如果可以,希望您能按照模板提供,以便我们排查出现的问题。

  1. 报告前须知
  1. 对Bug的描述:

  2. 复现Bug的方法:

  3. 相关的截图:

  4. 运行环境(如果该Bug的产生和环境有关,例如浏览器不兼容导致):

  5. 您的配置文件:

  6. 补充内容:

Candinya commented 2 years ago

如果理解起来有困难的话,能否麻烦提供以下的文件或是数据:

  1. 站点目录package.json 文件
  2. 站点目录_config.yml 文件
  3. 您该部分渲染异常的 Markdown 源码

这不是一个主题的样式问题,这是渲染器出错导致块代码被渲染成了行代码的模式

xhege commented 2 years ago

好的

xhege commented 2 years ago

站点目录的 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": "5.4.1" }, "dependencies": { "hexo": "^5.0.0", "hexo-blog-encrypt": "^3.1.6", "hexo-deployer-git": "^3.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.0", "hexo-generator-tag": "^1.0.0", "hexo-permalink-pinyin": "^1.1.0", "hexo-renderer-ejs": "^1.0.0", "hexo-renderer-marked": "^4.0.0", "hexo-renderer-pug": "^3.0.0", "hexo-renderer-stylus": "^2.0.1", "hexo-server": "^2.0.0", "hexo-theme-butterfly": "^4.1.0", "hexo-theme-landscape": "^0.0.3" } }

xhege commented 2 years ago

_config.yml 文件

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 abbrlink: alg: crc32 # 算法:crc16(default) and crc32 rep: hex # 进制:dec(default) and hex

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: true line_number: true auto_detect: false tab_replace: '' wrap: true hljs: false prismjs: enable: true preprocess: true line_number: true 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: 12 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: 12 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: Rebirth

xhege commented 2 years ago

大佬,我的问题解决了,好像是因为站点_config.yml文件默认highlight:和prismjs:渲染同时开启了,关闭其中一个代码块就正常显示了

Candinya commented 2 years ago

大佬,我的问题解决了,好像是因为站点_config.yml文件默认highlight:和prismjs:渲染同时开启了,关闭其中一个代码块就正常显示了

好的,解决了就好!

Candinya commented 2 years ago

如果有其他任何问题,欢迎随时 issue 联系 ✌

Candinya commented 2 years ago

不过想到了也确实有可能是主题的问题,印象里 prismjs 是运行时渲染的,这块的结构不够丰富,似乎不是太好处理,所以更推荐使用 highlight 的说