···278278 let s = source (inline ~verbatim:false ~in_source:true) c in
279279 match s with [] -> [] | _ :: _ as l -> [ Code_fragment l ]
280280281281+let alt_text ~in_source (target : Target.t) alt =
282282+ let text = txt ~verbatim:false ~in_source:false [ alt ] in
283283+ let break = if in_source then [] else [ Break Paragraph ] in
284284+ match target with
285285+ | Internal _ -> text @ break
286286+ | External l -> [ External_ref (l, Some text) ] @ break
287287+288288+let image ~in_source (internal_url : Url.t) alt =
289289+ let dir, file = Link.get_dir_and_file internal_url.page in
290290+ match Fpath.(get_ext @@ v file) with
291291+ (* list imported from pdftex.def *)
292292+ | "" | ".pdf" | ".png" | ".jpg" | ".mps" | ".jpeg" | ".jbig2" | ".jb2"
293293+ | ".PDF" | ".PNG" | ".JPG" | ".JPEG" | ".JBIG2" | ".JB2" ->
294294+ let fpath = Fpath.v (String.concat Fpath.dir_sep (dir @ [ file ])) in
295295+ [ Image fpath ]
296296+ | _ -> alt_text ~in_source (Internal (Resolved internal_url)) alt
297297+281298let rec block ~in_source (l : Block.t) =
282299 let one (t : Block.one) =
283300 match t.desc with
284301 | Inline i -> inline ~verbatim:false ~in_source:false i
285285- | Image (Internal (Resolved x), alt) ->
286286- let dir, file = Link.get_dir_and_file x.page in
287287- begin match Fpath.(get_ext @@ v file) with
288288- | "" | ".jpeg" | ".png" | ".pdf" ->
289289- let fpath = Fpath.v (String.concat Fpath.dir_sep (dir @ [file])) in
290290- [ Image fpath ]
291291- | _ ->
292292- txt ~verbatim:false ~in_source:false [ alt ]
293293- @ if in_source then [] else [ Break Paragraph ]
294294- end
295295- | Image (Internal Unresolved, c) | Audio(Internal _, c) | Video (Internal _, c) ->
296296- txt ~verbatim:false ~in_source:false [ c ]
297297- @ if in_source then [] else [ Break Paragraph ]
298298- | Audio (External l, content) | Video (External l, content)
299299- | Image (External l, content) ->
300300- let text = txt ~verbatim:false ~in_source:false [ content ] in
301301- let break = if in_source then [] else [ Break Paragraph ] in
302302- [ External_ref (l, Some text)] @ break
302302+ | Image (Internal (Resolved x), alt) -> image ~in_source x alt
303303+ | Image (t, alt) | Audio (t, alt) | Video (t, alt) ->
304304+ alt_text ~in_source t alt
303305 | Paragraph i ->
304306 inline ~in_source:false ~verbatim:false i
305307 @ if in_source then [] else [ Break Paragraph ]
+1-1
src/latex/raw.mli
···66666767val input : Fpath.t Fmt.t
68686969-val includegraphics: 'a t
6969+val includegraphics : 'a t
70707171(** {1 Required OCaml-specific primitives}
7272 All the macro should be implemented as "ocaml"-suffixed macro in the latex