lots of langfilter stuff, mostly lántas script
This commit is contained in:
parent
4a177d7828
commit
ba5522187c
8 changed files with 348 additions and 132 deletions
37
langfilter/Main.hs
Normal file
37
langfilter/Main.hs
Normal file
|
@ -0,0 +1,37 @@
|
|||
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
|
||||
lang' <- toLang $ Map.lookup "lang" m
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue