-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.html
More file actions
70 lines (62 loc) · 1.86 KB
/
demo.html
File metadata and controls
70 lines (62 loc) · 1.86 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Highlighting Example</title>
<!-- Include highlight.js stylesheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/atom-one-dark.min.css">
<!-- Include your custom styles if needed -->
<style>
/* Custom styles go here */
body {
background-color: #2d2d2d; /* Dark background color */
color: #abb2bf; /* Text color */
}
pre {
background-color: #2d2d2d; /* Dark background color */
border-radius: 10px;
padding: 20px;
color: inherit; /* Inherit text color from body */
}
</style>
</head>
<body>
<h1>Code Highlighting Example</h1>
<h2>Python Code</h2>
<pre><code id="pythonSnippet" class="python">
def greet(name):
# This function greets the user
print("Hello, {}!".format(name))
# Example usage
user_name = "Alice"
greet(user_name)
</code></pre>
<h2>JavaScript Code</h2>
<pre><code id="javascriptSnippet" class="javascript">
function greet(name) {
// This function greets the user
console.log("Hello, " + name + "!");
}
// Example usage
var user_name = "Bob";
greet(user_name);
</code></pre>
<h2>C++ Code</h2>
<pre><code id="cppSnippet" class="cpp">
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
</code></pre>
<!-- Include highlight.js library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
<script>
// Initialize highlight.js for each code snippet
hljs.highlightBlock(document.getElementById('pythonSnippet'));
hljs.highlightBlock(document.getElementById('javascriptSnippet'));
hljs.highlightBlock(document.getElementById('cppSnippet'));
</script>
</body>
</html>