levonlin / Tinnypp

This is a theme for hexo and based on the theme Tinny.
14 stars 6 forks source link

你好,请教一下,代码高亮怎么弄。 #4

Closed wangkunlin closed 8 years ago

wangkunlin commented 8 years ago

我把hexo的高亮关了,也hexo clean和hexo g 了,但是网页上的代码没什么变化,依然不是高亮的。是不是还是有的地方没配置导致的?求助啊,就这一个问题了。

wangkunlin commented 8 years ago

刚才不知道怎么就高亮了,但是还有个问题,我看了你的博客,还是这个主题,是怎么出现行号的?为啥我的没有呢?

levonlin commented 8 years ago

我用的是hexo的默认高亮,主题里带的highlight.js不支持显示行号。 它的作者是这么解释的。。。

wangkunlin commented 8 years ago

但是我用hexo的默认的 根本就不会亮。。是什么情况。

levonlin commented 8 years ago

发下你的配置文件吧,两个_config.yml,分别是hexo的和主题里的

wangkunlin commented 8 years ago

hexo 的_config.yml文件

title: 王坤林
subtitle: ---开发者
description: 个人博客
author: 王坤林
language: zh-CN
timezone:

url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

# 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: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: false
  line_number: true
  auto_detect: true
  tab_replace:

default_category: uncategorized
category_map:
tag_map:

date_format: YYYY-MM-DD
time_format: HH:mm:ss

per_page: 10
pagination_dir: page

theme: Tinnypp

deploy:
  type: git
  repo: https://github.com/wangkunlin/wangkunlin.github.io.git
  branch: master

Tinnypo的_config.yml文件

##### Menu
menu:
  首页: /
  归档: /archives

profile:
  enable: true
  href: https://github.com/wangkunlin

#### Widgets
widgets: 
- category
- tag
#- rss

excerpt_link: 阅读更多

#rss: /Tinnypp/atom.xml## RSS address.
#rss: /

#### Image
imglogo:
  enable: false             ## display image logo true/false.
  src: img/logo.svg        ## `.svg` and `.png` are recommended,please put image into the theme folder `/Tinny/source/img`.
favicon: img/favicon.ico   ## size:32px*32px,`.ico` is recommended,please put image into the theme folder `/Tinny/source/img`.     
apple_icon: img/Tinny.jpg ## size:114px*114px,please put image into the theme folder `/Tinny/source/img`.

#### Author Avatar Picture
author_img_enable: true ## display author avatar picture
dataURI: false
## if the picture's format is dataURI please set the value to true,otherwise set the value to false.
## convert an image into base 64 data URIs http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/ .
author_img_data: ''
## paste the dataURI in ONE LINE and included it by ''.
author_img: img/myPic.jpg ## size:220px*220px.
## if the picture's format is `.png` or `.jpg`  instead of dataURI,you should set the `dataURI` value to false.

#### Font
ShowCustomFont: true  
## you can change custom font in `variable.styl` and `font.styl` which in the theme folder `/Tinny/source/css`.

toc:
  article: true   ## show contents in article.
  aside: false    ## show contents in aside.
fancybox: true

colorscheme:
  enable: true
  color: railscasts

author:
  google_plus: ## eg:116338260303228776998 for https://plus.google.com/u/0/116338260303228776998
  intro_line1: '王坤林'    ## eg: "Hello ,I'm Larry Page in Google."
  intro_line2: '热爱编程,热爱开源的屌丝程序猿'   ## eg: "This is my blog,believe it or not."
  weibo:          ## e.g. 436062867 for http://weibo.com/436062867
  twitter:        ## e.g. yangjiansky for https://twitter.com/yangjiansky
  github: 'wangkunlin'      ## e.g. A-limon for https://github.com/A-limon
  facebook:       ## e.g. yangjian for https://favebook.com/yangjian
  tsina:          ## e.g. 1664838973  Your weibo ID,It will be used in share button.

duoshuo: 
  enable: true  ## duoshuo.com
  short_name:  wangkunlin  ##your duoshuo short name.

jiathis:
  enable: true ## if you use jiathis as your share tool,the built-in share tool won't be display.
  id: 1501277    ## e.g. 1501277 your jiathis ID. 
  tsina: ## e.g. 1664838973 Your weibo id,It will be used in share button.

#### Analytics
google_analytics:
  enable: true
  id: UA-1766729-8  ## e.g. UA-1766729-8 your google analytics ID.
  site: auto 
google_cse: 
  enable: false
  cx:  
swift_search:
  enable: true
wangkunlin commented 8 years ago

我现在用的是heightlight.js的高亮。

levonlin commented 8 years ago

hexo的配置文件中设置:

highlight:
  enable: true
  line_number: true

hexo clean hexo g一下,就能开启默认高亮的行号了,而且你得注意下markdown语法,只有被```包起来的代码块才会显示行号。

wangkunlin commented 8 years ago
int a = 1;
int b = 2;
int c = a + b;
public static void main(String[] agrs) {
    System.out.println("hello world");
}

这段代码的效果是。 pic

levonlin commented 8 years ago

再试试设置下:

colorscheme:
  enable: false
wangkunlin commented 8 years ago

还是不行

wangkunlin commented 8 years ago

我试了试其他主题,coney 效果和上面的图差不多,但是如果我用hexo的默认主题就是有高亮的。 好像我只要设置了其他主题,他就不会高亮了。

levonlin commented 8 years ago

这个,你有hexo clean下试试吗?

wangkunlin commented 8 years ago

每次的改完东西都是hexo clean 然后 hexo g 然后 hexo s 从本地服务器看效果的。

levonlin commented 8 years ago

这个,应该是样式没加载出来,没有代码我也没法说是什么问题。 不如你放一个代码块到你博文里,我看看是怎么回事吧~

wangkunlin commented 8 years ago

不好意思,最近一直忙工作。 wangkunlin.date

levonlin commented 8 years ago

额,我指的是看看hexo的默认代码高亮的问题,然而你博客上现在用的还是highlight.js呀。。。

wangkunlin commented 8 years ago

好。我换成默认的。http://wangkunlin.date/2016/05/12/hello-world/

levonlin commented 8 years ago

看了下,你博客生成的css少了好多行,检查下主题目录下有没有这些文件吧: https://github.com/levonlin/Tinnypp/tree/master/source/css/_base 没有的话就更新下主题。。。

wangkunlin commented 8 years ago

这四个的styl文件都是有的。在主题里面。

levonlin commented 8 years ago

既然有,那就不是主题的问题了,应该是你的hexo哪里配置有问题导致生成不了相应的样式。 这样吧,如果你方便的话把你的博客目录压缩后发我邮箱,我在我这边看看到底是什么问题吧。

levonlin commented 8 years ago

额,我更新了下hexo,结果出现了你这个情况。原来是新旧版本的变量环境不同了,导致coney系主题的高亮样式都加不出来,现在我已经修复了,你可以更新试试。