git.iko.soy/typeable/pandoc
on master help sign in
Textile Reader: image attributes

closes #2515

commitd901a3da03ee1cfef09ea3001a2917ce6e2896a2 authormb21 <mb21@users.noreply.github.com> dateThu 3 Dec 2015, 00:06 (11 years ago) parent1f379da
1 file changed+9−2
src/Text/Pandoc/Readers/Textile.hs+9−2
src/Text/Pandoc/Readers/Textile.hs+9−2
@@ -51,6 +51,7 @@ TODO : refactor common patterns across readers :
5151
5252
5353module Text.Pandoc.Readers.Textile ( readTextile) where
54+import Text.Pandoc.CSS
5455import Text.Pandoc.Definition
5556import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
5657import qualified Text.Pandoc.Builder as B
@@ -535,11 +536,17 @@ link = try $ do
535536image :: Parser [Char] ParserState Inlines
536537image = try $ do
537538 char '!' >> notFollowedBy space
538− _ <- attributes -- ignore for now, until we have image attributes
539+ (ident, cls, kvs) <- attributes
540+ let getAtt k styles = case pickStyleAttrProps [k] styles of
541+ Just v -> [(k, v)]
542+ Nothing -> []
543+ let attr = case lookup "style" kvs of
544+ Just stls -> (ident, cls, getAtt "width" stls ++ getAtt "height" stls)
545+ Nothing -> (ident, cls, kvs)
539546 src <- manyTill anyChar' (lookAhead $ oneOf "!(")
540547 alt <- option "" (try $ (char '(' >> manyTill anyChar' (char ')')))
541548 char '!'
542− return $ B.image src alt (B.str alt)
549+ return $ B.imageWith attr src alt (B.str alt)
543550
544551escapedInline :: Parser [Char] ParserState Inlines
545552escapedInline = escapedEqs <|> escapedTag