Source file cmarkit_proxy.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
let of_string ?loc_offset ~file =
  Cmarkit.Doc.of_string ~heading_auto_ids:false ~strict:false ~locs:true
    ?loc_offset ~file

let of_string ~read_file ~file s =
  let file = Fpath.to_string file in
  let frontmatter, s, loc_offset =
    match Frontmatter.extract s with
    | None -> (Frontmatter.empty, s, (0, 0))
    | Some { frontmatter = txt_fm; rest; rest_offset; fm_offset } ->
        let to_asset = Asset.of_string ~read_file in
        let frontmatter =
          Frontmatter.of_string ~to_asset file fm_offset txt_fm
        in
        (frontmatter, rest, rest_offset)
  in
  let doc = of_string ~loc_offset ~file s in
  (doc, frontmatter)