mirror of
https://github.com/alrayyes/wiki.git
synced 2025-05-01 14:38:14 +00:00
fix: parsing wikilinks that have codeblock anchors, scroll to anchor
This commit is contained in:
parent
fd5c8d17d3
commit
24348b24a9
16 changed files with 99 additions and 80 deletions
quartz/processors
|
@ -21,8 +21,8 @@ export function createProcessor(transformers: QuartzTransformerPluginInstance[])
|
|||
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 @@ export function createProcessor(transformers: QuartzTransformerPluginInstance[])
|
|||
|
||||
|
||||
// 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,18 @@ async function transpileWorkerScript() {
|
|||
})
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
// 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 +116,8 @@ export async function parseMarkdown(transformers: QuartzTransformerPluginInstanc
|
|||
|
||||
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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue