Skip to content

Commit d1c5ccd

Browse files
committed
Merge commit '2f110c6f52b48bcc44bfd3acd0c53ad44a34ebea'
2 parents 3290ea6 + 2f110c6 commit d1c5ccd

File tree

5 files changed

+55
-8
lines changed

5 files changed

+55
-8
lines changed

Diff for: CodeStyle/Plugin.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @package CodeStyle
66
* @author hongweipeng
7-
* @version 0.7.1
7+
* @version 0.8.0
88
* @link https://www.hongweipeng.com
99
*/
1010
class CodeStyle_Plugin implements Typecho_Plugin_Interface {
@@ -43,6 +43,8 @@ public static function config(Typecho_Widget_Helper_Form $form){
4343
$styles = array_combine($styles, $styles);
4444
$name = new Typecho_Widget_Helper_Form_Element_Select('code_style', $styles, 'segmentfault.css', _t('选择你的代码风格'));
4545
$form->addInput($name->addRule('enum', _t('必须选择配色样式'), $styles));
46+
$showLineNumber = new Typecho_Widget_Helper_Form_Element_Checkbox('showln', array('showln' => _t('显示行号')), array('showln'), _t('是否在代码左侧显示行号'));
47+
$form->addInput($showLineNumber);
4648

4749
/*$jq_import = new Typecho_Widget_Helper_Form_Element_Radio('jq_import', array(
4850
0 => _t('不引入'),
@@ -79,6 +81,9 @@ public static function header() {
7981
$style = Helper::options()->plugin('CodeStyle')->code_style;
8082
$cssUrl = Helper::options()->pluginUrl . '/CodeStyle/markdown/styles/' . $style;
8183
echo '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" />';
84+
if (Helper::options()->plugin('CodeStyle')->showln) {
85+
echo '<link rel="stylesheet" type="text/css" href="' . Helper::options()->pluginUrl. '/CodeStyle/markdown/highlightjs-line.css" />';
86+
}
8287
}
8388

8489
/**
@@ -87,11 +92,22 @@ public static function header() {
8792
*/
8893
public static function footer() {
8994
$jsUrl = Helper::options()->pluginUrl . '/CodeStyle/markdown/highlight.pack.js';
95+
$lineUrl = Helper::options()->pluginUrl . '/CodeStyle/markdown/highlightjs-line-numbers.min.js';
96+
$showIn = Helper::options()->plugin('CodeStyle')->showln;
9097
echo <<<HTML
9198
<script type="text/javascript" src="{$jsUrl}"></script>
9299
<script type="text/javascript">
93100
hljs.initHighlightingOnLoad();
94101
</script>
95102
HTML;
103+
if ($showIn) {
104+
echo <<<HTML
105+
<script type="text/javascript" src="{$lineUrl}"></script>
106+
<script type="text/javascript">
107+
hljs.initLineNumbersOnLoad();
108+
</script>
109+
HTML;
110+
111+
}
96112
}
97113
}

Diff for: CodeStyle/README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 起步
22

3-
代码展示样式,将highlightjs制作为typecho插件形式
3+
代码展示样式,[highlightjs][4] 制作为typecho插件形式
44

55
## 使用方法
66

@@ -19,5 +19,12 @@ github开源地址:[https://github.com/hongweipeng/CodeStyle_for_typecho][1]
1919
或者通过 Emai: [email protected]
2020
有任何问题也可评论留言
2121

22+
## 感谢
23+
代码行显示支持:
24+
25+
[https://github.com/wcoder/highlightjs-line-numbers.js][3]
26+
2227
[1]: https://github.com/hongweipeng/MenuTree_for_typecho
23-
[2]: https://www.hongweipeng.com/
28+
[2]: https://www.hongweipeng.com/
29+
[3]: https://github.com/wcoder/highlightjs-line-numbers.js
30+
[4]: https://highlightjs.org/

Diff for: CodeStyle/markdown/highlightjs-line-numbers.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: CodeStyle/markdown/highlightjs-line.css

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
.hljs td.hljs-ln-numbers {
3+
-webkit-touch-callout: none;
4+
-webkit-user-select: none;
5+
-khtml-user-select: none;
6+
-moz-user-select: none;
7+
-ms-user-select: none;
8+
user-select: none;
9+
10+
text-align: right;
11+
color: #ccc;
12+
border-top: none;
13+
border-bottom: none;
14+
border-left: none;
15+
border-right: 1px solid #CCC;
16+
vertical-align: top;
17+
word-break: normal;
18+
word-wrap: normal;
19+
padding: 0 5px 0 0;
20+
width: 20px;
21+
/* your custom style here */
22+
}
23+
24+
/* for block of code */
25+
.hljs td.hljs-ln-code {
26+
padding: 0 0 0 8px;
27+
border: none;
28+
}

Diff for: CodeStyle/markdown/styles/segmentfault.css

-5
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,4 @@ pre {
5252

5353
.tex .hljs-formula {
5454
background: #eee8d5
55-
}/*!
56-
* Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome
57-
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
58-
*/@font-face {
59-
font-family:FontAwesome;src:url(../../3rd/fontawesome/fonts/fontawesome-webfont.eot?v=4.3.0);src:url(../../3rd/fontawesome/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0) format('embedded-opentype'),url(../../3rd/fontawesome/fonts/fontawesome-webfont.woff2?v=4.3.0) format('woff2'),url(../../3rd/fontawesome/fonts/fontawesome-webfont.woff?v=4.3.0) format('woff'),url(../../3rd/fontawesome/fonts/fontawesome-webfont.ttf?v=4.3.0) format('truetype'),url(../../3rd/fontawesome/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular) format('svg');font-weight:400;font-style:normal
6055
}

0 commit comments

Comments
 (0)