@@ -104,8 +104,15 @@ let fmt_verbatim_block ~loc s =
104104 in
105105 hvbox 0 (wrap (str " {v" ) (str " v}" ) content)
106106
107- let fmt_code_span s =
108- wrap (str " [" ) (str " ]" ) (str (escape_balanced_brackets s))
107+ let fmt_code_span ~wrap s =
108+ let s = escape_balanced_brackets s in
109+ let s =
110+ if wrap then
111+ let words = String. split_on_chars ~on: [' ' ] s in
112+ list words space_break str
113+ else str s
114+ in
115+ hovbox_if wrap 1 (str " [" $ s $ str " ]" )
109116
110117let fmt_math_span s = hovbox 2 (wrap (str " {m " ) (str " }" ) (str s))
111118
@@ -163,8 +170,8 @@ let list_block_elem c elems f =
163170 (elem.Loc. value :> block_element )
164171 (n.value :> block_element )
165172 || should_preserve_blank c elem.location n.location
166- then str " \n " $ force_newline
167- else force_newline
173+ then str " \n " $ force_break
174+ else force_break
168175 | None -> noop
169176 in
170177 f elem $ break )
@@ -231,7 +238,7 @@ let rec fmt_inline_elements c ~wrap elements =
231238 | `Word w :: t ->
232239 fmt_if (String. is_prefix ~prefix: " @" w) (str " \\ " )
233240 $ str_normalized ~wrap w $ aux t
234- | `Code_span s :: t -> fmt_code_span s $ aux t
241+ | `Code_span s :: t -> fmt_code_span ~wrap s $ aux t
235242 | `Math_span s :: t -> fmt_math_span s $ aux t
236243 | `Raw_markup (lang , s ) :: t ->
237244 let lang =
@@ -281,7 +288,8 @@ and fmt_markup_with_inline_elements c ~wrap ?(force_space = false) tag elems
281288 in
282289 str " {" $ tag $ leading_space $ fmt_inline_elements c ~wrap elems $ str " }"
283290
284- and fmt_nestable_block_element c elm =
291+ and fmt_nestable_block_element c (elm : nestable_block_element with_location )
292+ =
285293 match elm.Loc. value with
286294 | `Paragraph elems ->
287295 hovbox 0
@@ -299,6 +307,20 @@ and fmt_nestable_block_element c elm =
299307 fmt_list_heavy c k items
300308 | `List (k , _syntax , items ) -> fmt_list_light c k items
301309 | `Table table -> fmt_table c table
310+ | `Media (_kind , href , text , media ) -> (
311+ let prefix =
312+ match media with
313+ | `Image -> " image"
314+ | `Video -> " video"
315+ | `Audio -> " audio"
316+ in
317+ let href =
318+ match href.value with
319+ | `Reference s -> str " !" $ str s
320+ | `Link s -> str " :" $ str s
321+ in
322+ let ref = str " {" $ str prefix $ href $ str " }" in
323+ match text with "" -> ref | _ -> str " {" $ ref $ str text $ str " }" )
302324
303325and fmt_list_heavy c kind items =
304326 let fmt_item elems =
@@ -437,7 +459,7 @@ let wrap_see = function
437459 | `File -> wrap (str " '" ) (str " '" )
438460 | `Document -> wrap (str " \" " ) (str " \" " )
439461
440- let fmt_tag c = function
462+ let fmt_tag c : tag -> _ = function
441463 | `Author s -> fmt_tag_args c " author" ~arg: (str s)
442464 | `Version s -> fmt_tag_args c " version" ~arg: (str s)
443465 | `See (k , sr , txt ) -> fmt_tag_args c " see" ~arg: (wrap_see k (str sr)) ~txt
@@ -452,6 +474,8 @@ let fmt_tag c = function
452474 | `Closed -> fmt_tag_args c " closed"
453475 | `Hidden -> fmt_tag_args c " hidden"
454476 | `Canonical ref -> fmt_tag_args c " canonical" ~arg: (fmt_reference ref )
477+ | `Children_order txt -> fmt_tag_args c " children_order" ~txt
478+ | `Short_title txt -> fmt_tag_args c " short_title" ~txt
455479
456480let fmt_block_element c elm =
457481 match elm.Loc. value with
0 commit comments