From b3480bdc49120010da8d2805df02cbf84ca08bdc Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Fri, 07 Jul 2023 02:18:18 +0000
Subject: [PATCH] fix styling for bullet points
---
quartz/processors/parse.ts | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/quartz/processors/parse.ts b/quartz/processors/parse.ts
index f937701..170e964 100644
--- a/quartz/processors/parse.ts
+++ b/quartz/processors/parse.ts
@@ -21,8 +21,8 @@
let processor = unified().use(remarkParse)
// MD AST -> MD AST transforms
- for (const plugin of transformers) {
- processor = processor.use(plugin.markdownPlugins())
+ for (const plugin of transformers.filter(p => p.markdownPlugins)) {
+ processor = processor.use(plugin.markdownPlugins!())
}
// MD AST -> HTML AST
@@ -30,8 +30,8 @@
// HTML AST -> HTML AST transforms
- for (const plugin of transformers) {
- processor = processor.use(plugin.htmlPlugins())
+ for (const plugin of transformers.filter(p => p.htmlPlugins)) {
+ processor = processor.use(plugin.htmlPlugins!())
}
return processor
@@ -73,13 +73,21 @@
})
}
-export function createFileParser(baseDir: string, fps: string[], verbose: boolean) {
+export function createFileParser(transformers: QuartzTransformerPluginInstance[], baseDir: string, fps: string[], verbose: boolean) {
return async (processor: QuartzProcessor) => {
const res: ProcessedContent[] = []
for (const fp of fps) {
try {
const file = await read(fp)
+ // strip leading and trailing whitespace
+ file.value = file.value.toString().trim()
+
+ // Text -> Text transforms
+ for (const plugin of transformers.filter(p => p.textTransform)) {
+ file.value = plugin.textTransform!(file.value)
+ }
+
// base data properties that plugins may use
file.data.slug = slugify(path.relative(baseDir, file.path))
file.data.filePath = fp
@@ -111,9 +119,8 @@
log.start(`Parsing input files using ${concurrency} threads`)
if (concurrency === 1) {
- // single-thread
const processor = createProcessor(transformers)
- const parse = createFileParser(baseDir, fps, verbose)
+ const parse = createFileParser(transformers, baseDir, fps, verbose)
res = await parse(processor)
} else {
await transpileWorkerScript()
--
Gitblit v1.10.0