package kkmarkdown

  1. Overview
  2. Docs
A safe markdown engine

Install

dune-project
 Dependency

Authors

Maintainers

Sources

1.0.0.tar.gz
md5=cc8056af18a204bf68d60f50be5a9de7
sha512=452ef12429aa68606e79b82d883275abd05659fec52509dfa18d7de0edcfa0afba7fa9001d9643c5ad072a494ad8593c6f127e382b06d6c224964b3a7969f388

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.