{-# LANGUAGE TemplateHaskell #-} import Control.Lens hiding (argument) import Control.Monad (when) import Data.List (isInfixOf) import Options.Applicative import System.Directory (findExecutable) import System.Exit (die) import System.FilePath (takeBaseName, (>)) import System.IO.Temp import System.Process data Opts = Opts { _font :: String, _input :: FilePath } makeLenses ''Opts optsParser :: Parser Opts optsParser = Opts <$> strOption (long "font" <> metavar "FONT" <> value "Liberation Serif") <*> argument str (metavar "INPUT") narrowToContent :: String -> (String, String, String) narrowToContent full = (body, notes ++ "", footer) where ls = lines full body = unlines . takeWhile (\x -> not . isInfixOf "