mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-07-13 02:41:00 +02:00
prettier
This commit is contained in:
parent
aae897a0d5
commit
eaac39444a
@ -220,19 +220,27 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
if (opts.inlineFootnotes) {
|
if (opts.inlineFootnotes) {
|
||||||
// Replaces ^[inline] footnotes with regular footnotes [^1]:
|
// Replaces ^[inline] footnotes with regular footnotes [^1]:
|
||||||
const footnotes: Record<string, string> = {}
|
const footnotes: Record<string, string> = {}
|
||||||
|
|
||||||
// Replace inline footnotes with references and collect definitions
|
// Replace inline footnotes with references and collect definitions
|
||||||
const result = (src as string).replace(inlineFootnoteRegex, (_match: string, content: string) => {
|
const result = (src as string).replace(
|
||||||
const id = `inline-${Math.random().toString(36).substring(2, 8)}`
|
inlineFootnoteRegex,
|
||||||
footnotes[id] = content.trim()
|
(_match: string, content: string) => {
|
||||||
return `[^${id}]`
|
const id = `inline-${Math.random().toString(36).substring(2, 8)}`
|
||||||
})
|
footnotes[id] = content.trim()
|
||||||
|
return `[^${id}]`
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// Append footnote definitions if we found any
|
// Append footnote definitions if we found any
|
||||||
if (Object.keys(footnotes).length > 0) {
|
if (Object.keys(footnotes).length > 0) {
|
||||||
return result + "\n\n" + Object.entries(footnotes)
|
return (
|
||||||
.map(([id, content]) => `[^${id}]: ${content}`)
|
result +
|
||||||
.join("\n") + "\n"
|
"\n\n" +
|
||||||
|
Object.entries(footnotes)
|
||||||
|
.map(([id, content]) => `[^${id}]: ${content}`)
|
||||||
|
.join("\n") +
|
||||||
|
"\n"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user