Skip to content

Commit

Permalink
remove js highlight,use hugo Syntax Highlighting,fix hugo v0.60.0+ Sy…
Browse files Browse the repository at this point in the history
…ntax Highlighting bugs.close flysnow-org#72,close flysnow-org#73
  • Loading branch information
flysnoworg committed Dec 17, 2019
1 parent 6d75b4d commit 65a1598
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 306 deletions.
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ Maupassant theme, ported to Hugo.
9. 支持GA分析统计
17. 不蒜子页面计数器支持
11. 代码高亮、代码行号
* markup、css、clike、javascript、c、csharp、bash、cpp
* aspnet、dart、docker、markup-templating、erlang
* go、groovy、java、json、kotlin、markdown、lua、objectivec
* php、python、r、yaml、toml
10. sitemap站点地图
5. RSS支持,并且可以自动发现RSS
14. Google站内搜索
Expand Down Expand Up @@ -82,10 +78,35 @@ summaryLength = 140
description = "专注于IT互联网,包括但不限于Go语言(golang)、Java、Android、Python、项目管理、抖音分析、软件架构等"
busuanzi = true
localSearch = true

[markup]
[markup.highlight]
lineNos = true
style = "github"
```

基本配置大家都比较熟悉,这是我的博客的配置,仅供参考。

#### 代码高亮

从Hugo v0.60.0开始,默认使用`Goldmark`渲染MD文件,并且默认开启了代码高亮,所以该主题原来的代码高亮兼容出现问题,
经过取舍,最终还是选用了Hugo原生的代码高亮方式,去掉了原来主题自带的基于JS的代码高亮。

新的Hugo内置的代码高亮使用非常代码,默认不用任何配置就可以,如果你需要开启行号、或者更换代码样式,可以参考如下配置:

*config.toml*
```toml
[markup]
[markup.highlight]
lineNos = true
style = "github"
```

更多配合和样式参考:

[Configure Markup](https://gohugo.io/getting-started/configuration-markup)
[Syntax Highlighting](https://gohugo.io/content-management/syntax-highlighting/)

#### 自定义菜单

```toml
Expand Down
6 changes: 0 additions & 6 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,13 @@
{{- end -}}

<script type="text/javascript">
//添加行号
(function () {
$("pre code").parent().addClass("line-numbers")
}());

window.MathJax = {
tex2jax: {
inlineMath: [['$', '$']],
processEscapes: true
}
};
</script>
<script type="text/javascript" src="{{ "js/prism.js" | relURL}}" async="true"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>
{{ end }}

Expand Down
3 changes: 0 additions & 3 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">

<link rel="stylesheet" href="{{ "css/normalize.css" | relURL}}">
{{ if .IsPage }}
<link rel="stylesheet" href="{{ "css/prism.css" | relURL }}">
{{ end }}
<link rel="stylesheet" href="{{ "css/style.css" | relURL }}">
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s+%s" href="%s" title="%s" />` .Rel .MediaType.Type .MediaType.Suffix .Permalink $.Site.Title | safeHTML }}
Expand Down
249 changes: 0 additions & 249 deletions static/css/prism.css

This file was deleted.

14 changes: 3 additions & 11 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ mark {
background: #fffdd1;
}
pre, code {
background:#f8f8f8;
font-family:Menlo, Monaco, Consolas, "Lucida Console", "Courier New", monospace;
font-size:.92857em;
}
pre {
margin: 2em 0;
overflow:auto;
border: 1px solid #ddd;
display: block;
Expand Down Expand Up @@ -374,17 +372,11 @@ textarea {
border-bottom: 1px solid #eee;
overflow: hidden;
}
/* .post-content pre, .comment-content pre {
max-height: 320px;
} */
.post-content pre, .comment-content pre {
padding: 1em 1.5em;
.post-content pre{
padding: 1em;
}
.post-content p code, .comment-content p code {
.post-content code{
display:inline;
margin:0 5px;
padding:3px 5px;
border: 1px solid #ddd;
}
.post-content p {
margin:0 0 1.1em;
Expand Down
Loading

0 comments on commit 65a1598

Please sign in to comment.