pass other classes/id thru with gloss

This commit is contained in:
Rhiannon Morris 2021-04-29 19:02:20 +02:00
parent 7a205bc6bd
commit 0adea5d063

View file

@ -9,16 +9,20 @@ import Text.Pandoc.Builder
import Text.Pandoc.Walk import Text.Pandoc.Walk
import Data.Maybe import Data.Maybe
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as Text
glosses :: Vars => Block -> IO [Block] glosses :: Vars => Block -> IO [Block]
glosses = \case glosses = \case
Div (_, cs, _) blocks | "glosses" `elem` cs -> do Div (i, cs, _) blocks | "glosses" `elem` cs -> do
tables <- traverse glossTable blocks tables <- traverse glossTable blocks
pure $ pure $
[RawBlock (Format "html") "<figure class=glosses>"] ++ [RawBlock (Format "html") $ "<figure" <> id <> classes <> ">"] ++
catMaybes tables ++ catMaybes tables ++
[RawBlock (Format "html") "</figure>"] [RawBlock (Format "html") "</figure>"]
where
id = if i == "" then "" else " id=\"" <> i <> "\""
classes = " class=\"" <> Text.unwords cs <> "\""
b -> pure [b] b -> pure [b]
pattern Gloss l g w t = BulletList [[Plain l], [Plain g], [Plain w], [Plain t]] pattern Gloss l g w t = BulletList [[Plain l], [Plain g], [Plain w], [Plain t]]