View raw

1 (** Public semantic AST types for Org Mode documents. *) 2 3 (** {1 Inline objects} *) 4 5 (** A link target. *) 6 type link_target = 7 | Url of string (** An external URL (https, http, ftp, etc.) *) 8 | File of string (** A file path *) 9 | Internal of string (** An internal link target (custom-id, fuzzy) *) 10 | Protocol of string * string (** protocol:path *) 11 12 (** {1 Timestamps} *) 13 14 type date = { 15 year : int; 16 month : int; 17 day : int; 18 dayname : string option; 19 hour : int option; 20 minute : int option; 21 } 22 (** A date with optional time. *) 23 24 (** Repeater or delay mark. *) 25 type repeater_mark = 26 | Plus (** + *) 27 | Double_plus (** ++ *) 28 | Dot_plus (** .+ *) 29 | Minus (** - (warning delay) *) 30 | Double_minus (** -- (warning delay) *) 31 32 type duration_unit = Hour | Day | Week | Month | Year 33 34 type repeater_or_delay = { 35 mark : repeater_mark; 36 value : int; 37 unit_ : duration_unit; 38 } 39 40 (** A timestamp value. *) 41 type timestamp = 42 | Active of date * repeater_or_delay option 43 | Inactive of date * repeater_or_delay option 44 | Active_range of date * date 45 | Inactive_range of date * date 46 47 (** {1 Planning} *) 48 49 type planning = { 50 deadline : timestamp option; 51 scheduled : timestamp option; 52 closed : timestamp option; 53 } 54 55 (** {1 Properties} *) 56 57 type property = { prop_name : string; prop_value : string option } 58 59 (** {1 Affiliated keywords} *) 60 61 type affiliated = { 62 aff_name : string; 63 aff_optional : string option; 64 aff_value : string; 65 } 66 67 (** {1 Inline objects} *) 68 69 (** Inline objects that can appear within paragraphs, headings, etc. *) 70 type inline = 71 | Plain of string (** Plain text *) 72 | Bold of inline list (** *bold* *) 73 | Italic of inline list (** /italic/ *) 74 | Underline of inline list (** _underline_ *) 75 | Strikethrough of inline list (** +strikethrough+ *) 76 | Code of string (** ~code~ *) 77 | Verbatim of string (** =verbatim= *) 78 | Link of link (** A link object *) 79 | Timestamp of timestamp (** A timestamp *) 80 | Line_break (** Explicit line break \\\\ *) 81 82 and link = { target : link_target; description : inline list option } 83 (** A link with optional description. *) 84 85 (** {1 Lists} *) 86 87 type list_kind = Ordered | Unordered | Descriptive 88 type checkbox = Checked | Unchecked | Partial 89 90 (** {1 Tables} *) 91 92 type table_cell = inline list 93 type table_row = Table_row_standard of table_cell list | Table_row_rule 94 type table = { rows : table_row list } 95 96 (** {1 Blocks} *) 97 98 type src_block = { 99 src_language : string option; 100 src_switches : string option; 101 src_arguments : string option; 102 src_value : string; 103 src_affiliated : affiliated list; 104 } 105 106 (** {1 Keywords} *) 107 108 type keyword = { kw_key : string; kw_value : string } 109 110 (** {1 Elements} *) 111 112 (** Elements are the building blocks of sections. *) 113 type element = 114 | Paragraph of inline list * affiliated list 115 | Plain_list of list_kind * list_item list 116 | Table of table 117 | Block of block 118 | Drawer of string * element list 119 | Keyword of keyword 120 | Comment of string list 121 | Fixed_width of string list 122 | Horizontal_rule 123 124 and list_item = { 125 li_bullet : string; 126 li_counter_set : int option; 127 li_checkbox : checkbox option; 128 li_tag : inline list option; 129 li_contents : element list; 130 } 131 132 and block = 133 | Src_block of src_block 134 | Example_block of { 135 ex_value : string; 136 ex_switches : string option; 137 ex_affiliated : affiliated list; 138 } 139 | Export_block of { 140 exp_backend : string; 141 exp_value : string; 142 exp_affiliated : affiliated list; 143 } 144 | Comment_block of { cb_value : string; cb_affiliated : affiliated list } 145 | Quote_block of { 146 qt_contents : element list; 147 qt_affiliated : affiliated list; 148 } 149 | Center_block of { 150 cn_contents : element list; 151 cn_affiliated : affiliated list; 152 } 153 | Verse_block of { 154 vs_contents : inline list; 155 vs_affiliated : affiliated list; 156 } 157 | Custom_block of { 158 cst_name : string; 159 cst_params : string option; 160 cst_contents : element list; 161 cst_affiliated : affiliated list; 162 } 163 164 (** {1 Headings} *) 165 166 type heading = { 167 level : int; 168 todo : string option; 169 priority : char option; 170 commented : bool; 171 title : inline list; 172 tags : string list; 173 planning : planning option; 174 properties : property list; 175 contents : element list; 176 children : heading list; 177 } 178 179 (** {1 Directives} *) 180 181 type directive = { dir_key : string; dir_value : string } 182 (** File-level directives like #+TITLE, #+AUTHOR, etc. *) 183 184 (** {1 Document} *) 185 186 type document = { 187 directives : directive list; 188 preamble : element list; 189 headings : heading list; 190 } 191