Pointfold separates source structure, rendering, and browser interactions.
outline.goparses and validates a tree of points.render.goturns that tree into HTML with embedded assets.web/reader.jshandles copying, navigation, and global expansion controls.
The CLI validates input before replacing an output file.
runreads a path or standard input.parseOutlineproduces the point model [3] or an error.renderOutlinebuilds the entire HTML result in memory.atomicWritewrites a temporary file before renaming it over the destination.- This sequence prevents a parsing failure from truncating an existing output.
- A path check also prevents overwriting the input through the same path or a filesystem alias.
Every point has one text field and a list of child points.
Textholds the point's Markdown.StableIDholds optional source identity.Numberholds a position such as2.1.3in this document version.Linepoints back to the source file for diagnostics and therefscommand.Childrenholds points with the same structure.Markdownretains the point's own source text and visual blocks for copying without its children.Contentholds visual blocks that appear when the point is expanded.
Parsing builds the tree before checking its cross-references.
- Goldmark parses the Markdown into a syntax tree.
parseListcollects points and rejects unsupported block structures.- A trailing
{#stable-id}is removed from point text and registered inByID. A second pass rejects fragment links whose targets were never registered.
- Waiting until the second pass permits a point to refer to a later point.
- Duplicate stable IDs fail before link resolution can become ambiguous.
Rendering keeps stable identity separate from visible position.
linkRendererresolves a source link throughByID.- The generated link points to the target's current numbered HTML anchor.
- Its label gains the target's current outline number.
- A copy button exposes that outline number without exposing the source ID.
Browser navigation reveals a target by opening only its ancestors.
- The click handler records the source point for the return button.
revealwalks from the target toward the document root.- Every ancestor
detailselement is opened. - The target's own children retain their previous expansion state.
- The target is highlighted and receives focus.
A moved point retains its source identity when its stable ID is preserved.
- Re-rendering updates links to its new number through reference resolution [4].
- A previously copied outline number still belongs to the older document version.
- An agent should inspect the current source or the
refsoutput before acting on a reference from another version.