Skip to content

Commit ff90c5f

Browse files
committed
separate comrak styling
1 parent b0b35a2 commit ff90c5f

File tree

7 files changed

+211
-304
lines changed

7 files changed

+211
-304
lines changed

build_css.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,22 @@ const reset =
3333
await $`deno run -A npm:[email protected] --input src/html/templates/pages/reset.css`
3434
.bytes();
3535
const resetFinal = transform({
36-
filename: "./page.css",
36+
filename: "./reset.css",
3737
code: reset,
3838
minify: true,
3939
targets: browserslistToTargets(browsers),
4040
analyzeDependencies: false,
4141
});
4242
await Deno.writeFile("src/html/templates/pages/reset.gen.css", resetFinal.code);
43+
44+
const comrak =
45+
await $`deno run -A npm:[email protected] --input src/html/templates/comrak.css`
46+
.bytes();
47+
const comrakFinal = transform({
48+
filename: "./comrak.css",
49+
code: comrak,
50+
minify: true,
51+
targets: browserslistToTargets(browsers),
52+
analyzeDependencies: false,
53+
});
54+
await Deno.writeFile("src/html/templates/comrak.gen.css", comrakFinal.code);

src/html/comrak.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ use std::io::Write;
1111
use std::rc::Rc;
1212
use std::sync::Arc;
1313

14+
pub const COMRAK_STYLESHEET: &str = include_str!("./templates/comrak.gen.css");
15+
pub const COMRAK_STYLESHEET_FILENAME: &str = "comrak.css";
16+
1417
pub type URLRewriter =
1518
Arc<dyn (Fn(Option<&ShortPath>, &str) -> String) + Send + Sync>;
1619

src/html/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,11 @@ pub fn generate(
996996
files.insert(RESET_STYLESHEET_FILENAME.into(), RESET_STYLESHEET.into());
997997
files.insert(FUSE_FILENAME.into(), FUSE_JS.into());
998998
files.insert(SEARCH_FILENAME.into(), SEARCH_JS.into());
999+
#[cfg(feature = "comrak")]
1000+
files.insert(
1001+
comrak::COMRAK_STYLESHEET_FILENAME.into(),
1002+
comrak::COMRAK_STYLESHEET.into(),
1003+
);
9991004

10001005
Ok(files)
10011006
}

src/html/templates/comrak.css

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
.link {
2+
@apply text-blue-600 transition duration-75;
3+
}
4+
5+
.link:hover {
6+
@apply text-blue-400;
7+
}
8+
9+
.markdown_summary, .markdown {
10+
a:not(.no_color) {
11+
@apply link;
12+
}
13+
}
14+
15+
.markdown_summary {
16+
@apply inline text-stone-600;
17+
18+
p {
19+
@apply inline-block line-clamp-4;
20+
}
21+
22+
:not(pre) > code {
23+
@apply font-mono text-sm py-0.5 px-1.5 rounded bg-stone-200;
24+
}
25+
}
26+
27+
.markdown {
28+
@apply space-y-3 shrink min-w-0 max-w-[40ch] sm:max-w-screen-sm
29+
md:max-w-screen-md lg:max-w-[75ch];
30+
31+
h1 {
32+
@apply text-xl md:text-2xl lg:text-3xl border-b border-stone-300 pb-1;
33+
}
34+
35+
h2 {
36+
@apply text-lg md:text-xl lg:text-2xl border-b border-stone-300 pb-1;
37+
}
38+
39+
h3 {
40+
@apply font-bold md:text-lg md:font-normal lg:text-xl lg:font-normal;
41+
}
42+
43+
h4 {
44+
@apply font-semibold md:font-bold lg:text-lg lg:font-normal;
45+
}
46+
47+
h5 {
48+
@apply italic md:font-semibold lg:font-bold;
49+
}
50+
51+
h6 {
52+
@apply md:italic lg:font-semibold;
53+
}
54+
55+
hr {
56+
@apply m-2 border-stone-500;
57+
}
58+
59+
ol, ul {
60+
@apply list-outside ml-4;
61+
}
62+
63+
ol {
64+
@apply list-decimal;
65+
}
66+
67+
ul {
68+
@apply list-disc;
69+
}
70+
71+
/* Inline code */
72+
73+
:not(pre) > code {
74+
@apply font-mono text-sm py-0.5 px-1.5 rounded-md bg-stone-200;
75+
}
76+
77+
h1, h2, h3, h4, h5, h6 {
78+
& > code {
79+
font-size: inherit !important;
80+
}
81+
}
82+
83+
pre {
84+
@apply font-mono text-sm text-black bg-slate-50 border-t-1.5 border-b-1.5
85+
border-slate-300 -mx-4 rounded-none md:rounded-md md:border-1.5 md:mx-0;
86+
87+
& > code:first-child {
88+
@apply overflow-x-auto px-6 py-4 block;
89+
}
90+
}
91+
92+
p {
93+
@apply my-1 mx-0;
94+
}
95+
96+
table {
97+
@apply block table-auto overflow-auto w-max max-w-full;
98+
}
99+
100+
td {
101+
@apply p-2;
102+
}
103+
104+
th {
105+
@apply font-bold text-center py-1.5;
106+
}
107+
108+
th, td {
109+
@apply border-1.5 border-slate-300;
110+
}
111+
112+
tr:nth-child(2n) {
113+
@apply bg-slate-50;
114+
}
115+
116+
img {
117+
display: inline-block;
118+
}
119+
120+
.alert {
121+
@apply py-4 px-6 border-2 space-y-2 rounded-lg;
122+
123+
div:first-child {
124+
@apply font-medium flex items-center gap-1.5;
125+
126+
svg {
127+
@apply size-5;
128+
}
129+
}
130+
}
131+
132+
.alert-note {
133+
@apply border-blue-600 bg-blue-600/5;
134+
135+
div:first-child {
136+
@apply text-blue-600 stroke-blue-600;
137+
}
138+
}
139+
140+
.alert-tip {
141+
@apply border-green-600 bg-green-600/5;
142+
143+
div:first-child {
144+
@apply text-green-600 stroke-green-600;
145+
}
146+
}
147+
148+
.alert-important {
149+
@apply border-purple-600 bg-purple-600/5;
150+
151+
div:first-child {
152+
@apply text-purple-600 stroke-purple-600;
153+
}
154+
}
155+
156+
.alert-warning {
157+
@apply border-yellow-600 bg-yellow-600/5;
158+
159+
div:first-child {
160+
@apply text-yellow-600 stroke-yellow-600;
161+
}
162+
}
163+
164+
.alert-caution {
165+
@apply border-red-600 bg-red-600/5;
166+
167+
div:first-child {
168+
@apply text-red-600 stroke-red-600;
169+
}
170+
}
171+
}
172+
173+
.markdown .highlight {
174+
@apply relative;
175+
176+
.lineNumbers {
177+
@apply border-r-2 border-stone-300 pr-1 text-right flex-none;
178+
}
179+
180+
.context_button {
181+
@apply absolute top-3 right-4 opacity-60 hover:opacity-100;
182+
}
183+
}

src/html/templates/comrak.gen.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)