this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix missing types in markdown record output

Add extract_all_text helper that properly handles all inline renderer
elements (Text, Code_span, Inlines, Emphasis, etc.) instead of only
handling Text nodes. Fixes record fields losing their type annotations
in the unified code block output.

Cherry-picked from jonludlam/odoc@f303d8e69

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+36 -6
+36 -6
src/markdown2/generator.ml
··· 319 319 let code_line = match code with 320 320 | `D code -> 321 321 let inline_source = inline ~config ~resolve code in 322 - let code_text = String.concat ~sep:"" (List.concat_map (function 323 - | Renderer.Inline.Text s -> [s] 324 - | _ -> []) inline_source) in 322 + let rec extract_all_text acc = function 323 + | [] -> List.rev acc 324 + | Renderer.Inline.Text s :: rest -> extract_all_text (s :: acc) rest 325 + | Renderer.Inline.Code_span code_list :: rest -> 326 + extract_all_text (String.concat ~sep:"" code_list :: acc) rest 327 + | Renderer.Inline.Inlines inlines :: rest -> 328 + extract_all_text (extract_all_text [] inlines @ acc) rest 329 + | Renderer.Inline.Emphasis inner :: rest -> 330 + extract_all_text (extract_all_text [] [inner] @ acc) rest 331 + | Renderer.Inline.Strong_emphasis inner :: rest -> 332 + extract_all_text (extract_all_text [] [inner] @ acc) rest 333 + | Renderer.Inline.Link { text; _ } :: rest -> 334 + extract_all_text (extract_all_text [] [text] @ acc) rest 335 + | Renderer.Inline.Image { text; _ } :: rest -> 336 + extract_all_text (extract_all_text [] [text] @ acc) rest 337 + | _ :: rest -> extract_all_text acc rest 338 + in 339 + let code_text = String.concat ~sep:"" (extract_all_text [] inline_source) in 325 340 String.trim code_text 326 341 | `N n -> 327 342 (* For nested items, recursively process them *) ··· 379 394 let code_line = match code with 380 395 | `D code -> 381 396 let inline_source = inline ~config ~resolve code in 382 - let code_text = String.concat ~sep:"" (List.concat_map (function 383 - | Renderer.Inline.Text s -> [s] 384 - | _ -> []) inline_source) in 397 + let rec extract_all_text acc = function 398 + | [] -> List.rev acc 399 + | Renderer.Inline.Text s :: rest -> extract_all_text (s :: acc) rest 400 + | Renderer.Inline.Code_span code_list :: rest -> 401 + extract_all_text (String.concat ~sep:"" code_list :: acc) rest 402 + | Renderer.Inline.Inlines inlines :: rest -> 403 + extract_all_text (extract_all_text [] inlines @ acc) rest 404 + | Renderer.Inline.Emphasis inner :: rest -> 405 + extract_all_text (extract_all_text [] [inner] @ acc) rest 406 + | Renderer.Inline.Strong_emphasis inner :: rest -> 407 + extract_all_text (extract_all_text [] [inner] @ acc) rest 408 + | Renderer.Inline.Link { text; _ } :: rest -> 409 + extract_all_text (extract_all_text [] [text] @ acc) rest 410 + | Renderer.Inline.Image { text; _ } :: rest -> 411 + extract_all_text (extract_all_text [] [text] @ acc) rest 412 + | _ :: rest -> extract_all_text acc rest 413 + in 414 + let code_text = String.concat ~sep:"" (extract_all_text [] inline_source) in 385 415 String.trim code_text 386 416 | `N n -> 387 417 (* For nested items, recursively process them *)