aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-09-15 16:55:42 -0400
committerJohn MacFarlane <jgm@berkeley.edu>2012-09-15 16:56:01 -0400
commit3e8630c88e339c40da449421d192100cc836481c (patch)
tree7ded40cc4767494703cabee0564b549bd0f6de35
parent0cd2289eea62bbfef3d1837ea0f9f7101a2a8746 (diff)
downloadpandoc-3e8630c88e339c40da449421d192100cc836481c.tar.gz
MediaWiki reader: Added smart doublequotes with -S option.
Also disallow ' in the "trail" of an internal link; allowing it causes bugs with `'''[[Link]]'''`.
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
index f6192ffc6..38ffed835 100644
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -89,7 +89,7 @@ nested p = do
return res
specialChars :: [Char]
-specialChars = "'[]<=&*{}|"
+specialChars = "'[]<=&*{}|\""
spaceChars :: [Char]
spaceChars = " \n\t"
@@ -445,6 +445,7 @@ inline :: MWParser Inlines
inline = whitespace
<|> url
<|> str
+ <|> doubleQuotes
<|> strong
<|> emph
<|> image
@@ -540,7 +541,7 @@ internalLink = try $ do
-- [[Help:Contents|] -> "Contents"
<|> (return $ B.text $ drop 1 $ dropWhile (/=':') pagename) )
sym "]]"
- linktrail <- B.text <$> many (char '\'' <|> letter)
+ linktrail <- B.text <$> many letter
let link = B.link (addUnderscores pagename) "wikilink" (label <> linktrail)
if "Category:" `isPrefixOf` pagename
then do
@@ -582,3 +583,10 @@ strong = B.strong <$> nested (inlinesBetween start end)
where start = sym "'''" >> lookAhead nonspaceChar
end = try $ sym "'''"
+doubleQuotes :: MWParser Inlines
+doubleQuotes = B.doubleQuoted . trimInlines . mconcat <$> try
+ ((getState >>= guard . readerSmart . mwOptions) *>
+ openDoubleQuote *> manyTill inline closeDoubleQuote )
+ where openDoubleQuote = char '"' <* lookAhead alphaNum
+ closeDoubleQuote = char '"' <* notFollowedBy alphaNum
+