git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki reader: don't do curly quotes inside `<tt>` contexts.

Even if `+smart`. See #3585.

commit41db9e826e5be45d087b1959d6d5dbeb8389e2a7 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 25 May 2017, 09:35 (9 years ago) parente6f4636
2 files changed+26−1
src/Text/Pandoc/Readers/MediaWiki.hs+10−1 test/command/3585.md+16
src/Text/Pandoc/Readers/MediaWiki.hs+10−1
@@ -74,6 +74,7 @@ readMediaWiki opts s = do
7474 , mwHeaderMap = M.empty
7575 , mwIdentifierList = Set.empty
7676 , mwLogMessages = []
77+ , mwInTT = False
7778 }
7879 (s ++ "\n")
7980 case parsed of
@@ -87,6 +88,7 @@ data MWState = MWState { mwOptions :: ReaderOptions
8788 , mwHeaderMap :: M.Map Inlines String
8889 , mwIdentifierList :: Set.Set String
8990 , mwLogMessages :: [LogMessage]
91+ , mwInTT :: Bool
9092 }
9193
9294type MWParser m = ParserT [Char] MWState m
@@ -569,7 +571,12 @@ inlineTag = do
569571 TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub"
570572 TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup"
571573 TagOpen "code" _ -> encode <$> inlinesInTags "code"
572− TagOpen "tt" _ -> encode <$> inlinesInTags "tt"
574+ TagOpen "tt" _ -> do
575+ inTT <- mwInTT <$> getState
576+ updateState $ \st -> st{ mwInTT = True }
577+ result <- encode <$> inlinesInTags "tt"
578+ updateState $ \st -> st{ mwInTT = inTT }
579+ return result
573580 TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask"
574581 _ -> B.rawInline "html" . snd <$> htmlTag (~== tag)
575582
@@ -690,6 +697,8 @@ strong = B.strong <$> nested (inlinesBetween start end)
690697doubleQuotes :: PandocMonad m => MWParser m Inlines
691698doubleQuotes = do
692699 guardEnabled Ext_smart
700+ inTT <- mwInTT <$> getState
701+ guard (not inTT)
693702 B.doubleQuoted <$> nested (inlinesBetween openDoubleQuote closeDoubleQuote)
694703 where openDoubleQuote = sym "\"" >> lookAhead nonspaceChar
695704 closeDoubleQuote = try $ sym "\""
test/command/3585.mdnew file+16
@@ -0,0 +1,16 @@
1+```
2+% pandoc -f mediawiki+smart -t native
3+"Hello"
4+
5+Same but bzip2 it and nice it <tt>zfs send tank/storage/data/svn@daily-2014-03-20_00.00.00--2w | nice -15 bzip2 | ssh user@hyper.somewhere.org "> /storage/c-3po/tank-storage-data-svn.dmp.bz2"</tt>
6+^D
7+[Para [Quoted DoubleQuote [Str "Hello"]]
8+,Para [Str "Same",Space,Str "but",Space,Str "bzip2",Space,Str "it",Space,Str "and",Space,Str "nice",Space,Str "it",Space,Code ("",[],[]) "zfs send tank/storage/data/svn@daily-2014-03-20_00.00.00--2w | nice -15 bzip2 | ssh user@hyper.somewhere.org \"> /storage/c-3po/tank-storage-data-svn.dmp.bz2\""]]
9+```
10+
11+```
12+% pandoc -f mediawiki -t native
13+"Hello"
14+^D
15+[Para [Str "\"Hello\""]]
16+```