@@ -541,6 +541,12 @@ directive' = do
541 body <- option "" $ try $ blanklines >> indentedBlock
541 body <- option "" $ try $ blanklines >> indentedBlock
542 optional blanklines
542 optional blanklines
543 let body' = body ++ "\n\n"
543 let body' = body ++ "\n\n"
544+ imgAttr cl = ("", classes, getAtt "width" ++ getAtt "height")
546+ classes = words $ maybe "" trim $ lookup cl fields
547+ getAtt k = case lookup k fields of
548+ Just v -> [(k, filter (not . isSpace) v)]
544 case label of
550 case label of
545 "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
551 "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
546 "role" -> addNewRole top $ map (\(k,v) -> (k, trim v)) fields
552 "role" -> addNewRole top $ map (\(k,v) -> (k, trim v)) fields
@@ -590,15 +596,16 @@ directive' = do
590 "figure" -> do
596 "figure" -> do
591 (caption, legend) <- parseFromString extractCaption body'
597 (caption, legend) <- parseFromString extractCaption body'
592 let src = escapeURI $ trim top
598 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
594 "image" -> do
600 "image" -> do
595 let src = escapeURI $ trim top
601 let src = escapeURI $ trim top
596 let alt = B.str $ maybe "image" trim $ lookup "alt" fields
602 let alt = B.str $ maybe "image" trim $ lookup "alt" fields
603+ let attr = imgAttr "class"
597 return $ B.para
604 return $ B.para
598 $ case lookup "target" fields of
605 $ case lookup "target" fields of
599 Just t -> B.link (escapeURI $ trim t) ""
606 Just t -> B.link (escapeURI $ trim t) ""
600− $ B.image src "" alt
607+ $ B.imageWith attr src "" alt
601− Nothing -> B.image src "" alt
608+ Nothing -> B.imageWith attr src "" alt
602 "class" -> do
609 "class" -> do
603 let attrs = ("", (splitBy isSpace $ trim top), map (\(k,v) -> (k, trimr v)) fields)
610 let attrs = ("", (splitBy isSpace $ trim top), map (\(k,v) -> (k, trimr v)) fields)
604 -- directive content or the first immediately following element
611 -- directive content or the first immediately following element
@@ -812,10 +819,10 @@ substKey = try $ do
812 res <- B.toList <$> directive'
819 res <- B.toList <$> directive'
813 il <- case res of
820 il <- case res of
814 -- use alt unless :alt: attribute on image:
821 -- use alt unless :alt: attribute on image:
815− [Para [Image _ [Str "image"] (src,tit)]] ->
822+ [Para [Image attr [Str "image"] (src,tit)]] ->
816− return $ B.image src tit alt
823+ return $ B.imageWith attr src tit alt
817− [Para [Link _ [Image _ [Str "image"] (src,tit)] (src',tit')]] ->
824+ [Para [Link _ [Image attr [Str "image"] (src,tit)] (src',tit')]] ->
818− return $ B.link src' tit' (B.image src tit alt)
825+ return $ B.link src' tit' (B.imageWith attr src tit alt)
819 [Para ils] -> return $ B.fromList ils
826 [Para ils] -> return $ B.fromList ils
820 _ -> mzero
827 _ -> mzero
821 let key = toKey $ stripFirstAndLast ref
828 let key = toKey $ stripFirstAndLast ref