package hilite

  1. Overview
  2. Docs

Source file md.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
let langs = [ "ocaml"; "dune"; "opam"; "sh"; "shell"; "bash" ]

let transform blocks =
  let f (b : 'a Omd.block) =
    match b with
    | Omd.Code_block (attr, lang, src) -> (
        if not (List.mem lang langs) then b
        else
          match Syntax.src_code_to_html ~lang ~src with
          | Ok html -> Omd.Html_block (attr, html)
          | Error (`Msg s) -> failwith s)
    | _ -> b
  in
  List.map f blocks