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