(** Public semantic AST types for Org Mode documents. This module defines the strongly-typed abstract syntax tree produced by parsing an Org Mode document. The types are designed to be semantic: they represent the meaning of Org constructs rather than their exact surface syntax. The AST is read-only and uses closed variants for known constructs. *) (** {1 Inline objects} *) (** A link target. *) type link_target = | Url of string | File of string | Internal of string | Protocol of string * string (** {1 Timestamps} *) type date = { year : int; month : int; day : int; dayname : string option; hour : int option; minute : int option; } type repeater_mark = Plus | Double_plus | Dot_plus | Minus | Double_minus type duration_unit = Hour | Day | Week | Month | Year type repeater_or_delay = { mark : repeater_mark; value : int; unit_ : duration_unit; } type timestamp = | Active of date * repeater_or_delay option | Inactive of date * repeater_or_delay option | Active_range of date * date | Inactive_range of date * date (** {1 Planning} *) type planning = { deadline : timestamp option; scheduled : timestamp option; closed : timestamp option; } (** {1 Properties} *) type property = { prop_name : string; prop_value : string option } (** {1 Affiliated keywords} *) type affiliated = { aff_name : string; aff_optional : string option; aff_value : string; } (** {1 Inline objects} *) type inline = | Plain of string | Bold of inline list | Italic of inline list | Underline of inline list | Strikethrough of inline list | Code of string | Verbatim of string | Link of link | Timestamp of timestamp | Line_break and link = { target : link_target; description : inline list option } (** {1 Lists} *) type list_kind = Ordered | Unordered | Descriptive type checkbox = Checked | Unchecked | Partial (** {1 Tables} *) type table_cell = inline list type table_row = Table_row_standard of table_cell list | Table_row_rule type table = { rows : table_row list } (** {1 Blocks} *) type src_block = { src_language : string option; src_switches : string option; src_arguments : string option; src_value : string; src_affiliated : affiliated list; } (** {1 Keywords} *) type keyword = { kw_key : string; kw_value : string } (** {1 Elements} *) type element = | Paragraph of inline list * affiliated list | Plain_list of list_kind * list_item list | Table of table | Block of block | Drawer of string * element list | Keyword of keyword | Comment of string list | Fixed_width of string list | Horizontal_rule and list_item = { li_bullet : string; li_counter_set : int option; li_checkbox : checkbox option; li_tag : inline list option; li_contents : element list; } and block = | Src_block of src_block | Example_block of { ex_value : string; ex_switches : string option; ex_affiliated : affiliated list; } | Export_block of { exp_backend : string; exp_value : string; exp_affiliated : affiliated list; } | Comment_block of { cb_value : string; cb_affiliated : affiliated list } | Quote_block of { qt_contents : element list; qt_affiliated : affiliated list; } | Center_block of { cn_contents : element list; cn_affiliated : affiliated list; } | Verse_block of { vs_contents : inline list; vs_affiliated : affiliated list; } | Custom_block of { cst_name : string; cst_params : string option; cst_contents : element list; cst_affiliated : affiliated list; } (** {1 Headings} *) type heading = { level : int; todo : string option; priority : char option; commented : bool; title : inline list; tags : string list; planning : planning option; properties : property list; contents : element list; children : heading list; } (** {1 Directives} *) type directive = { dir_key : string; dir_value : string } (** {1 Document} *) type document = { directives : directive list; preamble : element list; headings : heading list; }