From 99f4d7eac07cd41e3ddf70b3a6445eea356daeed Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Wed, 25 Sep 2024 23:02:59 +0200 Subject: [PATCH] fix attrs for implicit figures the syntax `![caption](path){.class}` (when interpreted as an implicit figure) attaches `class` to the `` tag. this moves it to the `
` --- langfilter/Main.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/langfilter/Main.hs b/langfilter/Main.hs index a96cacd..aa938a0 100644 --- a/langfilter/Main.hs +++ b/langfilter/Main.hs @@ -25,7 +25,8 @@ main = toJSONFilter filter where defColor <- getDefColor m let ?lang = lang let ?defColor = defColor - fmap (walk makeEbnf . + fmap (walk fixFigureClass . + walk makeEbnf . walk makeQuotes . walk (concatMap makeBlocks) . walk inlineLetterList) $ @@ -51,6 +52,11 @@ pluck1 [] _ = Nothing pluck1 (x:xs) ys = (x,) <$> pluck x ys <|> pluck1 xs ys +fixFigureClass :: Block -> Block +fixFigureClass (Figure (_, c1, a1) cap [Plain [Image (i, c2, a2) alt path]]) = + Figure (i, c1 ++ c2, a1 ++ a2) cap [Plain [Image ("", [], []) alt path]] +fixFigureClass b = b + makeBlocks :: Block -> [Block] makeBlocks (Div ("", clss, []) blks) | Just (cls, rest) <- pluck1 ["figure", "aside"] clss =