@@ -541,6 +541,12 @@ directive' = do
541541 body <- option "" $ try $ blanklines >> indentedBlock
542542 optional blanklines
543543 let body' = body ++ "\n\n"
544+ imgAttr cl = ("", classes, getAtt "width" ++ getAtt "height")
545+ where
546+ classes = words $ maybe "" trim $ lookup cl fields
547+ getAtt k = case lookup k fields of
548+ Just v -> [(k, filter (not . isSpace) v)]
549+ Nothing -> []
544550 case label of
545551 "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
546552 "role" -> addNewRole top $ map (\(k,v) -> (k, trim v)) fields
@@ -590,15 +596,16 @@ directive' = do
590596 "figure" -> do
591597 (caption, legend) <- parseFromString extractCaption body'
592598 let src = escapeURI $ trim top
593− return $ B.para (B.image src "fig:" caption) <> legend
599+ return $ B.para (B.imageWith (imgAttr "figclass") src "fig:" caption) <> legend
594600 "image" -> do
595601 let src = escapeURI $ trim top
596602 let alt = B.str $ maybe "image" trim $ lookup "alt" fields
603+ let attr = imgAttr "class"
597604 return $ B.para
598605 $ case lookup "target" fields of
599606 Just t -> B.link (escapeURI $ trim t) ""
600− $ B.image src "" alt
601− Nothing -> B.image src "" alt
607+ $ B.imageWith attr src "" alt
608+ Nothing -> B.imageWith attr src "" alt
602609 "class" -> do
603610 let attrs = ("", (splitBy isSpace $ trim top), map (\(k,v) -> (k, trimr v)) fields)
604611 -- directive content or the first immediately following element
@@ -812,10 +819,10 @@ substKey = try $ do
812819 res <- B.toList <$> directive'
813820 il <- case res of
814821 -- use alt unless :alt: attribute on image:
815− [Para [Image _ [Str "image"] (src,tit)]] ->
816− return $ B.image src tit alt
817− [Para [Link _ [Image _ [Str "image"] (src,tit)] (src',tit')]] ->
818− return $ B.link src' tit' (B.image src tit alt)
822+ [Para [Image attr [Str "image"] (src,tit)]] ->
823+ return $ B.imageWith attr src tit alt
824+ [Para [Link _ [Image attr [Str "image"] (src,tit)] (src',tit')]] ->
825+ return $ B.link src' tit' (B.imageWith attr src tit alt)
819826 [Para ils] -> return $ B.fromList ils
820827 _ -> mzero
821828 let key = toKey $ stripFirstAndLast ref