Jacky Zhao
2023-06-12 352075ae81a3304a7bfa2512ef69b1cdacb26c12
quartz/plugins/transformers/ofm.ts
@@ -89,19 +89,13 @@
  return s.substring(0, 1).toUpperCase() + s.substring(1);
}
export class ObsidianFlavoredMarkdown extends QuartzTransformerPlugin {
  name = "ObsidianFlavoredMarkdown"
  opts: Options
  constructor(opts?: Partial<Options>) {
    super()
    this.opts = { ...defaultOptions, ...opts }
  }
  markdownPlugins(): PluggableList {
export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => {
  const opts = { ...defaultOptions, ...userOpts }
  return {
    name: "ObsidianFlavoredMarkdown",
    markdownPlugins() {
    const plugins: PluggableList = []
    if (this.opts.wikilinks) {
      if (opts.wikilinks) {
      plugins.push(() => {
        // Match wikilinks 
        // !?               -> optional embedding
@@ -169,7 +163,7 @@
      )
    }
    if (this.opts.highlight) {
      if (opts.highlight) {
      plugins.push(() => {
        // Match highlights 
        const highlightRegex = new RegExp(/==(.+)==/, "g")
@@ -185,7 +179,7 @@
      })
    }
    if (this.opts.callouts) {
      if (opts.callouts) {
      plugins.push(() => {
        // from https://github.com/escwxyz/remark-obsidian-callout/blob/main/src/index.ts
        const calloutRegex = new RegExp(/^\[\!(\w+)\]([+-]?)/)
@@ -252,11 +246,11 @@
        }
      })
    }
    return plugins
  }
    },
  htmlPlugins(): PluggableList {
    htmlPlugins() {
    return [rehypeRaw]
  }
}
}