this repo has no description

review: more file format and less nesting

authored by

Florian Angeletti and committed by
Paul-Elliot Anglès d'Auriac
6eb0c339 c233e40b

+21 -19
+20 -18
src/latex/generator.ml
··· 278 278 let s = source (inline ~verbatim:false ~in_source:true) c in 279 279 match s with [] -> [] | _ :: _ as l -> [ Code_fragment l ] 280 280 281 + 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 + 281 298 let rec block ~in_source (l : Block.t) = 282 299 let one (t : Block.one) = 283 300 match t.desc with 284 301 | 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 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 303 305 | Paragraph i -> 304 306 inline ~in_source:false ~verbatim:false i 305 307 @ if in_source then [] else [ Break Paragraph ]
+1 -1
src/latex/raw.mli
··· 66 66 67 67 val input : Fpath.t Fmt.t 68 68 69 - val includegraphics: 'a t 69 + val includegraphics : 'a t 70 70 71 71 (** {1 Required OCaml-specific primitives} 72 72 All the macro should be implemented as "ocaml"-suffixed macro in the latex