paperspec0.1.0

3. Nodes

A document is a tree of nodes. nodes.jsonl holds one node per line, in document order: the root first, then each node before its children, and siblings in order.

3.1 The node record#

PropertyRequiredHolds
idYesThe node ID (4).
kindYesOne of the kinds in 3.2.
parentYesThe parent's ID, or null for the root.
ordYesThe position among its siblings, from 0.
labelNoThe printed label (2.3, Figure 2, (1), a), for kinds that take one.
attrsNoStructural attributes, by kind (3.4).
contentNoThe node's own content, by kind (3.3).
withheldNotrue when the policy withholds the content (12.5).
fidelityNoFor leaves, the level the pipeline established: F0, F1 or F2 (8.1).
provNo{witnesses, backend?, reading?, corroborated_by?}: the witness IDs the text came from, the backend, and the witnesses that agree.
text_hash, match_hash, align_key, own_hash, node_hashYesThe five content values (5).

Optional properties are omitted, never written as null. The schema is node.schema.json.

3.2 Kinds and children#

KindMay containContentLabel
documentfront, section, back
fronttitle, authors, abstract, keywords, notes
titlesentence
authorsruns
abstractblocks, section
keywordsruns
notesfootnote, paragraph
sectionheading first, then blocks and sectionYes
headingsentence
paragraphsentence
sentenceequationruns
equationequation-linemathYes
equation-linemathYes
figurepanel, caption, figure-noteYes
panelYes
captionsentence
figure-notesentence
tablecaption, table-head, table-body, table-noteYes
table-head, table-bodyrow
table-notesentence
rowcell
cellruns
listitem
item, quoteblocks
code, algorithmverbatimYes
theoremblocksYes
footnotesentenceYes
backacknowledgments, references, appendix, notes
acknowledgmentsblocks
referencesreference
referencerunsYes
appendixsection

Blocks are paragraph, equation, figure, table, list, quote, code, algorithm, theorem and footnote.

These rules also hold:

  1. Exactly one node is a root, and it is a document.
  2. A heading is a section's first child, and a section has at most one.
  3. front, back, title, authors, abstract, keywords, caption, table-head, table-body, acknowledgments and references occur at most once among their siblings.
  4. A table has exactly one table-body.
  5. title, heading, paragraph, caption, figure-note, table-note, table-head, table-body, row, list, item, quote, theorem, footnote and appendix have at least one child.
  6. Only the kinds marked in the table take a label.
  7. A body without headings, as in a letter, is a section with no heading.

Kinds outside this list are refused; a new kind is a minor version. Page breaks, running heads and columns are not nodes: they are geometry (7).

3.3 Content#

ContentKindsShape
Runssentence, cell, reference, authors, keywordsA non-empty list of inline runs (3.5).
Mathequation, equation-line{notation, source}: tex or typst, and the source as written.
Verbatimcode, algorithm{language?, text}.

Other kinds have no content. Derived renderings, such as MathML, are not content; they live in derived/ (12.7).

3.4 Attributes#

KindAttributeHolds
sectionlevel (required)1 for a section, 2 for a subsection, and so on.
tablecolumnsThe column definitions: [{id, header_path}], where header_path lists header cell IDs, outermost first (9.2).
cellcolumn, rowspan, colspan, roleThe column's ID, spans (default 1), and data (default), column-header, row-header or row-group-header.
rowheader_pathThe cell IDs that label the row, outermost first.
listorderedWhether the list is numbered.
itemmarkerThe printed marker.
theoremvariantThe printed kind: Theorem, Lemma, Definition, Proof, Remark.
panelimage, crop, figure_textThe image asset, a crop, and the text found inside the panel (9.1).

No other kind carries attrs, and each kind carries only its own attributes.

3.5 Inline runs#

RunPropertiesPlain projection
texttext, and optional style: a sorted list of distinct values from em, strong, sup, sub, sc, mono, never both sup and sub.The text.
mathnotation (tex or typst), source.$ + source + $
citerefs: reference node IDs; text: the printed form, such as 23, [1,2] or (Smith, 2019).The printed form.
xreftarget: a node ID in this document, an address in another, or null when not yet resolved; text.The printed form.
fnmarkfootnote: a footnote's ID, or null; text: the mark.The mark.
linkurl, text.The text.
equationnode: the ID of an equation child of the sentence.$$ + that equation's source + $$

Runs are canonical: no text run is empty, and no two adjacent text runs have the same style list. A sentence's equation runs name its equation children, each once, in the children's order, and a sentence has no other children. A display equation the sentence runs through is thus part of the sentence, while keeping its own ID and hashes.

3.6 The plain projection#

The plain projection of a node with runs is the concatenation of its runs' projections. That of an equation or an equation line is $$ + source + $$, and that of a verbatim node is its text. That of any other node is the plain projections of its text leaves joined with one U+0020.

A node's text leaves are found by walking its subtree in document order and stopping at sentence, cell, reference, authors, keywords, code and algorithm nodes, and at equation nodes whose parent is not a sentence; an equation-line is never a text leaf.

Offsets, quotations and the text hash are all defined on the plain projection as stored, before normalization.

Source: spec/03-nodes.md · raw