summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs9
-rw-r--r--test/Tests/Writers/Muse.hs3
2 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
index c3c1c3120..a1414abc5 100644
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -48,6 +48,7 @@ import Data.List (intersperse, transpose, isInfixOf)
import System.FilePath (takeExtension)
import Text.Pandoc.Class (PandocMonad)
import Text.Pandoc.Definition
+import Text.Pandoc.ImageSize
import Text.Pandoc.Options
import Text.Pandoc.Pretty
import Text.Pandoc.Shared
@@ -384,14 +385,18 @@ inlineToMuse (Link _ txt (src, _)) =
isImageUrl = (`elem` imageExtensions) . takeExtension
inlineToMuse (Image attr alt (source,'f':'i':'g':':':title)) =
inlineToMuse (Image attr alt (source,title))
-inlineToMuse (Image _ inlines (source, title)) = do
+inlineToMuse (Image attr inlines (source, title)) = do
+ opts <- gets stOptions
alt <- inlineListToMuse inlines
let title' = if null title
then if null inlines
then ""
else "[" <> alt <> "]"
else "[" <> text title <> "]"
- return $ "[[" <> text source <> "]" <> title' <> "]"
+ let width = case dimension Width attr of
+ Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)
+ _ -> ""
+ return $ "[[" <> text (source ++ width) <> "]" <> title' <> "]"
inlineToMuse (Note contents) = do
-- add to notes in state
notes <- gets stNotes
diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs
index f330d14c5..a7d6b76ba 100644
--- a/test/Tests/Writers/Muse.hs
+++ b/test/Tests/Writers/Muse.hs
@@ -351,6 +351,9 @@ tests = [ testGroup "block elements"
=?> "[[URL:1.png]]"
]
, "image" =: image "image.png" "Image 1" (str "") =?> "[[image.png][Image 1]]"
+ , "image with width" =:
+ imageWith ("", [], [("width", "60%")]) "image.png" "Image" (str "") =?>
+ "[[image.png 60][Image]]"
, "note" =: note (plain (text "Foo"))
=?> unlines [ "[1]"
, ""