@@ -35,7 +35,6 @@ TODO:
3535- Page breaks (five "*")
3636- Org tables
3737- table.el tables
38−- Floating images
3938- <cite> tag
4039-}
4140module Text.Pandoc.Readers.Muse (readMuse) where
@@ -965,18 +964,31 @@ explicitLink = try $ do
965964image :: PandocMonad m => MuseParser m (F Inlines)
966965image = try $ do
967966 string "[["
968− (url, (ext, width)) <- manyUntil (noneOf "]") $ (imageExtensionAndOptions <* char ']')
967+ (url, (ext, width, align)) <- manyUntil (noneOf "]") $ (imageExtensionAndOptions <* char ']')
969968 content <- optionMaybe linkContent
970969 char ']'
971− let widthAttr = maybeToList (("width",) . (++ "%") <$> width)
972− return $ B.imageWith ("", [], widthAttr) (url ++ ext) mempty <$> fromMaybe (return mempty) content
970+ let widthAttr = case align of
971+ Just 'f' -> [("width", (fromMaybe "100" width) ++ "%"), ("height", "75%")]
972+ _ -> maybeToList (("width",) . (++ "%") <$> width)
973+ let alignClass = case align of
974+ Just 'r' -> ["align-right"]
975+ Just 'l' -> ["align-left"]
976+ Just 'f' -> []
977+ Nothing -> []
978+ return $ B.imageWith ("", alignClass, widthAttr) (url ++ ext) mempty <$> fromMaybe (return mempty) content
973979 where -- Taken from muse-image-regexp defined in Emacs Muse file lisp/muse-regexps.el
974980 imageExtensions = [".eps", ".gif", ".jpg", ".jpeg", ".pbm", ".png", ".tiff", ".xbm", ".xpm"]
975981 imageExtension = choice (try . string <$> imageExtensions)
976982 imageExtensionAndOptions = do
977983 ext <- imageExtension
978− width <- optionMaybe (many1 spaceChar *> many1 digit)
979− return (ext, width)
984+ (width, align) <- option (Nothing, Nothing) imageAttrs
985+ return (ext, width, align)
986+ imageAttrs = do
987+ many1 spaceChar
988+ width <- optionMaybe (many1 digit)
989+ many spaceChar
990+ align <- optionMaybe (oneOf "rlf")
991+ return (width, align)
980992
981993link :: PandocMonad m => MuseParser m (F Inlines)
982994link = try $ do