# Customizing Eleventy Syntax Highlighting with Line Numbers and MicroLighter

DevFeed: [Customizing Eleventy Syntax Highlighting with Line Numbers and MicroLighter](<https://devfeed.tech/articles/from-prismjs-to-better-prismjs-to-microlighter-in-three-painless-steps-55718.md>)

Original publisher: [Read original article](<https://infrequently.org/2026/09/microlighter/>)

Author: Alex Russell

Published: 2026-09-20T00:00:00Z

Content type: article

Language: en

Sources: [Alex Russell](<https://devfeed.tech/sources/alex-russell.md>)

Topics: [Eleventy](<https://devfeed.tech/topics/eleventy.md>), [Highlight.js](<https://devfeed.tech/topics/highlightjs.md>), [Syntax Highlighting](<https://devfeed.tech/topics/syntax-highlighting.md>), [MkDocs](<https://devfeed.tech/topics/mkdocs.md>), [CSS](<https://devfeed.tech/topics/css.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Nunjucks](<https://devfeed.tech/topics/nunjucks.md>)

Tags: [11ty](<https://devfeed.tech/tags/11ty.md>), [css](<https://devfeed.tech/tags/css.md>), [eleventy](<https://devfeed.tech/tags/eleventy.md>), [js](<https://devfeed.tech/tags/js.md>), [markdown](<https://devfeed.tech/tags/markdown.md>), [syntax-highlighting](<https://devfeed.tech/tags/syntax-highlighting.md>), [webdev](<https://devfeed.tech/tags/webdev.md>)

## AI overview

An Eleventy-focused article compares PrismJS syntax highlighting with a custom shortcode approach for adding line numbers and considers MicroLighter as an alternative for improved markup and highlighting behavior.

## Source excerpt

An excellent feature of Eleventy1 is the official PrismJS-based syntax highlighting plugin, which adds painless build-time syntax highlighting. It keeps 11ty sites from worrying about client-side bloat from JS-based highlighters and the common failure mode of over-including language definitions.2 But nothing's perfect. Contents Lilliputian Adventures In Line Numbering Greener Pastures The official plugin integrates naturally, and I took to using it via the usual triple-backtick markdown syntax: # The Usual Markdown Nonsense { #the-usual-nonsense } And now for something entirely different: ```js function yourCodeHere() { /* ... */ } ``` Etc., etc. This works a treat, until you want a bit more control. At that point, what seems magical starts to feel restrictive. Lilliputian Adventures In Line Numbering A recent goal was to add line numbers. After reading some of the plugin code that invokes PrismJS, I closed my laptop in frustration, unable to cajole eleventy-plugin-syntaxhighlight into outputting line numbers. Walking away from the keyboard paid off a few days later when I recalled the paired shortcode code path generated stable per-line delimiters. This allowed reuse of the plugin's primary logic, wrapped in a bit of string munging to add the necessary styling hooks: // From this site's Eleventy config file // Because my esm conversion is still partial: const { default: syntaxHighlight } = await import("@11ty/eleventy-plugin-syntaxhighlight"); // ... module.exports = async function(config) { // ... let syntaxHighlightOptions = { // For faster CSS selectors preAttributes: { highlighted: "highlighted" }, codeAttributes: { highlighted: "highlighted" }, }; config.addPlugin(syntaxHighlight, syntaxHighlightOptions); config.addPairedShortcode("code", function(content, language="", highlightLines="") { // The design of cssMin and addToBundle are outside // the scope of this post. // // Suffice to say, we're inlining the contents // of the file path passed as an argument to