Jacky Zhao
2023-08-12 83269ac26e41f8e81b56e000b4347ee60d4ff84b
quartz/plugins/transformers/ofm.ts
@@ -96,7 +96,7 @@
function canonicalizeCallout(calloutName: string): keyof typeof callouts {
  let callout = calloutName.toLowerCase() as keyof typeof calloutMapping
  return calloutMapping[callout]
  return calloutMapping[callout] ?? calloutName
}
const capitalize = (s: string): string => {
@@ -115,7 +115,7 @@
const calloutRegex = new RegExp(/^\[\!(\w+)\]([+-]?)/)
// (?:^| )   -> non-capturing group, tag should start be separated by a space or be the start of the line
// #(\w+)    -> tag itself is # followed by a string of alpha-numeric characters
const tagRegex = new RegExp(/(?:^| )#(\w+)/, "g")
const tagRegex = new RegExp(/(?:^| )#([\w-_\/]+)/, "g")
export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = (
  userOpts,
@@ -225,7 +225,6 @@
              }
              // internal link
              // const url = transformInternalLink(fp + anchor)
              const url = fp + anchor
              return {
                type: "link",
@@ -414,12 +413,16 @@
        js.push({
          script: `
          import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
          const darkMode = document.documentElement.getAttribute('saved-theme') === 'dark'
          mermaid.initialize({
            startOnLoad: false,
            securityLevel: 'loose',
            theme: darkMode ? 'dark' : 'default'
          });
          document.addEventListener('nav', async () => {
            const darkMode = document.documentElement.getAttribute('saved-theme') === 'dark'
            mermaid.initialize({
              securityLevel: 'loose',
              theme: darkMode ? 'dark' : 'default'
            });
            await mermaid.run({
              querySelector: '.mermaid'
            })
          });
          `,
          loadTime: "afterDOMReady",