diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-05-25 09:35:25 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-05-25 09:35:25 +0200 |
commit | 41db9e826e5be45d087b1959d6d5dbeb8389e2a7 (patch) | |
tree | a33bef12166dceb6618a30aac1ba50a3d93e0a32 /src/Text/Pandoc/Readers | |
parent | e6f4636a2cc6a3fa5ae834528fe21280d8f0a56a (diff) | |
download | pandoc-41db9e826e5be45d087b1959d6d5dbeb8389e2a7.tar.gz |
MediaWiki reader: don't do curly quotes inside `<tt>` contexts.
Even if `+smart`.
See #3585.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index b261021e0..3f6142f00 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -74,6 +74,7 @@ readMediaWiki opts s = do , mwHeaderMap = M.empty , mwIdentifierList = Set.empty , mwLogMessages = [] + , mwInTT = False } (s ++ "\n") case parsed of @@ -87,6 +88,7 @@ data MWState = MWState { mwOptions :: ReaderOptions , mwHeaderMap :: M.Map Inlines String , mwIdentifierList :: Set.Set String , mwLogMessages :: [LogMessage] + , mwInTT :: Bool } type MWParser m = ParserT [Char] MWState m @@ -569,7 +571,12 @@ inlineTag = do TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub" TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup" TagOpen "code" _ -> encode <$> inlinesInTags "code" - TagOpen "tt" _ -> encode <$> inlinesInTags "tt" + TagOpen "tt" _ -> do + inTT <- mwInTT <$> getState + updateState $ \st -> st{ mwInTT = True } + result <- encode <$> inlinesInTags "tt" + updateState $ \st -> st{ mwInTT = inTT } + return result TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask" _ -> B.rawInline "html" . snd <$> htmlTag (~== tag) @@ -690,6 +697,8 @@ strong = B.strong <$> nested (inlinesBetween start end) doubleQuotes :: PandocMonad m => MWParser m Inlines doubleQuotes = do guardEnabled Ext_smart + inTT <- mwInTT <$> getState + guard (not inTT) B.doubleQuoted <$> nested (inlinesBetween openDoubleQuote closeDoubleQuote) where openDoubleQuote = sym "\"" >> lookAhead nonspaceChar closeDoubleQuote = try $ sym "\"" |