diff options
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 4e4bc3fb0..dcf0c5f4a 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -376,11 +376,17 @@ preformatted = try $ do spacesStr _ = False if F.all spacesStr contents then return mempty - else return $ B.para $ walk strToCode contents - -strToCode :: Inline -> Inline -strToCode (Str s) = Code ("",[],[]) s -strToCode x = x + else return $ B.para $ encode contents + +encode :: Inlines -> Inlines +encode = B.fromList . normalizeCode . B.toList . walk strToCode + where strToCode (Str s) = Code ("",[],[]) s + strToCode Space = Code ("",[],[]) " " + strToCode x = x + normalizeCode [] = [] + normalizeCode (Code a1 x : Code a2 y : zs) | a1 == a2 = + normalizeCode $ (Code a1 (x ++ y)) : zs + normalizeCode (x:xs) = x : normalizeCode xs header :: MWParser Blocks header = try $ do @@ -545,8 +551,8 @@ inlineTag = do TagOpen "del" _ -> B.strikeout <$> inlinesInTags "del" TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub" TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup" - TagOpen "code" _ -> walk strToCode <$> inlinesInTags "code" - TagOpen "tt" _ -> walk strToCode <$> inlinesInTags "tt" + TagOpen "code" _ -> encode <$> inlinesInTags "code" + TagOpen "tt" _ -> encode <$> inlinesInTags "tt" TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask" _ -> B.rawInline "html" . snd <$> htmlTag (~== tag) |