2021-04-29 05:52:44 -04:00
|
|
|
import Lang
|
|
|
|
import Ebnf
|
|
|
|
import Spans
|
|
|
|
import Glosses
|
|
|
|
|
|
|
|
import Text.Pandoc.Definition
|
|
|
|
import Text.Pandoc.JSON
|
|
|
|
import Text.Pandoc.Walk
|
|
|
|
import qualified Data.Map as Map
|
|
|
|
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = toJSONFilter filter where
|
|
|
|
filter p@(Pandoc (Meta m) _) = do
|
2021-04-29 13:37:01 -04:00
|
|
|
lang' <- toLang $ Map.lookup "conlang" m
|
2021-04-29 05:52:44 -04:00
|
|
|
let ?lang = lang'
|
|
|
|
fmap (walk makeEbnf .
|
|
|
|
walk (concatMap makeFigures) .
|
|
|
|
walk inlineLetterList) $
|
|
|
|
walkM spans =<<
|
|
|
|
walkM (fmap concat . traverse glosses) p
|
|
|
|
|
|
|
|
|
|
|
|
makeFigures :: Block -> [Block]
|
|
|
|
makeFigures (Div ("", ["figure"], []) blks) =
|
|
|
|
[html "<figure>"] ++ blks ++ [html "</figure>"]
|
|
|
|
where html = RawBlock (Format "html")
|
|
|
|
makeFigures b = [b]
|
|
|
|
|
|
|
|
|
|
|
|
inlineLetterList :: Block -> Block
|
|
|
|
inlineLetterList (Div a@(_, cs, _) blks)
|
|
|
|
| "letter-list" `elem` cs = Div a (walk go blks)
|
|
|
|
where
|
|
|
|
go (Para xs) = Plain xs
|
|
|
|
go b = b
|
|
|
|
inlineLetterList b = b
|