Skip to content

Commit f07aa5f

Browse files
authored
Merge pull request #275 from andrewbranch/post/symbols
Shikiji
2 parents 82c4ae0 + aea4c4e commit f07aa5f

File tree

5 files changed

+161
-396
lines changed

5 files changed

+161
-396
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

+17-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");
55
const eleventyImage = require("@11ty/eleventy-img");
66
const getImageSize = require("image-size").default;
77
const anchor = require("markdown-it-anchor").default;
8-
const { loadTheme } = require("shiki");
9-
const shikiMarkdown = require("markdown-it-shiki").default;
108
const faviconsPlugin = require("eleventy-plugin-gen-favicons");
119
const pluginRss = require("@11ty/eleventy-plugin-rss");
1210
const markdownIt = require("markdown-it");
11+
const { readFile } = require("fs/promises");
1312
const md = markdownIt({
1413
html: true,
1514
});
@@ -122,18 +121,29 @@ module.exports = (eleventyConfig) => {
122121

123122
eleventyConfig.setLibrary("md", md);
124123
eleventyConfig.amendLibrary("md", async (/** @type {import("markdown-it")} */ md) => {
125-
const theme = await loadTheme(path.join(__dirname, "dark_modern.json"));
124+
const { getHighlighter } = await import("shikiji");
125+
const { fromHighlighter } = await import("markdown-it-shikiji/core");
126+
const { transformerNotationDiff } = await import("shikiji-transformers");
127+
const highlighter = await getHighlighter({
128+
langAlias: { kdl: "KDL" },
129+
});
130+
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"));
132+
await highlighter.loadTheme(theme);
133+
await highlighter.loadLanguage("css", kdl, "js", "json", "shell", "tsx", "typescript");
126134
md.use(require("markdown-it-footnote"));
127135
md.use(require("@ryanxcharles/markdown-it-katex"));
128136
md.use(anchor, {
129137
permalink: anchor.permalink.headerLink({
130138
class: "no-underline",
131139
}),
132140
});
133-
md.use(shikiMarkdown, {
134-
theme,
135-
useBackground: true,
136-
});
141+
md.use(
142+
fromHighlighter(highlighter, {
143+
theme: "dark-modern",
144+
transformers: [transformerNotationDiff()],
145+
}),
146+
);
137147
});
138148

139149
eleventyConfig.addPlugin(faviconsPlugin, {

0 commit comments

Comments
 (0)