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
1 changed files with 6 additions and 2 deletions

View File

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