lang/langfilter/Lang.hs

20 lines
563 B
Haskell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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