diff options
author | Ryan Kavanagh <rak@rak.ac> | 2020-06-08 22:04:42 -0400 |
---|---|---|
committer | Ryan Kavanagh <rak@rak.ac> | 2020-06-08 22:04:42 -0400 |
commit | 08cf9b09f53f999cad569aad9547edf6d2bf819c (patch) | |
tree | 51b9753c032071c312c82932a405c097a9e3526e /gemini/mimeTextGemini.ml | |
parent | Fix ciphers (diff) |
Fix parsing errors involving crlf vs eol
Diffstat (limited to '')
-rw-r--r-- | gemini/mimeTextGemini.ml | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gemini/mimeTextGemini.ml b/gemini/mimeTextGemini.ml index 95f432b..385871f 100644 --- a/gemini/mimeTextGemini.ml +++ b/gemini/mimeTextGemini.ml @@ -110,9 +110,9 @@ struct | Error m -> raise (ParseError m) let header_parser = - lift (fun x -> H3 x) (string "###" *> skip_spaces *> take_till_cr) - <|> lift (fun x -> H2 x) (string "##" *> skip_spaces *> take_till_cr) - <|> lift (fun x -> H1 x) (string "#" *> skip_spaces *> take_till_cr) + lift (fun x -> H3 x) (string "###" *> skip_spaces *> take_till_eol) + <|> lift (fun x -> H2 x) (string "##" *> skip_spaces *> take_till_eol) + <|> lift (fun x -> H1 x) (string "#" *> skip_spaces *> take_till_eol) <?> "gemini_header" let str_to_header_line = parse_string header_parser @@ -126,14 +126,14 @@ struct lift2 to_link (string "=>" *> skip_spaces *> take_till end_of_url) (* the optional name, will be "" if there is none *) - (skip_spaces *> take_till_cr) + (skip_spaces *> take_till_eol) <?> "gemini_link" let str_to_link_line = parse_string link_parser (* Makes sure a line is actually a plain text line *) let text_parser = - let take_line = lift (fun s -> Text s) take_till_cr in + let take_line = lift (fun s -> Text s) take_till_eol in peek_char >>= function | Some '#' -> fail "text line cannot start with #" | Some '>' -> fail "text line cannot start with >" @@ -153,12 +153,12 @@ struct (* The gemini spec says that pre blocks are demarcated by lines that start with "```". It says nothing about what follows on these lines. *) - let pre_divider = string "```" *> take_till_cr *> return None + let pre_divider = string "```" *> take_till_eol *> return None let pre_line_parser = peek_string 3 >>= function | "```" -> fail "preformatted line cannot start with ```" - | _ -> lift (fun s -> Pre s) take_till_cr + | _ -> lift (fun s -> Pre s) take_till_eol let pre_block_parser = pre_divider *> many pre_line_parser <* pre_divider @@ -166,12 +166,12 @@ struct let str_to_pre_block = parse_string pre_block_parser let list_item_parser = - lift (fun x -> Ul x) (string "* " *> skip_spaces *> take_till_cr) + lift (fun x -> Ul x) (string "* " *> skip_spaces *> take_till_eol) let str_to_list_line = parse_string list_item_parser let quoted_parser = - lift (fun x -> Ul x) (string ">" *> skip_spaces *> take_till_cr) + lift (fun x -> Ul x) (string ">" *> skip_spaces *> take_till_eol) let str_to_quoted_line = parse_string quoted_parser @@ -180,7 +180,7 @@ struct plain text line whenever we get to the text parser. As a result, we don't need to recheck that it's actually a text line and not some special line. *) - let plain_text_parser = lift (fun s -> Text s) take_till_cr + let plain_text_parser = lift (fun s -> Text s) take_till_eol in fix (fun gemini -> lift2 List.append pre_block_parser gemini |