mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 23:04:05 -06:00
Updated parsers with new typing
This commit is contained in:
parent
c3f1695595
commit
50bbc82e73
@ -1,5 +1,6 @@
|
||||
import { QuartzTransformerPlugin } from "../../types"
|
||||
import { QuartzParserPlugin } from "../../types"
|
||||
import { ReplaceFunction, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace"
|
||||
import { JSResource } from "../../../util/resources"
|
||||
import { SKIP } from "unist-util-visit"
|
||||
import { Root } from "mdast"
|
||||
import { PluggableList } from "unified"
|
||||
@ -25,10 +26,16 @@ const arrowMapping: Record<string, string> = {
|
||||
|
||||
const arrowRegex = new RegExp(/(-{1,2}>|={1,2}>|<-{1,2}|<={1,2})/g)
|
||||
|
||||
export const ObsidianArrow: QuartzTransformerPlugin<Partial<Options>> = (userOpts) => {
|
||||
export const ObsidianArrow: QuartzParserPlugin<Partial<Options>> = (userOpts) => {
|
||||
const opts: Options = { ...defaultOptions, ...userOpts }
|
||||
return {
|
||||
name: "ObsidianArrow",
|
||||
textTransform(_ctx, src: string | Buffer) {
|
||||
if (src instanceof Buffer) {
|
||||
src = src.toString()
|
||||
}
|
||||
return src
|
||||
},
|
||||
markdownPlugins(_ctx) {
|
||||
return [
|
||||
(tree: Root) => {
|
||||
@ -50,5 +57,12 @@ export const ObsidianArrow: QuartzTransformerPlugin<Partial<Options>> = (userOpt
|
||||
},
|
||||
] as PluggableList
|
||||
},
|
||||
htmlPlugins(_ctx) {
|
||||
return [] as PluggableList
|
||||
},
|
||||
externalResources(_ctx) {
|
||||
const js = [] as JSResource[]
|
||||
return { js }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { QuartzTransformerPlugin } from "../../types"
|
||||
import { QuartzParserPlugin } from "../../types"
|
||||
import { ReplaceFunction, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace"
|
||||
import { JSResource } from "../../../util/resources"
|
||||
import { Root } from "mdast"
|
||||
import { PluggableList } from "unified"
|
||||
|
||||
@ -13,11 +14,17 @@ const defaultOptions: Options = {
|
||||
|
||||
const highlightRegex = new RegExp(/==([^=]+)==/g)
|
||||
|
||||
export const ObsidianHighlights: QuartzTransformerPlugin<Partial<Options>> = (userOpts) => {
|
||||
export const ObsidianHighlights: QuartzParserPlugin<Partial<Options>> = (userOpts) => {
|
||||
const opts: Options = { ...defaultOptions, ...userOpts }
|
||||
return {
|
||||
name: "ObsidianHighlights",
|
||||
markdownPlugins(ctx) {
|
||||
textTransform(_ctx, src: string | Buffer) {
|
||||
if (src instanceof Buffer) {
|
||||
src = src.toString()
|
||||
}
|
||||
return src
|
||||
},
|
||||
markdownPlugins(_ctx) {
|
||||
return [
|
||||
(tree: Root) => {
|
||||
if (opts.enabled) {
|
||||
@ -37,5 +44,12 @@ export const ObsidianHighlights: QuartzTransformerPlugin<Partial<Options>> = (us
|
||||
},
|
||||
] as PluggableList
|
||||
},
|
||||
htmlPlugins(_ctx) {
|
||||
return [] as PluggableList
|
||||
},
|
||||
externalResources(_ctx) {
|
||||
const js = [] as JSResource[]
|
||||
return { js }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { QuartzTransformerPlugin } from "../../types"
|
||||
import { QuartzParserPlugin } from "../../types"
|
||||
import { ReplaceFunction, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace"
|
||||
import { FilePath, splitAnchor, slugifyFilePath } from "../../../util/path"
|
||||
import { JSResource } from "../../../util/resources"
|
||||
import { Root } from "mdast"
|
||||
import { PluggableList } from "unified"
|
||||
|
||||
@ -35,7 +36,7 @@ const wikilinkImageEmbedRegex = new RegExp(
|
||||
/^(?<alt>(?!^\d*x?\d*$).*?)?(\|?\s*?(?<width>\d+)(x(?<height>\d+))?)?$/,
|
||||
)
|
||||
|
||||
export const ObsidianWikilinks: QuartzTransformerPlugin<Partial<Options>> = (userOpts) => {
|
||||
export const ObsidianWikilinks: QuartzParserPlugin<Partial<Options>> = (userOpts) => {
|
||||
const opts: Options = { ...defaultOptions, ...userOpts }
|
||||
return {
|
||||
name: "ObsidianWikilinks",
|
||||
@ -160,5 +161,12 @@ export const ObsidianWikilinks: QuartzTransformerPlugin<Partial<Options>> = (use
|
||||
},
|
||||
] as PluggableList
|
||||
},
|
||||
htmlPlugins(_ctx) {
|
||||
return [] as PluggableList
|
||||
},
|
||||
externalResources(_ctx) {
|
||||
const js = [] as JSResource[]
|
||||
return { js }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user