summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Textile.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-11-06 16:05:17 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2012-11-06 16:05:17 -0800
commit4cd573c61f61885cb368b40dccd1b458c39846c7 (patch)
treec8fe5e6d7429b1d14fbe6b6ae1bfcd797b8fe626 /src/Text/Pandoc/Readers/Textile.hs
parent4aa3e1f978fc285d16f047c800504b03cc897ec8 (diff)
Textile reader/writer: Fixed autolinks.
Previously the textile reader and writer incorrectly implented RST-style autolinks for URLs and email addresses. This has been fixed. Now an autolink is done this way: "$":http://myurl.com
Diffstat (limited to 'src/Text/Pandoc/Readers/Textile.hs')
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index c6a2938a9..f2a70612d 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -46,7 +46,6 @@ Left to be implemented:
- continued blocks (ex bq..)
TODO : refactor common patterns across readers :
- - autolink
- more ...
-}
@@ -361,8 +360,7 @@ inline = choice inlineParsers <?> "inline"
-- | Inline parsers tried in order
inlineParsers :: [Parser [Char] ParserState Inline]
-inlineParsers = [ autoLink
- , str
+inlineParsers = [ str
, whitespace
, endline
, code
@@ -501,7 +499,8 @@ linkNoB = try $ do
char ':'
let stopChars = "!.,;:"
url <- manyTill nonspaceChar (lookAhead $ space <|> try (oneOf stopChars >> (space <|> newline)))
- return $ Link name (url, "")
+ let name' = if name == [Str "$"] then [Str url] else name
+ return $ Link name' (url, "")
linkB :: Parser [Char] ParserState Inline
linkB = try $ do
@@ -509,13 +508,8 @@ linkB = try $ do
name <- surrounded (char '"') inline
char ':'
url <- manyTill nonspaceChar (char ']')
- return $ Link name (url, "")
-
--- | Detect plain links to http or email.
-autoLink :: Parser [Char] ParserState Inline
-autoLink = do
- (orig, src) <- (try uri <|> try emailAddress)
- return $ Link [Str orig] (src, "")
+ let name' = if name == [Str "$"] then [Str url] else name
+ return $ Link name' (url, "")
-- | image embedding
image :: Parser [Char] ParserState Inline