kortfat/bin/main.ml
2024-09-24 11:58:17 +02:00

19 lines
524 B
OCaml

let read_markdown file =
let s =
let ic = open_in file in
(* XXX: probably doesn't work on Windows *)
let len = In_channel.length ic |> Int64.to_int in
Fun.protect (fun () -> really_input_string ic len)
~finally:(fun () -> close_in ic)
in
Cmarkit.Doc.of_string ~file s
let kortfat files =
let mds = List.map read_markdown files in
let doc = Kortfat.kortfat mds in
Cmarkit_commonmark.of_doc doc
|> print_endline
let () =
let files = List.tl (Array.to_list Sys.argv) in
kortfat files