Skip to main content

Module parser

Module parser 

Source
Expand description

Structural parser for nb notes, todos, and bookmarks.

Defines NoteDocument — the canonical byte-range partition for any source file produced or accepted by nb 7.24.0 — plus the DocumentKind, TodoState, ParseContext, and accessor types required by the add-note-document-model (P1) specification.

Permissive acceptance is the contract: parse succeeds for every input that can be losslessly partitioned into a NoteDocument, including the frozen W1 and E1-E11 noncanonical forms. The only refusal cases at the parse layer are [ParseErrorKind::MissingTitle] for Todo/Bookmark files with no non-blank line. Notes are permissive on empty source.

Mandatory-title/URL/state enforcement belongs to a separate canonical validator (P5+), not to the parser. Operation boundaries (do/undo for Todo) enforce checkbox state at the operation level, not the parse level.

Format dispatch (R3 revision) precedes byte parsing on ParseContext::FromPath. Files whose final filename matches a recognized-but-unsupported dotted suffix (e.g., .org, .latex, .tex, .adoc, .asciidoc) are rejected with NbError::UnsupportedDocumentFormat before any byte parsing runs. The list of supported extensions lives in the public constant SUPPORTED_DOCUMENT_EXTENSIONS.

Structs§

BodyFragments
Iterator over body byte ranges.
NoteDocument
A parsed nb note, todo, or bookmark.
TagsIter
Iterator over tag token byte slices.
TagsStrIter
Iterator over tag token string slices, surfacing UTF-8 errors.

Enums§

DocumentKind
Distinguishes the three document kinds recognized by the parser.
ParseContext
How the parser determines the DocumentKind for an input.
TodoState
The parsed checkbox state of a Todo title.

Constants§

SUPPORTED_DOCUMENT_EXTENSIONS
Source-of-truth list of supported document extensions for format dispatch. The constant is declared in the parser module and re-exported at the crate root as nb_api::SUPPORTED_DOCUMENT_EXTENSIONS per the spec.

Functions§

parse
Parse bytes into a NoteDocument.