Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoer committed Feb 21, 2025
1 parent aae897a commit eaac394
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions quartz/plugins/transformers/ofm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,27 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
if (opts.inlineFootnotes) {
// Replaces ^[inline] footnotes with regular footnotes [^1]:
const footnotes: Record<string, string> = {}

// Replace inline footnotes with references and collect definitions
const result = (src as string).replace(inlineFootnoteRegex, (_match: string, content: string) => {
const id = `inline-${Math.random().toString(36).substring(2, 8)}`
footnotes[id] = content.trim()
return `[^${id}]`
})
const result = (src as string).replace(
inlineFootnoteRegex,
(_match: string, content: string) => {
const id = `inline-${Math.random().toString(36).substring(2, 8)}`
footnotes[id] = content.trim()
return `[^${id}]`
},
)

// Append footnote definitions if we found any
if (Object.keys(footnotes).length > 0) {
return result + "\n\n" + Object.entries(footnotes)
.map(([id, content]) => `[^${id}]: ${content}`)
.join("\n") + "\n"
return (
result +
"\n\n" +
Object.entries(footnotes)
.map(([id, content]) => `[^${id}]: ${content}`)
.join("\n") +
"\n"
)
}

return result
Expand Down

0 comments on commit eaac394

Please sign in to comment.