package kkmarkdown

  1. Overview
  2. Docs
A safe markdown engine

Install

Dune Dependency

Authors

Maintainers

Sources

1.1.0.tar.gz
md5=a20517d95590d03ff5b7670323b8b0dd
sha512=97b3faa09e23ab88c5b4dcabe88f29e5c675b6bb4b0c9230ec105a70b01b37b54274cc0ab4a5eed84a754a99e3664e116a7aba6c9697e3669229985f1bf749be

doc/src/kkmarkdown.lib/kkmarkdown.ml.html

Source file kkmarkdown.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
let split_to_lines =
  let re = Str.regexp "\r?\n" in
  fun s -> Str.split_delim re s

let trans ?(unsafe = false) s = split_to_lines s |> Trans.run ~unsafe

let get_input_from_channel ch =
  let buf = Buffer.create 256 in
  (try
     while true do
       Buffer.add_char buf (input_char ch)
     done
   with End_of_file -> ());
  Buffer.contents buf

let trans_from_file ?unsafe file =
  let ch = open_in file in
  let input = get_input_from_channel ch in
  close_in_noerr ch;
  trans ?unsafe input

let trans_from_stdin ?unsafe () = trans ?unsafe (get_input_from_channel stdin)

let trans_to_string ?unsafe ?rss s =
  trans ?unsafe s |> Format.asprintf "%a" (Typ.pp ?rss)
OCaml

Innovation. Community. Security.