[OCaml] Mobile-friendly clone of cgit.
1
(** Prose rendering façade.
2
3
Detects documentation formats by filename extension and renders content as
4
styled HTML. This module is the single entry point for prose rendering
5
throughout ogit. *)
6
7
let is_readme_filename filename =
8
Filename.basename filename |> String.lowercase_ascii
9
|> String.starts_with ~prefix:"readme"
10
11
let is_doc_filename filename =
12
match Filename.extension filename |> String.lowercase_ascii with
13
| ".md" | ".markdown" | ".org" | ".mld" | ".txt" -> true
14
| _ -> false
15
16
let format_of_filename filename =
17
match Filename.extension filename |> String.lowercase_ascii with
18
| ".org" -> Org.format
19
| ".mld" -> Mld.format
20
| ".txt" -> Plaintext.format
21
| _ -> Markdown.format
22
23
let render ~filename content =
24
let format = format_of_filename filename in
25
Format.render format content
26