diff options
author | John MacFarlane <jgm@berkeley.edu> | 2012-07-13 14:01:56 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2012-07-13 14:01:56 -0700 |
commit | f68b05e74b7cc0dd0e217cc2650169a3fe7a41a0 (patch) | |
tree | 31bd85fce44ffdca4ec937debfdac4ca88f030aa /src | |
parent | 2192f02e19942c45828b7a506ca3a2b8b8b74f9d (diff) | |
download | pandoc-f68b05e74b7cc0dd0e217cc2650169a3fe7a41a0.tar.gz |
Textile reader: properly handle links with surrounding brackets.
Square brackets need to be used when the link isn't surrounded by
spaces or punctuation, or when the URL ending may be ambiguous.
Closes #564.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 348900d38..9f6289289 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -466,12 +466,25 @@ rawLaTeXInline' = try $ do failIfStrict rawLaTeXInline --- | Textile standard link syntax is "label":target +-- | Textile standard link syntax is "label":target. But we +-- can also have ["label":target]. link :: GenParser Char ParserState Inline -link = try $ do +link = linkB <|> linkNoB + +linkNoB :: GenParser Char ParserState Inline +linkNoB = try $ do + name <- surrounded (char '"') inline + char ':' + let stopChars = "!.,;:" + url <- manyTill nonspaceChar (lookAhead $ space <|> try (oneOf stopChars >> (space <|> newline))) + return $ Link name (url, "") + +linkB :: GenParser Char ParserState Inline +linkB = try $ do + char '[' name <- surrounded (char '"') inline char ':' - url <- manyTill (anyChar) (lookAhead $ (space <|> try (oneOf ".;,:" >> (space <|> newline)))) + url <- manyTill nonspaceChar (char ']') return $ Link name (url, "") -- | Detect plain links to http or email. |