module FixFigures (fixFigures, expandable, shaped) where import Text.Pandoc.Definition fixFigures :: Block -> Block fixFigures = expandable . shaped expandable :: Block -> Block expandable (Figure attr@(_, cs, _) cap [Plain img@[Image _ _ t]]) | "expandable" `elem` cs = Figure attr cap $ [Plain [Link blank img t]] expandable b = b shaped :: Block -> Block shaped (Figure (i, cs, as) cap [Plain img@[Image _ _ (url, _)]]) | "shaped" `elem` cs = let shape = "shape-outside: url(" <> url <> ")" in Figure (i, cs, ("style", shape) : as) cap [Plain img] shaped b = b blank :: Attr blank = ("", [], [("target", "_blank")])