Skip to content

Commit f2fbd5b

Browse files
committed
feat: introduce "themes/prism.css"
1 parent b761c68 commit f2fbd5b

File tree

3 files changed

+99
-3
lines changed

3 files changed

+99
-3
lines changed

index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>👓</text></svg>" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>&lt;syntax-highlight&gt; element</title>
8-
<link rel="stylesheet" href="/src/themes/prism.css">
8+
<link rel="stylesheet" href="/src/themes/prettylights.css">
99
<style>
1010
body {
1111
display: flex;
1212
flex-direction: column;
1313
gap: 1.5rem;
1414
}
1515

16-
syntax-highlight:not([data-inline]) {
16+
syntax-highlight {
1717
display: block;
1818
border-radius: 0.25rem;
1919
padding: 1rem;

src/themes/prism.css

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
@import "theme-defaults.css" layer(syntax-highlight-element);
2+
3+
/**
4+
* Source: https://github.com/PrismJS/prism/blob/master/themes/prism.css
5+
*/
6+
7+
@layer syntax-highlight-element {
8+
syntax-highlight {
9+
color: black;
10+
background: #f5f2f0;
11+
text-shadow: 0 1px white;
12+
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
13+
line-height: 1.5;
14+
}
15+
16+
@media print {
17+
syntax-highlight {
18+
text-shadow: none;
19+
}
20+
}
21+
22+
::highlight(comment),
23+
::highlight(prolog),
24+
::highlight(doctype),
25+
::highlight(cdata) {
26+
color: slategray;
27+
}
28+
29+
::highlight(punctuation) {
30+
color: #999;
31+
}
32+
33+
::highlight(namespace) {
34+
opacity: 0.7;
35+
}
36+
37+
::highlight(property),
38+
::highlight(tag),
39+
::highlight(boolean),
40+
::highlight(number),
41+
::highlight(constant),
42+
::highlight(symbol),
43+
::highlight(deleted) {
44+
color: #905;
45+
}
46+
47+
::highlight(selector),
48+
::highlight(attr-name),
49+
::highlight(string),
50+
::highlight(char),
51+
::highlight(builtin),
52+
::highlight(inserted) {
53+
color: #690;
54+
}
55+
56+
::highlight(operator),
57+
::highlight(entity),
58+
::highlight(url),
59+
::highlight(css-string) {
60+
color: #9a6e3a;
61+
/* This background color was intended by the author of this theme. */
62+
background: hsla(0, 0%, 100%, 0.5);
63+
}
64+
65+
::highlight(atrule),
66+
::highlight(attr-value),
67+
::highlight(keyword) {
68+
color: #07a;
69+
}
70+
71+
::highlight(function),
72+
::highlight(class-name) {
73+
color: #dd4a68;
74+
}
75+
76+
::highlight(regex),
77+
::highlight(important),
78+
::highlight(variable) {
79+
color: #e90;
80+
}
81+
82+
::highlight(important),
83+
::highlight(bold) {
84+
font-weight: bold;
85+
}
86+
::highlight(italic) {
87+
font-style: italic;
88+
}
89+
90+
::highlight(entity) {
91+
cursor: help;
92+
}
93+
}

vite.themes.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { defineConfig } from 'vite';
44

55
const __dirname = dirname(fileURLToPath(import.meta.url));
66

7-
const themes = [resolve(__dirname, 'src/themes/prettylights.css')];
7+
const themes = [
8+
resolve(__dirname, 'src/themes/prettylights.css'),
9+
resolve(__dirname, 'src/themes/prism.css'),
10+
];
811

912
export default defineConfig({
1013
build: {

0 commit comments

Comments
 (0)