From 3e8630c88e339c40da449421d192100cc836481c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 15 Sep 2012 16:55:42 -0400 Subject: MediaWiki reader: Added smart doublequotes with -S option. Also disallow ' in the "trail" of an internal link; allowing it causes bugs with `'''[[Link]]'''`. --- src/Text/Pandoc/Readers/MediaWiki.hs | 12 ++++++++++-- 1 file 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 + -- cgit v1.2.3