librarify langfilter too
This commit is contained in:
parent
1098cbdc1b
commit
89270a82fb
9 changed files with 35 additions and 23 deletions
2
Makefile
2
Makefile
|
@ -55,7 +55,7 @@ define copy
|
||||||
cp $< $@
|
cp $< $@
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(LANGFILTER): langfilter/*.hs langfilter/langfilter.cabal
|
$(LANGFILTER): langfilter/lib/*.hs langfilter/main/*.hs langfilter/langfilter.cabal
|
||||||
$(cabal-exe)
|
$(cabal-exe)
|
||||||
|
|
||||||
$(LAANTAS_SCRIPT): laantas-script/*
|
$(LAANTAS_SCRIPT): laantas-script/*
|
||||||
|
|
|
@ -7,15 +7,7 @@ license: AGPL-3.0-or-later
|
||||||
author: Rhiannon Morris <rhi@rhiannon.website>
|
author: Rhiannon Morris <rhi@rhiannon.website>
|
||||||
maintainer: Rhiannon Morris <rhi@rhiannon.website>
|
maintainer: Rhiannon Morris <rhi@rhiannon.website>
|
||||||
|
|
||||||
executable langfilter
|
common base
|
||||||
hs-source-dirs: .
|
|
||||||
main-is: Main.hs
|
|
||||||
other-modules:
|
|
||||||
Lang,
|
|
||||||
Ebnf,
|
|
||||||
Spans,
|
|
||||||
LaantasImage,
|
|
||||||
Glosses
|
|
||||||
ghc-options:
|
ghc-options:
|
||||||
-Wall -Wno-missing-signatures -Wno-missing-pattern-synonym-signatures
|
-Wall -Wno-missing-signatures -Wno-missing-pattern-synonym-signatures
|
||||||
-Wno-name-shadowing
|
-Wno-name-shadowing
|
||||||
|
@ -31,6 +23,7 @@ executable langfilter
|
||||||
OverloadedStrings,
|
OverloadedStrings,
|
||||||
PatternSynonyms,
|
PatternSynonyms,
|
||||||
RecordWildCards,
|
RecordWildCards,
|
||||||
|
TupleSections,
|
||||||
ViewPatterns
|
ViewPatterns
|
||||||
build-depends:
|
build-depends:
|
||||||
base >= 4.14.0.0 && < 4.21,
|
base >= 4.14.0.0 && < 4.21,
|
||||||
|
@ -42,3 +35,20 @@ executable langfilter
|
||||||
text ^>= 2.1,
|
text ^>= 2.1,
|
||||||
pretty-show ^>= 1.10,
|
pretty-show ^>= 1.10,
|
||||||
laantas-script
|
laantas-script
|
||||||
|
|
||||||
|
library
|
||||||
|
import: base
|
||||||
|
hs-source-dirs: lib
|
||||||
|
exposed-modules:
|
||||||
|
Lang,
|
||||||
|
Ebnf,
|
||||||
|
Spans,
|
||||||
|
LaantasImage,
|
||||||
|
Glosses,
|
||||||
|
LangFilter
|
||||||
|
|
||||||
|
executable langfilter
|
||||||
|
import: base
|
||||||
|
hs-source-dirs: main
|
||||||
|
main-is: Main.hs
|
||||||
|
build-depends: langfilter
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{-# LANGUAGE TupleSections #-}
|
module LangFilter where
|
||||||
|
|
||||||
import Lang
|
import Lang
|
||||||
import Ebnf
|
import Ebnf
|
||||||
|
@ -6,7 +6,6 @@ import Spans
|
||||||
import Glosses
|
import Glosses
|
||||||
|
|
||||||
import Text.Pandoc.Definition
|
import Text.Pandoc.Definition
|
||||||
import Text.Pandoc.JSON
|
|
||||||
import Text.Pandoc.Walk
|
import Text.Pandoc.Walk
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Map (Map)
|
import Data.Map (Map)
|
||||||
|
@ -18,17 +17,16 @@ import Control.Monad
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
|
||||||
|
|
||||||
main :: IO ()
|
langFilter :: Pandoc -> IO Pandoc
|
||||||
main = toJSONFilter filter where
|
langFilter p@(Pandoc (Meta m) _) = do
|
||||||
filter p@(Pandoc (Meta m) _) = do
|
lang <- toLang $ Map.lookup "conlang" m
|
||||||
lang <- toLang $ Map.lookup "conlang" m
|
defColor <- getDefColor m
|
||||||
defColor <- getDefColor m
|
let ?lang = lang
|
||||||
let ?lang = lang
|
let ?defColor = defColor
|
||||||
let ?defColor = defColor
|
let f = map (walk spans . fixFigureClass . makeEbnf .
|
||||||
let f = map (walk spans . fixFigureClass . makeEbnf .
|
makeQuotes . letterList) .
|
||||||
makeQuotes . letterList) .
|
concatMap (makeBlocks <=< glosses)
|
||||||
concatMap (makeBlocks <=< glosses)
|
pure $ walk f p
|
||||||
pure $ walk f p
|
|
||||||
|
|
||||||
getDefColor :: Map Text MetaValue -> IO Text
|
getDefColor :: Map Text MetaValue -> IO Text
|
||||||
getDefColor m = do
|
getDefColor m = do
|
4
langfilter/main/Main.hs
Normal file
4
langfilter/main/Main.hs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import LangFilter
|
||||||
|
import Text.Pandoc.JSON
|
||||||
|
|
||||||
|
main = toJSONFilter langFilter
|
Loading…
Add table
Reference in a new issue