From d613a3d2f2f1cfa77bdc592c17882e260e2cea17 Mon Sep 17 00:00:00 2001
From: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 26 Aug 2024 21:13:09 +0000
Subject: [PATCH] chore(deps): bump unified from 11.0.4 to 11.0.5 (#1373)

---
 quartz/plugins/transformers/syntax.ts |   47 +++++++++++++++++++++++++----------------------
 1 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/quartz/plugins/transformers/syntax.ts b/quartz/plugins/transformers/syntax.ts
index f09daaa..5d3aae0 100644
--- a/quartz/plugins/transformers/syntax.ts
+++ b/quartz/plugins/transformers/syntax.ts
@@ -1,28 +1,31 @@
-import { PluggableList } from "unified"
 import { QuartzTransformerPlugin } from "../types"
-import rehypePrettyCode, { Options as CodeOptions } from "rehype-pretty-code"
+import rehypePrettyCode, { Options as CodeOptions, Theme as CodeTheme } from "rehype-pretty-code"
 
-export class SyntaxHighlighting extends QuartzTransformerPlugin {
-  name = "SyntaxHighlighting"
+interface Theme extends Record<string, CodeTheme> {
+  light: CodeTheme
+  dark: CodeTheme
+}
 
-  markdownPlugins(): PluggableList {
-    return []
-  }
+interface Options {
+  theme?: Theme
+  keepBackground?: boolean
+}
 
-  htmlPlugins(): PluggableList {
-    return [[rehypePrettyCode, {
-      theme: 'css-variables',
-      onVisitLine(node) {
-        if (node.children.length === 0) {
-          node.children = [{ type: 'text', value: ' ' }]
-        }
-      },
-      onVisitHighlightedLine(node) {
-        node.properties.className.push('highlighted')
-      },
-      onVisitHighlightedWord(node) {
-        node.properties.className = ['word']
-      },
-    } satisfies Partial<CodeOptions>]]
+const defaultOptions: Options = {
+  theme: {
+    light: "github-light",
+    dark: "github-dark",
+  },
+  keepBackground: false,
+}
+
+export const SyntaxHighlighting: QuartzTransformerPlugin<Partial<Options>> = (userOpts) => {
+  const opts: CodeOptions = { ...defaultOptions, ...userOpts }
+
+  return {
+    name: "SyntaxHighlighting",
+    htmlPlugins() {
+      return [[rehypePrettyCode, opts]]
+    },
   }
 }

--
Gitblit v1.10.0