only walk once

This commit is contained in:
Rhiannon Morris 2024-11-28 01:54:36 +01:00
parent 6c9d04489c
commit b1ef3fc82d

View file

@ -25,14 +25,10 @@ main = toJSONFilter filter where
defColor <- getDefColor m defColor <- getDefColor m
let ?lang = lang let ?lang = lang
let ?defColor = defColor let ?defColor = defColor
pure $ let f = map (walk spans . fixFigureClass . makeEbnf .
walk fixFigureClass $ makeQuotes . letterList) .
walk makeEbnf $ concatMap (makeBlocks <=< glosses)
walk makeQuotes $ pure $ walk f p
walk (concatMap makeBlocks) $
walk inlineLetterList $
walk spans $
walk (concat . map glosses) p
getDefColor :: Map Text MetaValue -> IO Text getDefColor :: Map Text MetaValue -> IO Text
getDefColor m = do getDefColor m = do
@ -86,11 +82,10 @@ makeQuotes para@(Para b) = fromMaybe para $ do
checkEnd _ = empty checkEnd _ = empty
makeQuotes other = other makeQuotes other = other
letterList :: Block -> Block
inlineLetterList :: Block -> Block letterList (Div a@(_, cs, _) blks)
inlineLetterList (Div a@(_, cs, _) blks)
| "letter-list" `elem` cs = Div a (walk go blks) | "letter-list" `elem` cs = Div a (walk go blks)
where where
go (Para xs) = Plain xs go (Para xs) = Plain xs
go b = b go b = b
inlineLetterList b = b letterList b = b