blog/blog-meta/lib/FixFigures.hs
rhiannon morris 5a94aae932 make less inefficient
- do all filters in one go
- do all post lists in one run of the program
- only write files if they are changed
  (so make repeats less work)
- simplify pandoc command for meta pages
  (this might not actually make a difference)
2024-12-03 20:17:27 +01:00

21 lines
640 B
Haskell

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")])