summaryrefslogtreecommitdiff
path: root/gemini/mimeTextGemini.mli
blob: 941cf94fcc4851555f6cf33c95c0b3542b5ced0b (plain) (blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(* Copyright (C) 2020 Ryan Kavanagh <rak@rak.ac> *)
(* Implements a parser for the text/gemini mime-type specified on
   https://gemini.circumlunar.space/docs/spec-spec.txt .  *)

module type MIME_TEXT_GEMINI =
sig
  exception ParseError of string

  type gemini_line =
    | H1 of string                     (* # header   *)
    | H2 of string                     (* ## header  *)
    | H3 of string                     (* ### header *)
    | Link of string * (string option) (* link with url and optional name *)
    | Pre of string                    (* preformatted text line *)
    | Text of string                   (* plain text line *)
    | Ul of string                     (* unordered list item *)
    | Quoted of string                 (* quoted text *)

  type gemini = gemini_line list

  val gemini_line_to_str : gemini_line -> string

  val gemini_to_str : gemini -> string

  val gemini_line_to_canon_str : gemini_line -> string

  val gemini_to_canon_str : gemini -> string

  val str_to_header_line : string -> gemini_line

  val str_to_link_line : string -> gemini_line

  val str_to_text_line : string -> gemini_line

  val str_to_pre_line : string -> gemini_line

  val str_to_pre_block : string -> gemini_line list

  val str_to_list_line : string -> gemini_line

  val str_to_quoted_line : string -> gemini_line

  val str_to_gemini : string -> gemini
end

module MimeTextGemini : MIME_TEXT_GEMINI