summaryrefslogtreecommitdiff
path: root/Text/Pandoc
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-10-30 02:24:17 +0300
committerdefanor <defanor@uberspace.net>2017-10-30 02:24:17 +0300
commit2489d6808500b0395546216a9c6a9f2785496f6f (patch)
treea7377401448e27d12ae18b42df8f0b1838461acf /Text/Pandoc
parentb27e1f15a689b033d024d1791a8add301eed5a35 (diff)
Handle Gopher+
By ignoring it.
Diffstat (limited to 'Text/Pandoc')
-rw-r--r--Text/Pandoc/Readers/Gopher.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Text/Pandoc/Readers/Gopher.hs b/Text/Pandoc/Readers/Gopher.hs
index 694720d..3909e3d 100644
--- a/Text/Pandoc/Readers/Gopher.hs
+++ b/Text/Pandoc/Readers/Gopher.hs
@@ -37,7 +37,7 @@ pInfo = do
-- entry.
pLink :: Parser [Inline]
pLink = do
- t <- alphaNum
+ t <- anyChar
name <- manyTill unascii tab
selector <- manyTill unascii tab
host <- manyTill unascii tab
@@ -51,8 +51,14 @@ pLastLine :: Parser ()
-- sometimes LF is used instead of CRLF.
pLastLine = optional (optional endOfLine *> char '.' *> endOfLine) *> eof
+-- | Parses end-of-line, skipping Gopher+ extensions if present.
+pEOL :: Parser ()
+pEOL = (endOfLine *> pure ())
+ <|> (tab >> char '+' >> manyTill anyChar endOfLine *> pure ())
+
+-- | Parses a directory.
pDirEntries :: Parser [Inline]
-pDirEntries = concat <$> manyTill (choice [pInfo, pLink] <* endOfLine) pLastLine
+pDirEntries = concat <$> manyTill (choice [pInfo, pLink] <* pEOL) pLastLine
-- | Reads Gopher directory entries, falls back to plain text on
-- failure.