(** Org — OCaml Org Mode parser library. This is the top-level module for the [org] library. It re-exports the public API and sub-modules, providing a convenient namespace for consumers: {[ let doc = Org.parse input let headings = doc.Org.Ast.headings ]} *) (** {1 Public sub-modules} *) module Ast = Ast module Config = Config (** {1 Internal sub-modules} These are exposed for testing and advanced use. They are not part of the stable public API and may change without notice. *) (**/**) module Private = struct module Lexer = Lexer module Inline_lexer = Inline_lexer module Parse = Parse module Parser = Parser module Token = Token module Raw_ast = Raw_ast module Prescan = Prescan end (**/**) (** {1 Parsing entry points} *) let version = "0.1.0" (** Parse an Org Mode document string into a semantic AST. This is the primary entry point. It: 1. Pre-scans for file-local declarations (#+TODO etc.) 2. Lexes the input into structural tokens 3. Parses tokens into a raw document tree (Menhir) 4. Normalizes the raw tree into the semantic AST Malformed input degrades gracefully — the parser always produces a best-effort document without raising exceptions for syntax errors. @param config Optional document configuration. When omitted, the input is pre-scanned for #+TODO declarations automatically. *) let parse ?config input = let config = match config with Some c -> c | None -> Prescan.scan input in let raw = Parse.document ~config input in Normalize.normalize config raw