From efd46f84de2d8dcc630b96de5454027bfbbf5f6e Mon Sep 17 00:00:00 2001
From: Eiko Wagenknecht <git@eiko-wagenknecht.de>
Date: Mon, 19 Feb 2024 08:08:36 +0000
Subject: [PATCH] fix(frontmatter): delimiters parameter was not passed (#885)
---
quartz/processors/parse.ts | 54 +++++++++++++++++++++++++++---------------------------
1 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/quartz/processors/parse.ts b/quartz/processors/parse.ts
index 299d59a..3950fee 100644
--- a/quartz/processors/parse.ts
+++ b/quartz/processors/parse.ts
@@ -5,36 +5,34 @@
import { Root as MDRoot } from "remark-parse/lib"
import { Root as HTMLRoot } from "hast"
import { ProcessedContent } from "../plugins/vfile"
-import { PerfTimer } from "../perf"
+import { PerfTimer } from "../util/perf"
import { read } from "to-vfile"
-import { FilePath, QUARTZ, slugifyFilePath } from "../path"
+import { FilePath, QUARTZ, slugifyFilePath } from "../util/path"
import path from "path"
import workerpool, { Promise as WorkerPromise } from "workerpool"
-import { QuartzLogger } from "../log"
-import { trace } from "../trace"
-import { BuildCtx } from "../ctx"
+import { QuartzLogger } from "../util/log"
+import { trace } from "../util/trace"
+import { BuildCtx } from "../util/ctx"
-export type QuartzProcessor = Processor<MDRoot, HTMLRoot, void>
+export type QuartzProcessor = Processor<MDRoot, MDRoot, HTMLRoot>
export function createProcessor(ctx: BuildCtx): QuartzProcessor {
const transformers = ctx.cfg.plugins.transformers
- // base Markdown -> MD AST
- let processor = unified().use(remarkParse)
-
- // MD AST -> MD AST transforms
- for (const plugin of transformers.filter((p) => p.markdownPlugins)) {
- processor = processor.use(plugin.markdownPlugins!(ctx))
- }
-
- // MD AST -> HTML AST
- processor = processor.use(remarkRehype, { allowDangerousHtml: true })
-
- // HTML AST -> HTML AST transforms
- for (const plugin of transformers.filter((p) => p.htmlPlugins)) {
- processor = processor.use(plugin.htmlPlugins!(ctx))
- }
-
- return processor
+ return (
+ unified()
+ // base Markdown -> MD AST
+ .use(remarkParse)
+ // MD AST -> MD AST transforms
+ .use(
+ transformers
+ .filter((p) => p.markdownPlugins)
+ .flatMap((plugin) => plugin.markdownPlugins!(ctx)),
+ )
+ // MD AST -> HTML AST
+ .use(remarkRehype, { allowDangerousHtml: true })
+ // HTML AST -> HTML AST transforms
+ .use(transformers.filter((p) => p.htmlPlugins).flatMap((plugin) => plugin.htmlPlugins!(ctx)))
+ )
}
function* chunks<T>(arr: T[], n: number) {
@@ -89,12 +87,13 @@
// Text -> Text transforms
for (const plugin of cfg.plugins.transformers.filter((p) => p.textTransform)) {
- file.value = plugin.textTransform!(ctx, file.value)
+ file.value = plugin.textTransform!(ctx, file.value.toString())
}
// base data properties that plugins may use
- file.data.slug = slugifyFilePath(path.posix.relative(argv.directory, file.path) as FilePath)
- file.data.filePath = fp
+ file.data.filePath = file.path as FilePath
+ file.data.relativePath = path.posix.relative(argv.directory, file.path) as FilePath
+ file.data.slug = slugifyFilePath(file.data.relativePath)
const ast = processor.parse(file)
const newAst = await processor.run(ast, file)
@@ -112,7 +111,8 @@
}
}
-const clamp = (num: number, min: number, max: number) => Math.min(Math.max(Math.round(num), min), max);
+const clamp = (num: number, min: number, max: number) =>
+ Math.min(Math.max(Math.round(num), min), max)
export async function parseMarkdown(ctx: BuildCtx, fps: FilePath[]): Promise<ProcessedContent[]> {
const { argv } = ctx
const perf = new PerfTimer()
--
Gitblit v1.10.0