-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Functions for running Tex from Haskell. -- -- texrunner is an interface to tex that attempts to parse errors and can -- parse tex in online mode to retrieve hbox sizes. -- -- This package should be considered very experimental. Eventually I hope -- it will be good enough for general use but for now it's only suitable -- for simple things. @package texrunner @version 0.0.2 -- | Functions for parsing Tex output and logs. This log is parser is -- experimental and largely untested. Please make an issue for any logs -- that aren't parsed properly. module System.Texrunner.Parse -- | Data type for holding dimensions of a hbox. It is likely the internal -- representation will change to allow nested boxes in the future. data Box n Box :: n -> n -> n -> Box n [boxHeight] :: Box n -> n [boxDepth] :: Box n -> n [boxWidth] :: Box n -> n parseBox :: Fractional n => Parser (Box n) data TexLog TexLog :: TexInfo -> Maybe Int -> [TexError] -> ByteString -> TexLog [texInfo] :: TexLog -> TexInfo [numPages] :: TexLog -> Maybe Int [texErrors] :: TexLog -> [TexError] [rawLog] :: TexLog -> ByteString data TexInfo TexInfo :: Maybe ByteString -> Maybe ByteString -> Maybe ByteString -> TexInfo [texCommand] :: TexInfo -> Maybe ByteString [texVersion] :: TexInfo -> Maybe ByteString [texDistribution] :: TexInfo -> Maybe ByteString -- | An error from tex with possible line number. data TexError TexError :: Maybe Int -> TexError' -> TexError [errorLine] :: TexError -> Maybe Int [error'] :: TexError -> TexError' -- | A subset of possible error Tex can throw. data TexError' UndefinedControlSequence :: ByteString -> TexError' MissingNumber :: TexError' Missing :: Char -> TexError' IllegalUnit :: TexError' PackageError :: String -> String -> TexError' LatexError :: ByteString -> TexError' BadBox :: ByteString -> TexError' EmergencyStop :: TexError' ParagraphEnded :: TexError' TooMany :: ByteString -> TexError' DimensionTooLarge :: TexError' TooManyErrors :: TexError' NumberTooBig :: TexError' ExtraBrace :: TexError' FatalError :: ByteString -> TexError' UnknownError :: ByteString -> TexError' -- | Parse any line beginning with "! ". Any unknown errors are returned as -- UnknownError. someError :: Parser TexError badBox :: Parser TexError parseUnit :: Fractional n => Parser n parseLog :: ByteString -> TexLog prettyPrintLog :: TexLog -> ByteString instance GHC.Show.Show n => GHC.Show.Show (System.Texrunner.Parse.Box n) instance GHC.Show.Show System.Texrunner.Parse.TexInfo instance GHC.Classes.Eq System.Texrunner.Parse.TexError' instance GHC.Read.Read System.Texrunner.Parse.TexError' instance GHC.Show.Show System.Texrunner.Parse.TexError' instance GHC.Show.Show System.Texrunner.Parse.TexError instance GHC.Show.Show System.Texrunner.Parse.TexLog instance GHC.Base.Semigroup System.Texrunner.Parse.TexLog instance GHC.Base.Monoid System.Texrunner.Parse.TexLog instance GHC.Classes.Eq System.Texrunner.Parse.TexError -- | Functions for running and parsing using Tex's online interface. This -- is mostly used for getting measurements like hbox dimensions and -- textwidth. -- -- Tex's online interface is basically running the command line. You can -- see it by running pdflatex without any arguments. The -- contents can be written line by and tex can give feedback though -- stdout, which gets parsed in by this module. This is the only way I -- know to get info like hbox sizes. Please let me know if you know a -- better way. module System.Texrunner.Online -- | Type for dealing with Tex's piping interface; the current streams are -- available though the MonadReader instance. data OnlineTex a -- | Run a tex process, discarding the resulting PDF. runOnlineTex :: String -> [String] -> ByteString -> OnlineTex a -> IO a -- | Run a tex process, keeping the resulting PDF. The OnlineTex must -- receive the terminating control sequence (\bye, \end{document}, -- \stoptext). runOnlineTex' :: String -> [String] -> ByteString -> OnlineTex a -> IO (a, TexLog, Maybe ByteString) -- | Get the dimensions of a hbox. hbox :: Fractional n => ByteString -> OnlineTex (Box n) -- | Dimensions from filling the current line. hsize :: Fractional n => OnlineTex n -- | Parse result from showthe. showthe :: Fractional n => ByteString -> OnlineTex n -- | Run an Attoparsec parser on Tex's output. onlineTexParser :: Parser a -> OnlineTex a texPutStrLn :: ByteString -> OnlineTex () type TexStreams = (OutputStream ByteString, InputStream ByteString) -- | Get the input stream to give text to tex. getInStream :: OnlineTex (InputStream ByteString) -- | Get the output stream to read tex's output. getOutStream :: OnlineTex (OutputStream ByteString) -- | Clear any output tex has already given. clearUnblocking :: OnlineTex () instance Control.Monad.Reader.Class.MonadReader System.Texrunner.Online.TexStreams System.Texrunner.Online.OnlineTex instance Control.Monad.IO.Class.MonadIO System.Texrunner.Online.OnlineTex instance GHC.Base.Monad System.Texrunner.Online.OnlineTex instance GHC.Base.Applicative System.Texrunner.Online.OnlineTex instance GHC.Base.Functor System.Texrunner.Online.OnlineTex -- | Functions for running Tex. module System.Texrunner -- | Same as runTex' but runs Tex in a temporary system directory. runTex :: String -> [String] -> [FilePath] -> ByteString -> IO (ExitCode, TexLog, Maybe ByteString) -- | Run Tex program in the given directory. Additional Tex inputs are for -- filepaths to things like images that Tex can refer to. runTex' :: FilePath -> String -> [String] -> [FilePath] -> ByteString -> IO (ExitCode, TexLog, Maybe ByteString) prettyPrintLog :: TexLog -> ByteString