@@ -106,6 +106,41 @@ let rec nestable_block_element_to_block
106106 in
107107 let meta = loc_to_meta location in
108108 Block. Paragraph (paragraph, meta)
109+ | { value = `Table ((grid , alignment ), _ ); location } ->
110+ let meta = loc_to_meta location in
111+ let cell
112+ ((c , _ ) : Odoc_parser.Ast. nestable_block_element Odoc_parser.Ast. cell ) =
113+ let c = nestable_block_element_list_to_inlines c in
114+ (c, (" " , " " ) (* Initial and trailing blanks *) )
115+ in
116+ let header_row
117+ (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row ) =
118+ let row = List. map ~f: cell row in
119+ ((`Header row, Meta. none), " " )
120+ in
121+ let data_row
122+ (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row ) =
123+ let row = List. map ~f: cell row in
124+ ((`Data row, Meta. none), " " )
125+ in
126+ let alignment_row =
127+ match alignment with
128+ | None -> []
129+ | Some alignment ->
130+ let alignment =
131+ List. map
132+ ~f: (fun x -> ((x, 1 (* nb of separator *) ), Meta. none))
133+ alignment
134+ in
135+ [ ((`Sep alignment, Meta. none), " " ) ]
136+ in
137+ let rows =
138+ match grid with
139+ | [] -> assert false
140+ | h :: t -> (header_row h :: alignment_row) @ List. map ~f: data_row t
141+ in
142+ let tbl = Block.Table. make rows in
143+ Block. Ext_table (tbl, meta)
109144 | { value = `List (kind , style , xs ); location } ->
110145 let l =
111146 let list_items =
@@ -148,22 +183,27 @@ let rec nestable_block_element_to_block
148183 in
149184 let meta = loc_to_meta location in
150185 Block. List (l, meta)
151- | { value = `Code_block ( metadata , { value = code ; location = code_loc } ) ; location } ->
186+ | { value = `Code_block { meta = metadata ; delimiter = _ ; content = { value = code ; location = code_loc } ; output } ; location } ->
152187 let meta = loc_to_meta location in
153188 let main_block =
154189 let code_block =
155190 let info_string =
156191 match metadata with
157192 | None -> Some (" ocaml" , loc_to_meta code_loc)
158- | Some ( { value = lang ; location = lang_log }, _env ) ->
193+ | Some { language = { value = lang ; location = lang_log }; tags = _ } ->
159194 Some (lang, loc_to_meta lang_log)
160195 in
161196 let block_line = Block_line. list_of_string code in
162197 Block.Code_block. make ?info_string block_line
163198 in
164199 Block. Code_block (code_block, meta)
165200 in
166- Block. Blocks ([ main_block ], meta)
201+ let output_block =
202+ match output with
203+ | None -> []
204+ | Some output -> [nestable_block_element_list_to_block output]
205+ in
206+ Block. Blocks ( main_block :: output_block , meta)
167207 | { value = `Verbatim code ; location } ->
168208 let code_block =
169209 let info_string = Some (" verb" , Meta. none) in
@@ -179,6 +219,75 @@ let rec nestable_block_element_to_block
179219 in
180220 let meta = loc_to_meta location in
181221 Block. Ext_math_block (code_block, meta)
222+ | { value = `Media _ ; location } ->
223+ let meta = loc_to_meta location in
224+ let p = Block.Paragraph. make (Inline. Text (" (media)" , meta)) in
225+ Block. Paragraph (p, meta)
226+
227+ and nestable_block_element_to_inlines
228+ (nestable :
229+ Odoc_parser.Ast.nestable_block_element Odoc_parser.Loc.with_location ) =
230+ match nestable with
231+ | { value = `Paragraph text ; location = _ } ->
232+ inline_element_list_to_inlines text
233+ | { value = `Table ((grid , _ ), _ ); location } ->
234+ let meta = loc_to_meta location in
235+ let cell
236+ ((c , _ ) : Odoc_parser.Ast. nestable_block_element Odoc_parser.Ast. cell ) =
237+ nestable_block_element_list_to_inlines c
238+ in
239+ let row (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row ) =
240+ let sep = Inline. Text (" | " , Meta. none) in
241+ sep :: List. concat_map ~f: (fun c -> [ cell c; sep ]) row
242+ in
243+ let rows = List. concat_map ~f: row grid in
244+ Inline. Inlines (rows, meta)
245+ | { value = `List (_ , _ , xs ); location } ->
246+ let meta = loc_to_meta location in
247+ let item i = nestable_block_element_list_to_inlines i in
248+ let items =
249+ let sep = Inline. Text (" - " , Meta. none) in
250+ List. concat_map ~f: (fun i -> [ sep; item i ]) xs
251+ in
252+ Inline. Inlines (items, meta)
253+ | { value = `Modules modules ; location } ->
254+ let meta = loc_to_meta location in
255+ let s = List. map ~f: (fun x -> x.Odoc_parser.Loc. value) modules in
256+ Inline. Text (" modules: " ^ String. concat ~sep: " " s, meta)
257+ | { value =
258+ `Code_block
259+ { meta = _
260+ ; delimiter = _
261+ ; content = { value = code; location = code_loc }
262+ ; output = _
263+ }
264+ ; location
265+ } ->
266+ let meta = loc_to_meta location in
267+ let meta_code = loc_to_meta code_loc in
268+ let code_span =
269+ Inline.Code_span. make ~backtick_count: 1 [ (" " , (code, meta_code)) ]
270+ in
271+ Inline. Code_span (code_span, meta)
272+ | { value = `Verbatim code ; location } ->
273+ let meta = loc_to_meta location in
274+ let code_span =
275+ Inline.Code_span. make ~backtick_count: 1 [ (" " , (code, Meta. none)) ]
276+ in
277+ Inline. Code_span (code_span, meta)
278+ | { value = `Math_block code ; location } ->
279+ let meta = loc_to_meta location in
280+ let code_span =
281+ Inline.Math_span. make ~display: true [ (" " , (code, Meta. none)) ]
282+ in
283+ Inline. Ext_math_span (code_span, meta)
284+ | { value = `Media _ ; location } ->
285+ let meta = loc_to_meta location in
286+ Inline. Text (" (media)" , meta)
287+
288+ and nestable_block_element_list_to_inlines l =
289+ let inlines = List. map ~f: nestable_block_element_to_inlines l in
290+ Inline. Inlines (inlines, Meta. none)
182291
183292and nestable_block_element_list_to_block nestables =
184293 let blocks = List. map ~f: nestable_block_element_to_block nestables in
@@ -276,6 +385,19 @@ let tag_to_block ~meta (tag : Odoc_parser.Ast.tag) =
276385 | `Inline -> format_tag_empty " @inline"
277386 | `Open -> format_tag_empty " @open"
278387 | `Closed -> format_tag_empty " @closed"
388+ | `Hidden -> format_tag_empty " @hidden"
389+ | `Order_category oc ->
390+ let block = nestable_block_element_list_to_block oc in
391+ format_tag_block " @order_category" block
392+ | `Short_title oc ->
393+ let block = nestable_block_element_list_to_block oc in
394+ format_tag_block " @short_title" block
395+ | `Toc_status oc ->
396+ let block = nestable_block_element_list_to_block oc in
397+ format_tag_block " @toc_status" block
398+ | `Children_order oc ->
399+ let block = nestable_block_element_list_to_block oc in
400+ format_tag_block " @children_order" block
279401;;
280402
281403let rec block_element_to_block
@@ -293,7 +415,7 @@ let rec block_element_to_block
293415 let meta = loc_to_meta location in
294416 tag_to_block ~meta t
295417 | { value =
296- `Paragraph _ | `List _ | `Modules _ | `Code_block _ | `Verbatim _ | `Math_block _
418+ `Paragraph _ | `List _ | `Modules _ | `Code_block _ | `Verbatim _ | `Table _ | ` Math_block _ | `Media _
297419 ; location = _
298420 } as nestable -> nestable_block_element_to_block nestable
299421
0 commit comments