···278 let s = source (inline ~verbatim:false ~in_source:true) c in
279 match s with [] -> [] | _ :: _ as l -> [ Code_fragment l ]
28000000000000000000281let rec block ~in_source (l : Block.t) =
282 let one (t : Block.one) =
283 match t.desc with
284 | Inline i -> inline ~verbatim:false ~in_source:false i
285- | Image (Internal (Resolved x), alt) ->
286- let dir, file = Link.get_dir_and_file x.page in
287- begin match Fpath.(get_ext @@ v file) with
288- | "" | ".jpeg" | ".png" | ".pdf" ->
289- let fpath = Fpath.v (String.concat Fpath.dir_sep (dir @ [file])) in
290- [ Image fpath ]
291- | _ ->
292- txt ~verbatim:false ~in_source:false [ alt ]
293- @ if in_source then [] else [ Break Paragraph ]
294- end
295- | Image (Internal Unresolved, c) | Audio(Internal _, c) | Video (Internal _, c) ->
296- txt ~verbatim:false ~in_source:false [ c ]
297- @ if in_source then [] else [ Break Paragraph ]
298- | Audio (External l, content) | Video (External l, content)
299- | Image (External l, content) ->
300- let text = txt ~verbatim:false ~in_source:false [ content ] in
301- let break = if in_source then [] else [ Break Paragraph ] in
302- [ External_ref (l, Some text)] @ break
303 | Paragraph i ->
304 inline ~in_source:false ~verbatim:false i
305 @ if in_source then [] else [ Break Paragraph ]
···278 let s = source (inline ~verbatim:false ~in_source:true) c in
279 match s with [] -> [] | _ :: _ as l -> [ Code_fragment l ]
280281+let alt_text ~in_source (target : Target.t) alt =
282+ let text = txt ~verbatim:false ~in_source:false [ alt ] in
283+ let break = if in_source then [] else [ Break Paragraph ] in
284+ match target with
285+ | Internal _ -> text @ break
286+ | External l -> [ External_ref (l, Some text) ] @ break
287+288+let image ~in_source (internal_url : Url.t) alt =
289+ let dir, file = Link.get_dir_and_file internal_url.page in
290+ match Fpath.(get_ext @@ v file) with
291+ (* list imported from pdftex.def *)
292+ | "" | ".pdf" | ".png" | ".jpg" | ".mps" | ".jpeg" | ".jbig2" | ".jb2"
293+ | ".PDF" | ".PNG" | ".JPG" | ".JPEG" | ".JBIG2" | ".JB2" ->
294+ let fpath = Fpath.v (String.concat Fpath.dir_sep (dir @ [ file ])) in
295+ [ Image fpath ]
296+ | _ -> alt_text ~in_source (Internal (Resolved internal_url)) alt
297+298let rec block ~in_source (l : Block.t) =
299 let one (t : Block.one) =
300 match t.desc with
301 | Inline i -> inline ~verbatim:false ~in_source:false i
302+ | Image (Internal (Resolved x), alt) -> image ~in_source x alt
303+ | Image (t, alt) | Audio (t, alt) | Video (t, alt) ->
304+ alt_text ~in_source t alt
000000000000000305 | Paragraph i ->
306 inline ~in_source:false ~verbatim:false i
307 @ if in_source then [] else [ Break Paragraph ]
+1-1
src/latex/raw.mli
···6667val input : Fpath.t Fmt.t
6869-val includegraphics: 'a t
7071(** {1 Required OCaml-specific primitives}
72 All the macro should be implemented as "ocaml"-suffixed macro in the latex
···6667val input : Fpath.t Fmt.t
6869+val includegraphics : 'a t
7071(** {1 Required OCaml-specific primitives}
72 All the macro should be implemented as "ocaml"-suffixed macro in the latex