lang/langfilter/Lang.hs

20 lines
563 B
Haskell
Raw Normal View History

module Lang where
import Text.Pandoc.Definition
import Data.Char (toLower)
import qualified Data.Text as Text
import System.IO
data Lang = Lántas deriving (Eq, Show)
type Vars = (?lang :: Maybe Lang)
toLang :: Maybe MetaValue -> IO (Maybe Lang)
toLang (Just (MetaInlines [Str s])) = toLang (Just (MetaString s)) -- ugh
toLang (Just (MetaString (Text.map toLower -> s)))
| s == "lántas" || s == "laantas" = pure $ Just Lántas
toLang Nothing = pure Nothing
toLang (Just ) = do
hPutStrLn stderr $ "[WARN] unknown language: " <> show
pure Nothing