HTML writer: avoid doubled style attribute...
when height and width are added to style because of an image, but the image already has a style attribute. Closes #8047.
This commit is contained in:
parent
c05f95773d
commit
c1105e6b06
2 changed files with 11 additions and 7 deletions
|
@ -686,19 +686,13 @@ attrsToHtml opts (id',classes',keyvals) = do
|
|||
imgAttrsToHtml :: PandocMonad m
|
||||
=> WriterOptions -> Attr -> StateT WriterState m [Attribute]
|
||||
imgAttrsToHtml opts attr = do
|
||||
attrs <- attrsToHtml opts (ident,cls,kvs')
|
||||
dimattrs <- toAttrs (dimensionsToAttrList attr)
|
||||
return $ attrs ++ dimattrs
|
||||
attrsToHtml opts (ident,cls, consolidateStyles (kvs' ++ dimensionsToAttrList attr))
|
||||
where
|
||||
(ident,cls,kvs) = attr
|
||||
kvs' = filter isNotDim kvs
|
||||
isNotDim ("width", _) = False
|
||||
isNotDim ("height", _) = False
|
||||
isNotDim _ = True
|
||||
|
||||
dimensionsToAttrList :: Attr -> [(Text, Text)]
|
||||
dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height
|
||||
where
|
||||
consolidateStyles :: [(Text, Text)] -> [(Text, Text)]
|
||||
consolidateStyles xs =
|
||||
case partition isStyle xs of
|
||||
|
@ -706,6 +700,10 @@ dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height
|
|||
(ss, rest) -> ("style", T.intercalate ";" $ map snd ss) : rest
|
||||
isStyle ("style", _) = True
|
||||
isStyle _ = False
|
||||
|
||||
dimensionsToAttrList :: Attr -> [(Text, Text)]
|
||||
dimensionsToAttrList attr = go Width ++ go Height
|
||||
where
|
||||
go dir = case dimension dir attr of
|
||||
(Just (Pixel a)) -> [(tshow dir, tshow a)]
|
||||
(Just x) -> [("style", tshow dir <> ":" <> tshow x)]
|
||||
|
|
6
test/command/8047.md
Normal file
6
test/command/8047.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
```
|
||||
% pandoc --wrap=none
|
||||
![](file.jpg){height=10em width=10em style='border: 1px solid black'}
|
||||
^D
|
||||
<p><img src="file.jpg" style="border: 1px solid black;width:10em;height:10em" /></p>
|
||||
```
|
Loading…
Add table
Reference in a new issue