Skip to content

Commit aea4c4e

Browse files
committed
Add kdl syntax highlighting and diff transformer
1 parent f274eaf commit aea4c4e

File tree

5 files changed

+65
-154
lines changed

5 files changed

+65
-154
lines changed

.vscode/settings.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3-
"editor.formatOnSave": true,
43
"editor.defaultFormatter": "esbenp.prettier-vscode",
5-
"editor.tabSize": 2
4+
"editor.tabSize": 2,
5+
"editor.formatOnSave": true,
6+
"[markdown]": {
7+
"editor.formatOnSave": false
8+
}
69
}

content/styles/main.css

+31-3
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,20 @@ blockquote {
234234
pre {
235235
line-height: var(--rhythm);
236236
font-size: 0.75rem;
237-
padding: calc(var(--rhythm) * 0.5rem);
238237
border-radius: calc(var(--rhythm) * 0.25rem);
239238
overflow: auto;
239+
padding: calc(var(--rhythm) * 0.5rem) 0;
240+
}
241+
pre code .line {
242+
display: inline-block;
243+
width: 100%;
244+
padding: 0 calc(var(--rhythm) * 0.5rem);
245+
}
246+
pre code .line:last-child {
247+
display: none; /* shikiji is adding a blank line at the end for some reason */
248+
}
249+
pre code .line.diff.add {
250+
background-color: rgb(150 255 100 / 0.15);
240251
}
241252

242253
.post-body ol,
@@ -288,15 +299,32 @@ figcaption {
288299
display: inline;
289300
font-size: 0.9rem;
290301
}
302+
303+
.post-body ol {
304+
list-style-type: decimal;
305+
}
306+
.post-body ol ol {
307+
margin: 0 0 0 calc(var(--rhythm) * 0.8rem);
308+
list-style-type: lower-alpha;
309+
}
310+
.post-body ol ol ol {
311+
list-style-type: lower-roman;
312+
}
313+
.post-body ol ol ol ol {
314+
list-style-type: lower-greek;
315+
}
316+
.post-body ol ol li {
317+
margin-bottom: 0;
318+
}
291319
/* #endregion */
292320

293321
/* #endregion */
294322

295323
/* #region: inlines */
296324
code {
297325
font-family: var(--font-mono);
298-
font-variant-ligatures: "none";
299-
font-feature-settings: "normal";
326+
font-variant-ligatures: none;
327+
font-feature-settings: normal;
300328
}
301329

302330
:not(pre) > code {

eleventy.config.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,14 @@ module.exports = (eleventyConfig) => {
123123
eleventyConfig.amendLibrary("md", async (/** @type {import("markdown-it")} */ md) => {
124124
const { getHighlighter } = await import("shikiji");
125125
const { fromHighlighter } = await import("markdown-it-shikiji/core");
126-
const highlighter = await getHighlighter();
126+
const { transformerNotationDiff } = await import("shikiji-transformers");
127+
const highlighter = await getHighlighter({
128+
langAlias: { kdl: "KDL" },
129+
});
127130
const theme = JSON.parse(await readFile(path.join(__dirname, "dark_modern.json"), "utf8"));
131+
const kdl = JSON.parse(await readFile(require.resolve("kdl/syntaxes/kdl.tmLanguage.json"), "utf8"));
128132
await highlighter.loadTheme(theme);
129-
await highlighter.loadLanguage("css", "js", "json", "shell", "tsx", "typescript");
133+
await highlighter.loadLanguage("css", kdl, "js", "json", "shell", "tsx", "typescript");
130134
md.use(require("markdown-it-footnote"));
131135
md.use(require("@ryanxcharles/markdown-it-katex"));
132136
md.use(anchor, {
@@ -137,6 +141,7 @@ module.exports = (eleventyConfig) => {
137141
md.use(
138142
fromHighlighter(highlighter, {
139143
theme: "dark-modern",
144+
transformers: [transformerNotationDiff()],
140145
}),
141146
);
142147
});

package-lock.json

+20-147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626
"eleventy-plugin-gen-favicons": "^1.1.2",
2727
"image-size": "*",
2828
"katex": "^0.16.9",
29+
"kdl": "github:kdl-org/vscode-kdl",
2930
"markdown-it": "^13.0.2",
3031
"markdown-it-anchor": "^8.6.7",
3132
"markdown-it-footnote": "^3.0.3",
3233
"markdown-it-shikiji": "^0.9.11",
3334
"npm-run-all": "^4.1.5",
3435
"prettier": "^3.0.3",
3536
"shikiji": "^0.9.11",
37+
"shikiji-transformers": "^0.9.11",
3638
"unocss": "^0.57.2"
3739
}
3840
}

0 commit comments

Comments
 (0)