@@ -376,11 +376,17 @@ preformatted = try $ do
376376 spacesStr _ = False
377377 if F.all spacesStr contents
378378 then return mempty
379− else return $ B.para $ walk strToCode contents
380−
381−strToCode :: Inline -> Inline
382−strToCode (Str s) = Code ("",[],[]) s
383−strToCode x = x
379+ else return $ B.para $ encode contents
380+
381+encode :: Inlines -> Inlines
382+encode = B.fromList . normalizeCode . B.toList . walk strToCode
383+ where strToCode (Str s) = Code ("",[],[]) s
384+ strToCode Space = Code ("",[],[]) " "
385+ strToCode x = x
386+ normalizeCode [] = []
387+ normalizeCode (Code a1 x : Code a2 y : zs) | a1 == a2 =
388+ normalizeCode $ (Code a1 (x ++ y)) : zs
389+ normalizeCode (x:xs) = x : normalizeCode xs
384390
385391header :: MWParser Blocks
386392header = try $ do
@@ -545,8 +551,8 @@ inlineTag = do
545551 TagOpen "del" _ -> B.strikeout <$> inlinesInTags "del"
546552 TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub"
547553 TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup"
548− TagOpen "code" _ -> walk strToCode <$> inlinesInTags "code"
549− TagOpen "tt" _ -> walk strToCode <$> inlinesInTags "tt"
554+ TagOpen "code" _ -> encode <$> inlinesInTags "code"
555+ TagOpen "tt" _ -> encode <$> inlinesInTags "tt"
550556 TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask"
551557 _ -> B.rawInline "html" . snd <$> htmlTag (~== tag)
552558