From afb33e26a68b59907e39d449a220b5b8a53037c0 Mon Sep 17 00:00:00 2001 From: Stephen Donahue Date: Sun, 28 Jun 2026 01:20:01 +0000 Subject: [PATCH] Fix column overflow and render math with KaTeX - minmax(0,1fr)+min-width:0 and pre-wrap so a long fenced line no longer blows out the grid - build-time KaTeX via @vscode/markdown-it-katex; ship katex CSS+fonts and link in layouts --- .eleventy.js | 12 ++++++++++++ _includes/base.njk | 1 + _includes/column.njk | 1 + css/style.css | 11 ++++++++++- package.json | 4 +++- yarn.lock | 26 ++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 0e65e05..9ca6496 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,5 +1,6 @@ const Image = require("@11ty/eleventy-img"); const path = require("path"); +const markdownItKatex = require("@vscode/markdown-it-katex").default; function imageShortcode(src, alt, sizes = "100vw") { const inputPath = path.join("img", src); @@ -54,6 +55,17 @@ module.exports = function (eleventyConfig) { eleventyConfig.addPassthroughCopy("img"); eleventyConfig.addPassthroughCopy("favicon.svg"); + // KaTeX: render $$...$$ at build time into static markup. Ship katex.min.css + // plus its fonts/ as a sibling so the stylesheet's url(fonts/...) resolves. + eleventyConfig.addPassthroughCopy({ + "node_modules/katex/dist/katex.min.css": "css/katex.min.css", + "node_modules/katex/dist/fonts": "css/fonts", + }); + + eleventyConfig.amendLibrary("md", (md) => { + md.use(markdownItKatex, { throwOnError: false, errorColor: "#cc0000" }); + }); + eleventyConfig.addShortcode("image", imageShortcode); eleventyConfig.addShortcode("heroImage", heroImageShortcode); diff --git a/_includes/base.njk b/_includes/base.njk index 00ad2ca..07f0f60 100644 --- a/_includes/base.njk +++ b/_includes/base.njk @@ -6,6 +6,7 @@ {% if title %}{{ title }} — un:prompted{% else %}un:prompted{% endif %} +