git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2568 from mb21/readers-images
48b7d25John MacFarlane
src/Text/Pandoc/CSS.hs+1−1
@@ -10,7 +10,7 @@ import Text.Parsec.String
10ruleParser :: Parser (String, String)
10ruleParser :: Parser (String, String)
11ruleParser = do
11ruleParser = do
12 p <- many1 (noneOf ":") <* char ':'
12 p <- many1 (noneOf ":") <* char ':'
13− v <- many1 (noneOf ":;") <* char ';' <* spaces
13+ v <- many1 (noneOf ":;") <* (optional $ char ';') <* spaces
14 return (trim p, trim v)
14 return (trim p, trim v)
15
15
16styleAttrParser :: Parser [(String, String)]
16styleAttrParser :: Parser [(String, String)]
src/Text/Pandoc/Readers/Textile.hs+9−2
@@ -51,6 +51,7 @@ TODO : refactor common patterns across readers :
51
51
52
52
53module Text.Pandoc.Readers.Textile ( readTextile) where
53module Text.Pandoc.Readers.Textile ( readTextile) where
54+import Text.Pandoc.CSS
54import Text.Pandoc.Definition
55import Text.Pandoc.Definition
55import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
56import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
56import qualified Text.Pandoc.Builder as B
57import qualified Text.Pandoc.Builder as B
@@ -535,11 +536,17 @@ link = try $ do
535image :: Parser [Char] ParserState Inlines
536image :: Parser [Char] ParserState Inlines
536image = try $ do
537image = try $ do
537 char '!' >> notFollowedBy space
538 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)
539 src <- manyTill anyChar' (lookAhead $ oneOf "!(")
546 src <- manyTill anyChar' (lookAhead $ oneOf "!(")
540 alt <- option "" (try $ (char '(' >> manyTill anyChar' (char ')')))
547 alt <- option "" (try $ (char '(' >> manyTill anyChar' (char ')')))
541 char '!'
548 char '!'
542− return $ B.image src alt (B.str alt)
549+ return $ B.imageWith attr src alt (B.str alt)
543
550
544escapedInline :: Parser [Char] ParserState Inlines
551escapedInline :: Parser [Char] ParserState Inlines
545escapedInline = escapedEqs <|> escapedTag
552escapedInline = escapedEqs <|> escapedTag