From 0da5767319e3635ac5de919c3ee4b839983a0c79 Mon Sep 17 00:00:00 2001 From: Viktor Kronvall Date: Sat, 2 Dec 2023 09:30:14 +0900 Subject: [PATCH] docs: fix syntax highlighting `document-highlighter` now outputs a `` block inside the pre-formatted `
` tag. This changes the required CSS for
rendering code snippets. Moreover, this commit uses the highlightjs
as provided by the `document-highlighter` package instead of the
version packaged in `nmd`.
---
 docs/highlight-style.css     | 8 ++++++++
 docs/home-manager-manual.nix | 9 ++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)
 create mode 100644 docs/highlight-style.css

diff --git a/docs/highlight-style.css b/docs/highlight-style.css
new file mode 100644
index 000000000..0b360281c
--- /dev/null
+++ b/docs/highlight-style.css
@@ -0,0 +1,8 @@
+pre {
+  padding: 0;
+}
+
+pre code.hljs {
+  border: none;
+  margin: 0;
+}
diff --git a/docs/home-manager-manual.nix b/docs/home-manager-manual.nix
index 1a4521e41..903456ecf 100644
--- a/docs/home-manager-manual.nix
+++ b/docs/home-manager-manual.nix
@@ -32,14 +32,17 @@ in stdenv.mkDerivation {
       --replace \
         '@OPTIONS_JSON@' \
         ${home-manager-options.nix-darwin}/share/doc/nixos/options.json
+    cp -t out/highlightjs ${nmd}/static/highlightjs/tomorrow-night.min.css
+    cp ${./highlight-style.css} out/highlightjs/highlight-style.css
 
     nixos-render-docs manual html \
       --manpage-urls ./manpage-urls.json \
       --revision ${lib.trivial.revisionWithDefault revision} \
       --stylesheet ${nmd}/static/style.css \
-      --stylesheet ${nmd}/static/highlightjs/tomorrow-night.min.css \
-      --script ${nmd}/static/highlightjs/highlight.min.js \
-      --script ${nmd}/static/highlightjs/highlight.load.js \
+      --stylesheet $out/share/doc/home-manager/highlightjs/tomorrow-night.min.css \
+      --stylesheet $out/share/doc/home-manager/highlightjs/highlight-style.css \
+      --script $out/share/doc/home-manager/highlightjs/highlight.pack.js \
+      --script $out/share/doc/home-manager/highlightjs/loader.js \
       --toc-depth 1 \
       --section-toc-depth 1 \
       manual.md \