Skip to main content

Module orgfile

Module orgfile 

Source
Expand description

Two-region model of a synced org file: the user’s body and the tool-owned machine region, split at the * GDOC_METADATA heading.

Every function here is a pure, total transformation of file text. The body (everything before the boundary) is preserved byte-for-byte by construction (domain invariant DI-2): writeback only ever rewrites a single #+KEYWORD: line or the metadata tail. The only sanctioned body mutation — inserting a :CUSTOM_ID: property — lives in crate::project (P2), not here.

#+KEYWORD: matching is case-insensitive, as org keywords are.

Constants§

METADATA_HEADING
Level-1 heading, sans tags, that begins the tool-owned machine region.

Functions§

body
The user-owned body region (everything before the machine region).
metadata_boundary
Byte offset where the GDOC_METADATA heading begins, if the file has one.
read_keyword
Extract the value of a #+KEY: keyword from the body region, if present.
replace_metadata
Replace the machine region with region, preserving every body byte.
split
Split into (body, Some(machine_region)), or (whole_text, None) when the file has no GDOC_METADATA section yet.
upsert_keyword
Set #+KEY: value in the body region.