-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
113 lines (85 loc) · 3.16 KB
/
index.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<style>
/* override badge styling */
.code-badge {
background: #555 !important;
padding: 8px !important;
}
.code-badge-copy-icon {
font-size: 1.3em !important;
}
</style>
</head>
<body>
<div class="container">
<h1>HighlightJS Code Copying</h1>
<hr>
<h3 class="mt-3">Single line code snippet</h3>
<pre><code class="hljs language-js">let x = 1;
x++;</code></pre>
<h3 class="mt-3">Single line code snippet</h3>
<pre><code class="hljs lang-js">public static string GetChecksumFromFile(string file)
{
if (!File.Exists(file))
return null;
try
{
byte[] checkSum;
using (FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var md = new MD5CryptoServiceProvider();
checkSum = md.ComputeHash(stream);
}
return StringUtils.BinaryToBinHex(checkSum);
}
catch
{
return null;
}
}</code></pre>
<h3>Plain Text</h3>
<pre><code class="hljs lang-txt">This should be treated as just plain text
It shows as is, without any formatting</code></pre>
<h3>Auto-Detected</h3>
<pre><code>Content-Type: text/html
Accept: application/json
Content-Length: 12332
</code></pre>
</div>
<link href="highlightJS/styles/vs2015.css" rel="stylesheet">
<script src="highlightJs/highlight.pack.js"></script>
<script src="highlightjs-badge.js"></script>
<script>
setTimeout(function () {
var pres = document.querySelectorAll("pre>code");
for (var i = 0; i < pres.length; i++) {
hljs.highlightBlock(pres[i]);
}
var options = {
contentSelector: ".container",
// Delay in ms used for `setTimeout` before badging is applied
// Use if you need to time highlighting and badge application
// since the badges need to be applied afterwards.
// 0 - direct execution (ie. you handle timing
loadDelay:0,
// CSS class(es) used to render the copy icon.
copyIconClass: "fa fa-copy",
// CSS class(es) used to render the done icon.
checkIconClass: "fa fa-check text-success",
// intercept text copying - passed in text return text out
onBeforeCodeCopied: function(text) {
text = "$$$ " + text;
return text;
}
};
window.highlightJsBadge(options);
},10);
</script>
</body>
</html>