Footnotes.h header

#include <ew/app/Footnotes.h>

Namespace ew::app

FootnoteEntry struct

struct ew::app::FootnoteEntry

One footnote/endnote reference resolved for display: its definition text paired with the number the reader sees. Numbering is a single sequence in order of first reference in the body (a note referenced more than once keeps its first number), shared by footnotes and endnotes alike so the editor and every export agree on the numbers; endnote is carried through for organising the notes and for placement in paginated output, not for a separate count.

Members

QString ew::app::FootnoteEntry::id

The note's stable id (matching its inline [^id] reference).

QString ew::app::FootnoteEntry::text

The note's content, as Markdown.

int ew::app::FootnoteEntry::number = 0

The reader-facing number, assigned by order of first reference (1-based).

bool ew::app::FootnoteEntry::endnote = false

Whether this note is an endnote (see ew::core::Footnote::endnote).

Functions

QString ew::app::appendFootnoteDefinitions(const QString &body, const std::vector< ew::core::Footnote > &definitions)

Appends Pandoc-style [^id]: text definition lines to body for every note referenced in it, in reference order, so the result is self-contained Markdown-with-footnotes ready for markdownToHtml or a Markdown file export. Unreferenced definitions are omitted. Returns body unchanged when it references no defined note.

QString ew::app::newFootnoteId(const std::vector< ew::core::Footnote > &existing)

Generates a footnote id not already used by existing (of the form "fn1", "fn2", ...). Stable and deterministic so it can be unit-tested and produces clean [^fnN] markers.

std::vector< FootnoteEntry > ew::app::orderFootnotes(const QString &body, const std::vector< ew::core::Footnote > &definitions)

Resolves definitions against the [^id] references in body, returning one entry per referenced and defined note in order of first appearance, each numbered in a single 1-based sequence. References with no matching definition are skipped (they render literally); definitions never referenced in the body are omitted – use unreferencedFootnotes to find those. A note referenced several times appears once, keeping its first number.

QString ew::app::stripFootnoteSyntax(const QString &text)

Removes footnote syntax from text: whole [^id]: ... definition lines and inline [^id] references. Used by export formats that cannot yet render footnotes (Word, standard-manuscript RTF) so a marker never leaks into their output as literal text.

std::vector< ew::core::Footnote > ew::app::unreferencedFootnotes(const QString &body, const std::vector< ew::core::Footnote > &definitions)

Returns the definitions that are never referenced by a [^id] marker in body, in their given order – the "orphan" notes a writer may have detached or not yet placed. Useful for surfacing them in the notes UI so they are not silently lost.