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_METADATAheading 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 noGDOC_METADATAsection yet. - upsert_
keyword - Set
#+KEY: valuein the body region.