Footnotes

  • packages/engine-server/src/markdown/remark/hierarchies.ts
transformer {

    if (insideNoteRef) {
        addFootNotes
    }

}

addFootNotes {
    footnotes := rootNode
    usedFootnotes = []

    visit(root, FOOTNOTE_REFERENCE) {
        (ref, parent, idx) => {
            def = footnotes[ref.id]
            if (def && parent) {
                parent.children[idx] = footnote2html(ref)
                usedFootnotes.add ref
            }
        }
    }

    if usedFootnotes {
        root.children.push breakLine
        root.children.push header("Footnotes")
        root.children.push usedFootnotes
    }
}

Prs