summaryrefslogtreecommitdiff
path: root/gemini
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--gemini/mimeTextGemini.ml13
-rw-r--r--gemini/mimeTextGemini.mli3
2 files changed, 16 insertions, 0 deletions
diff --git a/gemini/mimeTextGemini.ml b/gemini/mimeTextGemini.ml
index 2f4d5ca..ca4cd32 100644
--- a/gemini/mimeTextGemini.ml
+++ b/gemini/mimeTextGemini.ml
@@ -16,6 +16,7 @@ sig
| 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
@@ -39,6 +40,8 @@ sig
val str_to_list_line : string -> gemini_line
+ val str_to_quoted_line : string -> gemini_line
+
val str_to_gemini : string -> gemini
end
@@ -57,6 +60,7 @@ struct
| Pre of string
| Text of string
| Ul of string
+ | Quoted of string
type gemini = gemini_line list
@@ -69,6 +73,7 @@ struct
| Pre s -> "Pre " ^ s
| Text s -> "Text " ^ s
| Ul s -> "Ul " ^ s
+ | Quoted s -> "Quoted " ^ s
let gemini_line_to_canon_str = function
| H1 s -> "# " ^ s
@@ -79,6 +84,7 @@ struct
| Pre s -> s
| Text s -> s
| Ul s -> "* " ^ s
+ | Quoted s -> ">" ^ s
let gemini_to_str g =
List.fold_right (fun l -> fun r -> (gemini_line_to_str l) ^ "\n" ^ r) g ""
@@ -131,6 +137,7 @@ struct
peek_char >>= function
| Some '#' -> fail "text line cannot start with #"
| Some '*' -> fail "text line cannot start with *"
+ | Some '>' -> fail "text line cannot start with >"
| Some '`' -> (peek_string 3 >>= function
| "```" -> fail "text line cannot start with ```"
| _ -> take_line)
@@ -161,6 +168,11 @@ struct
let str_to_list_line = parse_string list_item_parser
+ let quoted_parser =
+ lift (fun x -> Ul x) (string ">" *> skip_spaces *> take_till_cr)
+
+ let str_to_quoted_line = parse_string quoted_parser
+
let gemini : gemini_line list Angstrom.t =
(* Because many tries each in order, we know that we will have a
plain text line whenever we get to the text parser. As a result,
@@ -173,6 +185,7 @@ struct
<|> lift2 List.cons (header_parser
<|> link_parser
<|> list_item_parser
+ <|> quoted_parser
<|> plain_text_parser) gemini
<|> return [])
<?> "gemini"
diff --git a/gemini/mimeTextGemini.mli b/gemini/mimeTextGemini.mli
index aa8d462..941cf94 100644
--- a/gemini/mimeTextGemini.mli
+++ b/gemini/mimeTextGemini.mli
@@ -14,6 +14,7 @@ sig
| 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
@@ -37,6 +38,8 @@ sig
val str_to_list_line : string -> gemini_line
+ val str_to_quoted_line : string -> gemini_line
+
val str_to_gemini : string -> gemini
end