Giter VIP home page Giter VIP logo

Comments (4)

levblanc avatar levblanc commented on July 24, 2024

已更新 highlight.js 的bundle,让它能够识别更多语言。拉取最新的代码试试。

如果可以的话就回来关闭这个issue吧。

from hexo-theme-aero-dual.

Evyde avatar Evyde commented on July 24, 2024

只能说好一些了,但是对于很多代码仍然不支持高亮,如图,C++和Java的关键字竟然都没有高亮。。。
image
image
但是这个问题似乎是间歇性的,如图,同一片文章内都是Java这个高亮就没有问题:
image
可能是玄学问题。

from hexo-theme-aero-dual.

levblanc avatar levblanc commented on July 24, 2024

我发现highlight js会自己检测代码类型,官方页面在这

image

(虽然它说可以自定义,然而hexo这边是直接从markdown生成的,我控制不了代码块的class……)

你的第一段截图代码,它认为是R…… (即使我本地尝试的时候,在markdown里面已经声明是java)

image

我下载的bundle里面应该是没有R吧,即使有,高亮出来跟你的代码应该对不上的,因为本来类型就错了。

有一个比较折腾的解决方法,就是使用hexo自带的landscape主题的代码高亮来替换我的方案:

  1. 复制 landscape 的 highlight.styl

(其中有些变量在_variables.styl,缺少的话编译的时候会报错,报哪个出错,就过去复制哪个,就行了。我这边尝试过,补上font-sizeline-heightfont-monoarticle-padding这几个基本就ok了。)

  1. 替换我的 code.styl (areo_dual/source/css/_typography/code.styl) 里面的内容,然后把其中的.article-entry class 改成.post-content

  2. 把 highlight.js 的引入屏蔽(注释 aero-dual/layout/_partial/after-footer.ejs 里面的全部内容)

写到这里,我有一个大胆的猜想,就是直接屏蔽我的 code.styl 和 after-footer.ejs 内容,然后直接在 html-head.ejs 里面引入github的样式,或许也是可行的。github的样式在人家的文章里面看到有这个<link rel="stylesheet" href="//cdn.bootcss.com/highlight.js/9.2.0/styles/github.min.css">,还有这里的CDN地址,如果速度慢,就整个拿下来放到项目里吧

上面这三个步骤折腾完毕的效果:

image

希望能对你有所帮助,以上!

from hexo-theme-aero-dual.

Evyde avatar Evyde commented on July 24, 2024

感谢,我会试一试的。
不过希望您写的这篇文章可以加入wiki。

from hexo-theme-aero-dual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.