-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathline-numbers.html
86 lines (78 loc) · 2.46 KB
/
line-numbers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/styles/solarized-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/highlightjs-line-numbers.min.js"></script>
<script src="./highlightjs-highlight-lines.js"></script>
<script>
hljs.highlightAll();
hljs.initLineNumbersOnLoad();
hljs.highlightLinesAll([
[{start: 2, end: 4, color: '#555'}, {start: 7, end: 7, color: 'yellow'},],
[{start: 3, end: 4, color: 'rgba(255, 255, 255, 0.2)'},],
[{start: 3, end: 5, color: 'blue'},],
]);
</script>
<style>
/* for block of numbers */
td.hljs-ln-numbers {
text-align: center;
color: #ccc;
border-right: 1px solid #999;
vertical-align: top;
padding-right: 5px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
td.hljs-ln-code {
padding-left: 10px;
}
code {
white-space: pre-wrap;
overflow: auto;
}
</style>
</head>
<body>
<h1>highlightjs-highlight-lines.js Examples with <a href="https://github.com/wcoder/highlightjs-line-numbers.js/">highlightjs-line-numbers.js</a></h1>
<h2>Example 1</h2>
<pre>
<code>#include <stdio.h>
void print_text(char[] text) {
printf("%s\n", text);
}
int main() {
printf("hoge\n");
print_text("foobar");
return 0;
}</code>
</pre>
<h2>Example 2 (using transparency)</h2>
<pre>
<code># coding: utf-8
def main():
print('hoge')
if __name__ == '__main__':
main()</code>
</pre>
<h2>Example 3 (scroll)</h2>
<div style="width: 100px;">
<pre>
<code>#include <iostream>
auto main() -> int {
using namespace std;
cout << "this is too long sentence......" << endl;
return 0;
}
</code>
</pre>
</div>
</body>
</html>