git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: ensure we don't get two style attributes for width & height.
commit2e26046e1334d85efab9cfc2775cf59a66e8b459 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 28 Aug 2017, 23:33 (9 years ago) parent05bb8ef
1 file changed+8−2
src/Text/Pandoc/Writers/HTML.hs+8−2
src/Text/Pandoc/Writers/HTML.hs+8−2
@@ -47,7 +47,7 @@ import Control.Monad.State.Strict
4747import Data.Char (ord, toLower)
4848import Data.Text (Text)
4949import qualified Data.Text.Lazy as TL
50−import Data.List (intersperse, isPrefixOf)
50+import Data.List (intersperse, isPrefixOf, partition, intercalate)
5151import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing)
5252import Data.Monoid ((<>))
5353import qualified Data.Set as Set
@@ -569,8 +569,14 @@ imgAttrsToHtml opts attr = do
569569 isNotDim _ = True
570570
571571dimensionsToAttrList :: Attr -> [(String, String)]
572−dimensionsToAttrList attr = (go Width) ++ (go Height)
572+dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height
573573 where
574+ consolidateStyles xs =
575+ case partition isStyle xs of
576+ ([], _) -> xs
577+ (ss, rest) -> ("style", intercalate ";" $ map snd ss) : rest
578+ isStyle ("style", _) = True
579+ isStyle _ = False
574580 go dir = case (dimension dir attr) of
575581 (Just (Pixel a)) -> [(show dir, show a)]
576582 (Just x) -> [("style", show dir ++ ":" ++ show x)]