element, we want to also replace the parent
+ const parent = element.parentElement;
+ if (parent && parent.tagName === "PRE") {
+ parent.replaceWith(div.firstChild!);
+ } else {
+ element.replaceWith(div.firstChild!);
+ }
+ } catch (cause) {
+ log.error(
+ `[katex plugin] Failed to render math in ${page.outputPath}: ${cause}`,
+ );
+ }
+ });
+
+ if (options.options.delimiters) {
+ try {
+ renderMathInElement(document.body, options.options);
+ } catch (cause) {
+ log.error(
+ `[katex plugin] Failed to render math in ${page.outputPath}: ${cause}`,
+ );
+ }
+ }
+ }
+ });
+ };
+}
+
+export default katex;
diff --git a/_plugins/remark-alerts.ts b/_plugins/remark-alerts.ts
new file mode 100644
index 0000000..6bc7921
--- /dev/null
+++ b/_plugins/remark-alerts.ts
@@ -0,0 +1,172 @@
+/*
+ * Based on https://github.com/hyoban/remark-github-alerts by Stephen Zhou (hyoban), MIT licensed.
+ */
+
+import type { Paragraph, Root, Html } from "npm:@types/mdast";
+import type { Plugin } from "npm:unified";
+import { visit } from "npm:unist-util-visit";
+
+export type RemarkGitHubAlertsOptions = {
+ /**
+ * List of markers to match.
+ * @default ['TIP', 'NOTE', 'IMPORTANT', 'WARNING', 'CAUTION']
+ */
+ markers?: string[] | '*'
+
+ /**
+ * If markers case sensitively on matching.
+ * @default false
+ */
+ matchCaseSensitive?: boolean
+
+ /**
+ * Custom icons for each marker. The key is the marker name, and the value is the html script represent the icon.
+ * The key is always lowercase.
+ *
+ * @default inline svg icons from GitHub
+ */
+ icons?: Record
+
+ /**
+ * Custom titles for each marker. The key is the marker name, and the value is the title.
+ * The key is always lowercase.
+ *
+ * When the title is not specified, the default title is the capitalized marker name.
+ */
+ titles?: Record
+
+ /**
+ * Prefix for the class names.
+ *
+ * @default 'markdown-alert'
+ */
+ classPrefix?: string
+
+ // ^ options from MarkdownItGitHubAlertsOptions
+
+ /**
+ * Whether to ignore the square brackets in the marker.
+ *
+ * @default false
+ */
+ ignoreSquareBracket?: boolean
+}
+
+function capitalize(str: string) {
+ return str.charAt(0).toUpperCase() + str.slice(1)
+}
+
+const DEFAULT_GITHUB_ICONS = {
+ note: '',
+ tip: '',
+ important: '',
+ warning: '',
+ caution: '',
+}
+
+// https://bl.ocks.org/jennyknuth/222825e315d45a738ed9d6e04c7a88d0
+function encodeSvg(svg: string) {
+ return svg.replace('