aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-08-28 23:33:21 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-28 23:33:21 -0700
commit2e26046e1334d85efab9cfc2775cf59a66e8b459 (patch)
tree6a76c32cbd9abe5ebe8c3734923246940030d4d9
parent05bb8ef4aa6faa6a4da3c54a0483d42b846733ca (diff)
downloadpandoc-2e26046e1334d85efab9cfc2775cf59a66e8b459.tar.gz
HTML writer: ensure we don't get two style attributes for width & height.
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 9ac37a0ba..87f61126b 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -47,7 +47,7 @@ import Control.Monad.State.Strict
import Data.Char (ord, toLower)
import Data.Text (Text)
import qualified Data.Text.Lazy as TL
-import Data.List (intersperse, isPrefixOf)
+import Data.List (intersperse, isPrefixOf, partition, intercalate)
import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing)
import Data.Monoid ((<>))
import qualified Data.Set as Set
@@ -569,8 +569,14 @@ imgAttrsToHtml opts attr = do
isNotDim _ = True
dimensionsToAttrList :: Attr -> [(String, String)]
-dimensionsToAttrList attr = (go Width) ++ (go Height)
+dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height
where
+ consolidateStyles xs =
+ case partition isStyle xs of
+ ([], _) -> xs
+ (ss, rest) -> ("style", intercalate ";" $ map snd ss) : rest
+ isStyle ("style", _) = True
+ isStyle _ = False
go dir = case (dimension dir attr) of
(Just (Pixel a)) -> [(show dir, show a)]
(Just x) -> [("style", show dir ++ ":" ++ show x)]