Improved mediawiki reader's treatment of verbatim constructions.
Previously these yielded strings of alternating Code and Space elements; we now incorporate the spaces into the Code. Emphasis etc. is still possible inside these. Closes #3055.
This commit is contained in:
parent
3a49439202
commit
124679fd63
1 changed files with 12 additions and 6 deletions
|
@ -376,11 +376,17 @@ preformatted = try $ do
|
|||
spacesStr _ = False
|
||||
if F.all spacesStr contents
|
||||
then return mempty
|
||||
else return $ B.para $ walk strToCode contents
|
||||
else return $ B.para $ encode contents
|
||||
|
||||
strToCode :: Inline -> Inline
|
||||
strToCode (Str s) = Code ("",[],[]) s
|
||||
strToCode x = x
|
||||
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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue