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 $< $@
|
||||
endef
|
||||
|
||||
$(LANGFILTER): langfilter/*.hs langfilter/langfilter.cabal
|
||||
$(LANGFILTER): langfilter/lib/*.hs langfilter/main/*.hs langfilter/langfilter.cabal
|
||||
$(cabal-exe)
|
||||
|
||||
$(LAANTAS_SCRIPT): laantas-script/*
|
||||
|
|
|
@ -7,15 +7,7 @@ license: AGPL-3.0-or-later
|
|||
author: Rhiannon Morris <rhi@rhiannon.website>
|
||||
maintainer: Rhiannon Morris <rhi@rhiannon.website>
|
||||
|
||||
executable langfilter
|
||||
hs-source-dirs: .
|
||||
main-is: Main.hs
|
||||
other-modules:
|
||||
Lang,
|
||||
Ebnf,
|
||||
Spans,
|
||||
LaantasImage,
|
||||
Glosses
|
||||
common base
|
||||
ghc-options:
|
||||
-Wall -Wno-missing-signatures -Wno-missing-pattern-synonym-signatures
|
||||
-Wno-name-shadowing
|
||||
|
@ -31,6 +23,7 @@ executable langfilter
|
|||
OverloadedStrings,
|
||||
PatternSynonyms,
|
||||
RecordWildCards,
|
||||
TupleSections,
|
||||
ViewPatterns
|
||||
build-depends:
|
||||
base >= 4.14.0.0 && < 4.21,
|
||||
|
@ -42,3 +35,20 @@ executable langfilter
|
|||
text ^>= 2.1,
|
||||
pretty-show ^>= 1.10,
|
||||
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 Ebnf
|
||||
|
@ -6,7 +6,6 @@ import Spans
|
|||
import Glosses
|
||||
|
||||
import Text.Pandoc.Definition
|
||||
import Text.Pandoc.JSON
|
||||
import Text.Pandoc.Walk
|
||||
import Data.Maybe
|
||||
import Data.Map (Map)
|
||||
|
@ -18,17 +17,16 @@ import Control.Monad
|
|||
import System.Environment
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = toJSONFilter filter where
|
||||
filter p@(Pandoc (Meta m) _) = do
|
||||
lang <- toLang $ Map.lookup "conlang" m
|
||||
defColor <- getDefColor m
|
||||
let ?lang = lang
|
||||
let ?defColor = defColor
|
||||
let f = map (walk spans . fixFigureClass . makeEbnf .
|
||||
makeQuotes . letterList) .
|
||||
concatMap (makeBlocks <=< glosses)
|
||||
pure $ walk f p
|
||||
langFilter :: Pandoc -> IO Pandoc
|
||||
langFilter p@(Pandoc (Meta m) _) = do
|
||||
lang <- toLang $ Map.lookup "conlang" m
|
||||
defColor <- getDefColor m
|
||||
let ?lang = lang
|
||||
let ?defColor = defColor
|
||||
let f = map (walk spans . fixFigureClass . makeEbnf .
|
||||
makeQuotes . letterList) .
|
||||
concatMap (makeBlocks <=< glosses)
|
||||
pure $ walk f p
|
||||
|
||||
getDefColor :: Map Text MetaValue -> IO Text
|
||||
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