chore(emacs): add org.css for html export of org files 9de1e3c3
Steve · 2026-10-10 11:37 2 file(s) · +326 −0
emacs/lisp/init-tools.el +26 −0
85 85
           "* [[%^{URL}][%^{Title}]] %^g\n:PROPERTIES:\n:ADDED: %U\n:END:\n%?"
86 86
           :empty-lines 1))))
87 87
88 +
;; HTML export: darkmatter CSS from org.css, inlined so exports are self-contained
89 +
(use-package ox-html
90 +
  :ensure nil
91 +
  :after org
92 +
  :config
93 +
  (defun my/org-html-head ()
94 +
    "Return `org-html-head' contents with org.css inlined."
95 +
    (let ((css (expand-file-name "org.css" user-emacs-directory)))
96 +
      (concat "<meta name=\"theme-color\" content=\"#121113\" />\n"
97 +
              "<style>\n"
98 +
              (with-temp-buffer
99 +
                (insert-file-contents css)
100 +
                (buffer-string))
101 +
              "</style>")))
102 +
  (setq org-html-head-include-default-style nil
103 +
        org-html-head-include-scripts nil
104 +
        org-html-validation-link nil
105 +
        org-html-postamble nil
106 +
        org-html-htmlize-output-type 'css
107 +
        org-html-head (my/org-html-head))
108 +
  ;; Re-read org.css on each export so edits apply without restarting
109 +
  (advice-add 'org-html-export-as-html :before
110 +
              (lambda (&rest _) (setq org-html-head (my/org-html-head))))
111 +
  (advice-add 'org-html-export-to-html :before
112 +
              (lambda (&rest _) (setq org-html-head (my/org-html-head)))))
113 +
88 114
(use-package dired
89 115
  :ensure nil
90 116
  :custom
emacs/org.css (added) +300 −0
1 +
/* Darkmatter theme for org HTML export (inlined by init-tools.el) */
2 +
3 +
@font-face {
4 +
  font-family: "Commit Mono";
5 +
  src: local("Commit Mono"), local("CommitMono-400-Regular");
6 +
  font-weight: 400;
7 +
  font-style: normal;
8 +
}
9 +
10 +
@font-face {
11 +
  font-family: "Commit Mono";
12 +
  src: local("Commit Mono Bold"), local("CommitMono-700-Regular");
13 +
  font-weight: 700;
14 +
  font-style: normal;
15 +
}
16 +
17 +
* {
18 +
  padding: 0;
19 +
  margin: 0;
20 +
  box-sizing: border-box;
21 +
  font-family: "Commit Mono", monospace, sans-serif;
22 +
  scrollbar-width: none;
23 +
  -ms-overflow-style: none;
24 +
}
25 +
26 +
html {
27 +
  background: #121113;
28 +
  color: #ffffff;
29 +
  font-size: 14px;
30 +
  line-height: 1.6;
31 +
}
32 +
33 +
html::-webkit-scrollbar {
34 +
  display: none;
35 +
}
36 +
37 +
body {
38 +
  max-width: 700px;
39 +
  margin: auto;
40 +
  padding: 0 1rem 4rem;
41 +
}
42 +
43 +
@media (max-width: 480px) {
44 +
  body {
45 +
    padding: 1rem;
46 +
  }
47 +
}
48 +
49 +
a {
50 +
  color: #ffffff;
51 +
  text-decoration: none;
52 +
}
53 +
54 +
a:hover {
55 +
  opacity: 0.7;
56 +
}
57 +
58 +
#content {
59 +
  display: flex;
60 +
  flex-direction: column;
61 +
  gap: 1rem;
62 +
}
63 +
64 +
/* Title */
65 +
.title {
66 +
  margin-top: 2rem;
67 +
  padding-bottom: 1rem;
68 +
  border-bottom: 1px solid #333;
69 +
  font-size: 28px;
70 +
  font-weight: 700;
71 +
  text-transform: uppercase;
72 +
  text-align: left;
73 +
}
74 +
75 +
.subtitle {
76 +
  font-size: 12px;
77 +
  opacity: 0.5;
78 +
}
79 +
80 +
/* Headings */
81 +
h1, h2, h3, h4, h5, h6 {
82 +
  font-weight: 700;
83 +
}
84 +
85 +
h1 { font-size: 18px; }
86 +
h2 { font-size: 16px; margin-top: 1rem; }
87 +
h3 { font-size: 15px; }
88 +
h4, h5, h6 { font-size: 14px; }
89 +
90 +
.section-number-2,
91 +
.section-number-3,
92 +
.section-number-4 {
93 +
  opacity: 0.5;
94 +
}
95 +
96 +
.outline-2, .outline-3, .outline-4, .outline-text-2, .outline-text-3, .outline-text-4 {
97 +
  display: flex;
98 +
  flex-direction: column;
99 +
  gap: 0.75rem;
100 +
}
101 +
102 +
/* Text */
103 +
p, li {
104 +
  font-size: 14px;
105 +
}
106 +
107 +
ul, ol {
108 +
  padding-left: 1.5rem;
109 +
}
110 +
111 +
li + li {
112 +
  margin-top: 0.25rem;
113 +
}
114 +
115 +
b, strong { font-weight: 700; }
116 +
i, em { font-style: italic; }
117 +
del { opacity: 0.5; }
118 +
119 +
.timestamp, .timestamp-kwd, .timestamp-wrapper {
120 +
  font-size: 12px;
121 +
  opacity: 0.5;
122 +
}
123 +
124 +
.tag {
125 +
  font-size: 12px;
126 +
  opacity: 0.5;
127 +
  float: right;
128 +
}
129 +
130 +
.tag span {
131 +
  background: none;
132 +
  font-weight: 400;
133 +
}
134 +
135 +
/* TODO keywords: no color, weight/opacity only */
136 +
.todo, .done {
137 +
  font-size: 12px;
138 +
  font-weight: 700;
139 +
  text-transform: uppercase;
140 +
}
141 +
142 +
.done {
143 +
  opacity: 0.5;
144 +
}
145 +
146 +
/* Code */
147 +
code {
148 +
  background: #1e1c1f;
149 +
  padding: 0.1rem 0.3rem;
150 +
  font-size: 13px;
151 +
}
152 +
153 +
pre {
154 +
  background: #1e1c1f;
155 +
  color: #ffffff;
156 +
  border: none;
157 +
  border-radius: 0;
158 +
  box-shadow: none;
159 +
  padding: 0.75rem 1rem;
160 +
  font-size: 13px;
161 +
  overflow-x: auto;
162 +
  white-space: pre;
163 +
}
164 +
165 +
pre code {
166 +
  background: none;
167 +
  padding: 0;
168 +
}
169 +
170 +
pre.src:before {
171 +
  display: none;
172 +
}
173 +
174 +
/* htmlize classes (needs org-html-htmlize-output-type 'css) */
175 +
pre span[class^="org-"] {
176 +
  color: #ffffff;
177 +
  background: none;
178 +
  font-weight: 400;
179 +
  font-style: normal;
180 +
}
181 +
182 +
pre span.org-comment,
183 +
pre span.org-comment-delimiter,
184 +
pre span.org-doc {
185 +
  opacity: 0.5;
186 +
  font-style: italic;
187 +
}
188 +
189 +
pre span.org-keyword,
190 +
pre span.org-function-name,
191 +
pre span.org-type {
192 +
  font-weight: 700;
193 +
}
194 +
195 +
pre span.org-string {
196 +
  opacity: 0.7;
197 +
}
198 +
199 +
/* Blockquote */
200 +
blockquote {
201 +
  border-left: 2px solid #555;
202 +
  padding-left: 0.75rem;
203 +
  opacity: 0.7;
204 +
}
205 +
206 +
blockquote p {
207 +
  margin: 0;
208 +
}
209 +
210 +
/* Tables */
211 +
table {
212 +
  border-collapse: collapse;
213 +
  width: 100%;
214 +
  border: none;
215 +
}
216 +
217 +
table caption {
218 +
  font-size: 12px;
219 +
  opacity: 0.5;
220 +
  text-align: left;
221 +
  margin-bottom: 0.25rem;
222 +
}
223 +
224 +
th, td {
225 +
  padding: 0.4rem 0.75rem 0.4rem 0;
226 +
  border: none;
227 +
  border-bottom: 1px solid #333;
228 +
  text-align: left;
229 +
}
230 +
231 +
th {
232 +
  opacity: 0.5;
233 +
  font-weight: 400;
234 +
  font-size: 12px;
235 +
  text-transform: uppercase;
236 +
}
237 +
238 +
/* Misc */
239 +
hr {
240 +
  border: none;
241 +
  border-top: 1px solid #333;
242 +
}
243 +
244 +
img {
245 +
  max-width: 100%;
246 +
  border-radius: 0;
247 +
}
248 +
249 +
figure {
250 +
  display: flex;
251 +
  flex-direction: column;
252 +
  gap: 0.25rem;
253 +
}
254 +
255 +
figcaption, .figure-number {
256 +
  font-size: 12px;
257 +
  opacity: 0.5;
258 +
}
259 +
260 +
.footnotes, #footnotes {
261 +
  border-top: 1px solid #333;
262 +
  padding-top: 0.75rem;
263 +
  font-size: 12px;
264 +
}
265 +
266 +
.footdef {
267 +
  opacity: 0.7;
268 +
}
269 +
270 +
sup a, .footref {
271 +
  font-size: 12px;
272 +
}
273 +
274 +
/* TOC */
275 +
#table-of-contents {
276 +
  border-bottom: 1px solid #333;
277 +
  padding-bottom: 1rem;
278 +
}
279 +
280 +
#table-of-contents h2 {
281 +
  font-size: 12px;
282 +
  text-transform: uppercase;
283 +
  opacity: 0.5;
284 +
  margin-top: 0;
285 +
}
286 +
287 +
#text-table-of-contents ul {
288 +
  list-style: none;
289 +
  padding-left: 1rem;
290 +
}
291 +
292 +
#text-table-of-contents > ul {
293 +
  padding-left: 0;
294 +
}
295 +
296 +
/* Postamble */
297 +
#postamble, .postamble {
298 +
  font-size: 12px;
299 +
  opacity: 0.5;
300 +
}