HaTeX 3.16.2.0 → 3.17.0.0
raw patch · 11 files changed
+334/−33 lines, 11 filesdep ~basedep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, transformers
API changes (from Hackage documentation)
+ Text.LaTeX.Base.Commands: array :: LaTeXC l => Maybe Pos -> [TableSpec] -> l -> l
+ Text.LaTeX.Base.Commands: baselineskip :: LaTeXC l => l
+ Text.LaTeX.Base.Commands: textheight :: LaTeXC l => l
+ Text.LaTeX.Base.Parser: ParserConf :: [String] -> ParserConf
+ Text.LaTeX.Base.Parser: [verbatimEnvironments] :: ParserConf -> [String]
+ Text.LaTeX.Base.Parser: data ParserConf
+ Text.LaTeX.Base.Parser: defaultParserConf :: ParserConf
+ Text.LaTeX.Base.Parser: parseLaTeXFileWith :: ParserConf -> FilePath -> IO (Either ParseError LaTeX)
+ Text.LaTeX.Base.Parser: parseLaTeXWith :: ParserConf -> Text -> Either ParseError LaTeX
+ Text.LaTeX.Base.Parser: type Parser = Parsec Text ParserConf
+ Text.LaTeX.Packages.AMSFonts: mathfrak :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.AMSFonts: timagPart :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.AMSFonts: trealPart :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.AMSMath: (!^) :: LaTeXC l => l -> (l, l) -> l
+ Text.LaTeX.Packages.AMSMath: (+-) :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.AMSMath: (-+) :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.AMSMath: bot :: LaTeXC l => l
+ Text.LaTeX.Packages.AMSMath: cases :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.AMSMath: parallel :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.AMSMath: perp :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.AMSMath: text :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.AMSMath: tfrac :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.Hyperref: OneColumn :: PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: SinglePage :: PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: TwoColumnLeft :: PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: TwoColumnRight :: PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: TwoPageLeft :: PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: TwoPageRight :: PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: data PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: instance GHC.Classes.Eq Text.LaTeX.Packages.Hyperref.PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: instance GHC.Classes.Ord Text.LaTeX.Packages.Hyperref.PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: instance GHC.Read.Read Text.LaTeX.Packages.Hyperref.PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: instance GHC.Show.Show Text.LaTeX.Packages.Hyperref.PdfPageLayout
+ Text.LaTeX.Packages.Hyperref: pdfauthor :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.Hyperref: pdfcreator :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.Hyperref: pdfkeywords :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.Hyperref: pdfpagelayout :: LaTeXC l => PdfPageLayout -> l
+ Text.LaTeX.Packages.Hyperref: pdfproducer :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.Hyperref: pdfstartpage :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.Hyperref: pdfsubject :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.Hyperref: pdftex :: LaTeXC l => l
+ Text.LaTeX.Packages.Hyperref: pdftitle :: LaTeXC l => l -> l
+ Text.LaTeX.Packages.Hyperref: pdftrapped :: LaTeXC l => Maybe Bool -> l
+ Text.LaTeX.Packages.QRCode: CodeOptions :: Bool -> Bool -> ErrorLevel -> CodeOptions
+ Text.LaTeX.Packages.QRCode: High :: ErrorLevel
+ Text.LaTeX.Packages.QRCode: Low :: ErrorLevel
+ Text.LaTeX.Packages.QRCode: Medium :: ErrorLevel
+ Text.LaTeX.Packages.QRCode: Quality :: ErrorLevel
+ Text.LaTeX.Packages.QRCode: [errorLevel] :: CodeOptions -> ErrorLevel
+ Text.LaTeX.Packages.QRCode: [includePadding] :: CodeOptions -> Bool
+ Text.LaTeX.Packages.QRCode: [link] :: CodeOptions -> Bool
+ Text.LaTeX.Packages.QRCode: data CodeOptions
+ Text.LaTeX.Packages.QRCode: data ErrorLevel
+ Text.LaTeX.Packages.QRCode: defaultOptions :: CodeOptions
+ Text.LaTeX.Packages.QRCode: draft :: LaTeXC l => l
+ Text.LaTeX.Packages.QRCode: final :: LaTeXC l => l
+ Text.LaTeX.Packages.QRCode: instance GHC.Classes.Eq Text.LaTeX.Packages.QRCode.CodeOptions
+ Text.LaTeX.Packages.QRCode: instance GHC.Classes.Eq Text.LaTeX.Packages.QRCode.ErrorLevel
+ Text.LaTeX.Packages.QRCode: instance GHC.Classes.Ord Text.LaTeX.Packages.QRCode.ErrorLevel
+ Text.LaTeX.Packages.QRCode: instance GHC.Read.Read Text.LaTeX.Packages.QRCode.ErrorLevel
+ Text.LaTeX.Packages.QRCode: instance GHC.Show.Show Text.LaTeX.Packages.QRCode.CodeOptions
+ Text.LaTeX.Packages.QRCode: instance GHC.Show.Show Text.LaTeX.Packages.QRCode.ErrorLevel
+ Text.LaTeX.Packages.QRCode: qr :: LaTeXC l => CodeOptions -> Text -> l
+ Text.LaTeX.Packages.QRCode: qrcode :: PackageName
Files
- CHANGELOG.md +15/−1
- HaTeX.cabal +3/−2
- README.md +5/−2
- Text/LaTeX/Base/Commands.hs +20/−0
- Text/LaTeX/Base/Parser.hs +60/−14
- Text/LaTeX/Packages/AMSFonts.hs +15/−2
- Text/LaTeX/Packages/AMSMath.hs +56/−10
- Text/LaTeX/Packages/Hyperref.hs +69/−0
- Text/LaTeX/Packages/QRCode.hs +81/−0
- parsertest/example6.tex +8/−0
- parsertest/parsertest.hs +2/−2
CHANGELOG.md view
@@ -1,13 +1,27 @@ # HaTeX Changelog -This is the logchange of HaTeX. It might not be exhaustive.+This is the logchange of HaTeX. It is not exhaustive. For a full list of changes, see the commit history of the git repository: https://github.com/Daniel-Diaz/HaTeX/commits/master # Changelog by versions++## From 3.16.2.0 to 3.17.0.0++* New 'array' command (NorfairKing).+* Added package options for the hyperref package related to PDF metadata (dmcclean).+* QRCode module (dmcclean).+* New math symbols (leftaroundabout).+* Added 'cases' environment (NorfairKing).+* Changed the way subscripts and superscripts work.+ See [#67](https://github.com/Daniel-Diaz/HaTeX/pull/67).+ Also [#78](https://github.com/Daniel-Diaz/HaTeX/pull/78).+* LaTeX parser is now configurable.+ Currently, only configurable option is verbatim+ environments. ## From 3.16.1.1 to 3.16.2.0
HaTeX.cabal view
@@ -1,5 +1,5 @@ Name: HaTeX -Version: 3.16.2.0 +Version: 3.17.0.0 Author: Daniel Díaz Category: LaTeX Build-type: Simple @@ -62,7 +62,7 @@ Build-depends: base == 4.* , bytestring >= 0.9.2.1 && < 0.11 , text >= 0.11.2.3 && < 2 - , transformers >= 0.2.2 && < 0.5 + , transformers >= 0.2.2 && < 0.6 , containers >= 0.4.2.1 && < 0.6 , matrix -- Testing @@ -99,6 +99,7 @@ Text.LaTeX.Packages.Graphicx Text.LaTeX.Packages.Hyperref Text.LaTeX.Packages.Inputenc + Text.LaTeX.Packages.QRCode Text.LaTeX.Packages.Relsize -- Trees Text.LaTeX.Packages.Trees
README.md view
@@ -10,8 +10,11 @@ ## Installation notes -To install `HaTeX`, use [cabal-install](http://hackage.haskell.org/package/cabal-install).+To install `HaTeX`, use [cabal-install](http://hackage.haskell.org/package/cabal-install)+or [stack](http://docs.haskellstack.org/en/stable/README). +To install with cabal, run:+ $ cabal update $ cabal install HaTeX @@ -70,7 +73,7 @@ ## Travis automatic build -Every time code changes in the GitHub repository, an automatic build checks that the library compiles with several+For every code push to the GitHub repository, an automatic build checks that the library compiles with several versions of GHC (7.4, 7.6, and 7.8) and that all tests pass. This label indicates the result of the last automatic build.
Text/LaTeX/Base/Commands.hs view
@@ -118,10 +118,12 @@ , stretch , smallskip , bigskip+ , baselineskip , indent , noindent -- *** Document measures , textwidth+ , textheight , linewidth -- ** Formatting text , verbatim , verb@@ -189,6 +191,7 @@ , pageref -- ** Tables , tabular+ , array , (&) , hline , cline@@ -692,6 +695,9 @@ linespread :: LaTeXC l => Float -> l linespread x = fromLaTeX $ TeXComm "linespread" [FixArg $ rendertex x] +baselineskip :: LaTeXC l => l+baselineskip = comm0 "baselineskip"+ indent :: LaTeXC l => l indent = comm0 "indent" @@ -724,6 +730,9 @@ textwidth :: LaTeXC l => l textwidth = comm0 "textwidth" +textheight :: LaTeXC l => l+textheight = comm0 "textheight"+ linewidth :: LaTeXC l => l linewidth = comm0 "linewidth" @@ -854,6 +863,17 @@ -> l -- ^ Resulting table syntax. tabular Nothing ts = liftL $ TeXEnv "tabular" [ FixArg $ TeXRaw $ renderAppend ts ] tabular (Just p) ts = liftL $ TeXEnv "tabular" [ OptArg $ TeXRaw $ render p , FixArg $ TeXRaw $ renderAppend ts ]+++-- | Like 'tabular' but in math mode by default+array :: LaTeXC l =>+ Maybe Pos -- ^ This optional parameter can be used to specify the vertical position of the table.+ -- Defaulted to 'Center'.+ -> [TableSpec] -- ^ Table specification of columns and vertical lines.+ -> l -- ^ Table content. See '&', 'lnbk', 'hline' and 'cline'.+ -> l -- ^ Resulting table syntax.+array Nothing ts = liftL $ TeXEnv "array" [ FixArg $ TeXRaw $ renderAppend ts ]+array (Just p) ts = liftL $ TeXEnv "array" [ OptArg $ TeXRaw $ render p , FixArg $ TeXRaw $ renderAppend ts ] -- | Column separator. (&) :: LaTeXC l => l -> l -> l
Text/LaTeX/Base/Parser.hs view
@@ -25,8 +25,6 @@ -- * The parser parseLaTeX , parseLaTeXFile- , latexParser- , latexBlockParser -- * Parsing errors , ParseError , errorPos@@ -39,10 +37,18 @@ , sourceLine , sourceColumn , sourceName+ -- * Configuring your parser+ , ParserConf (..)+ , defaultParserConf+ , parseLaTeXWith+ , parseLaTeXFileWith+ -- * Parser combinators+ , Parser+ , latexParser+ , latexBlockParser ) where import Text.Parsec hiding ((<|>),many)-import Text.Parsec.Text import Text.Parsec.Error import Data.Char (toLower,digitToInt) import Data.Monoid@@ -55,16 +61,52 @@ import Text.LaTeX.Base.Syntax import Text.LaTeX.Base.Render +------------------------------------------------------------------------+-- Parser configuration+------------------------------------------------------------------------++-- | Configuration for the LaTeX parser.+data ParserConf = ParserConf+ { -- | This is the list of names of the environments such that+ -- their content will be parsed verbatim.+ verbatimEnvironments :: [String]+ }++-- | Default parser configuration, used by 'parseLaTeX' and 'parseLaTeXFile'.+--+-- Defaults:+--+-- > verbatimEnvironments = ["verbatim"]+--+defaultParserConf :: ParserConf+defaultParserConf = ParserConf+ { verbatimEnvironments = ["verbatim"]+ }++-- | Parser with 'Text' input and 'ParserConf' environment.+type Parser = Parsec Text ParserConf++------------------------------------------------------------------------+-- Parser+------------------------------------------------------------------------+ -- | Parse a 'Text' sequence as a 'LaTeX' block. If it fails, it returns -- an error string. parseLaTeX :: Text -> Either ParseError LaTeX-parseLaTeX t | T.null t = return TeXEmpty- | otherwise = parse latexParser "parseLaTeX input" t+parseLaTeX = parseLaTeXWith defaultParserConf +parseLaTeXWith :: ParserConf -> Text -> Either ParseError LaTeX+parseLaTeXWith conf t+ | T.null t = return TeXEmpty+ | otherwise = runParser latexParser conf "parseLaTeX input" t+ -- | Read a file and parse it as 'LaTeX'. parseLaTeXFile :: FilePath -> IO (Either ParseError LaTeX)-parseLaTeXFile fp = parse latexParser fp <$> readFileTex fp+parseLaTeXFile = parseLaTeXFileWith defaultParserConf +parseLaTeXFileWith :: ParserConf -> FilePath -> IO (Either ParseError LaTeX)+parseLaTeXFileWith conf fp = runParser latexParser conf fp <$> readFileTex fp+ -- | The 'LaTeX' parser. latexParser :: Parser LaTeX latexParser = mconcat <$> latexBlockParser `manyTill` eof@@ -123,12 +165,16 @@ sps <- many $ char ' ' let lsps = if null sps then mempty else TeXRaw $ T.pack sps as <- cmdArgs- b <- envBody n - return $ TeXEnv n (fromMaybe [] as) $- case as of- Just [] -> lsps <> TeXBraces mempty <> b- Nothing -> lsps <> b- _ -> b+ verbatims <- verbatimEnvironments <$> getState+ if n `elem` verbatims+ then let endenv = try $ string "\\end" >> spaces >> string ("{" <> n <> "}")+ in TeXEnv n (fromMaybe [] as) . TeXRaw . T.pack <$> manyTill anyChar endenv+ else do b <- envBody n + return $ TeXEnv n (fromMaybe [] as) $+ case as of+ Just [] -> lsps <> TeXBraces mempty <> b+ Nothing -> lsps <> b+ _ -> b envName :: String -> Parser String envName k = do@@ -139,8 +185,8 @@ return $ T.unpack n envBody :: String -> Parser LaTeX-envBody n = mconcat <$> (bodyBlock n) `manyTill` endenv- where endenv = try $ string ("\\end") >> spaces >> string ("{" <> n <> "}")+envBody n = mconcat <$> bodyBlock n `manyTill` endenv+ where endenv = try $ string "\\end" >> spaces >> string ("{" <> n <> "}") bodyBlock :: String -> Parser LaTeX bodyBlock n = do
Text/LaTeX/Packages/AMSFonts.hs view
@@ -4,13 +4,16 @@ ( -- * AMSFonts package amsfonts -- * Fonts- , mathbb+ , mathbb, mathfrak -- * Number sets- , naturals, integers, rationals, reals, complexes+ , naturals, integers, rationals, reals+ -- ** Complex numbers+ , complexes, trealPart, timagPart ) where import Text.LaTeX.Base.Class import Text.LaTeX.Base.Types+import Data.Monoid -- | AMSFonts package. -- Example:@@ -34,6 +37,10 @@ mathbb :: LaTeXC l => l -> l mathbb = comm1 "mathbb" +-- | Fraktur font.+mathfrak :: LaTeXC l => l -> l+mathfrak = comm1 "mathfrak"+ -- | Number sets naturals :: LaTeXC l => l@@ -50,3 +57,9 @@ complexes :: LaTeXC l => l complexes = mathbb "C"++trealPart :: LaTeXC l => l -> l+trealPart z = comm0 "Re" <> z++timagPart :: LaTeXC l => l -> l+timagPart z = comm0 "Im" <> z
Text/LaTeX/Packages/AMSMath.hs view
@@ -9,6 +9,7 @@ , math, mathDisplay , equation , equation_ , align , align_+ , cases -- ** Referencing , eqref , nonumber -- * Symbols and utilities@@ -25,7 +26,7 @@ , lceil , rceil , dblPipe -- ** Superscript and subscript- , (^:) , (!:)+ , (^:) , (!:), (!^) -- ** Function symbols -- | Some symbols are preceded with /t/ to be distinguished from -- predefined Haskell entities (like 'sin' and 'cos').@@ -47,8 +48,9 @@ , partial, totald, partialOf, totaldOf -- ** Operator symbols -- *** Arithmetic+ , (+-), (-+) , cdot , times , div_- , frac+ , frac, tfrac , (*:) , star , circ , bullet -- *** Comparison@@ -58,6 +60,8 @@ , ll , gg , equiv , propto+ , parallel+ , perp -- *** Sets , in_ , ni , notin , subset , supset@@ -99,10 +103,12 @@ , dagger, ddagger , infty , imath, jmath+ , bot -- * Fonts , mathdefault , mathbf , mathrm+ , text , mathcal , mathsf , mathtt@@ -170,7 +176,7 @@ sqrt = tsqrt Nothing log = (tlog <>) (**) = (^:)- logBase b x = (tlog !: b) <> x+ logBase b x = (commS "log" !: b) <> x sin = (tsin <>) tan = (ttan <>) cos = (tcos <>)@@ -265,6 +271,10 @@ align_ :: LaTeXC l => [l] -> l align_ = liftL(TeXEnv "align*" []) . mconcat . intersperse lnbk +-- | The cases environment allows the writing of piecewise functions+cases :: LaTeXC l => l -> l+cases = liftL $ TeXEnv "cases" []+ ------------------------------------- ------- Symbols and utilities ------- @@ -322,12 +332,16 @@ -- | Superscript. (^:) :: LaTeXC l => l -> l -> l-x ^: y = x <> raw "^" <> braces y+x ^: y = braces x <> raw "^" <> braces y -- | Subscript. (!:) :: LaTeXC l => l -> l -> l-x !: y = x <> raw "_" <> braces y+x !: y = braces x <> raw "_" <> braces y +-- | Sub- and superscript, both stacked.+(!^) :: LaTeXC l => l -> (l,l) -> l+x !^ (y,z) = braces x <> raw "_" <> braces y <> raw "^" <> braces z+ ---- Function symbols -- | Sine function symbol.@@ -422,7 +436,7 @@ => l -- ^ Expression below the sigma. -> l -- ^ Expression above the sigma. -> l-sumFromTo x y = commS "sum" !: x ^: y+sumFromTo x y = commS "sum" <> raw"_" <> braces x <> raw"^" <> braces y -- | Pi product symbol. Use 'prodFromTo' if you want to specify the -- limits of the product.@@ -434,7 +448,7 @@ => l -- ^ Expression below the pi. -> l -- ^ Expression above the pi. -> l-prodFromTo x y = commS "prod" !: x ^: y+prodFromTo x y = commS "prod" <> raw"_" <> braces x <> raw"^" <> braces y -- | Integral symbol. Use 'integralFromTo' if you want to specify -- the limits of the integral.@@ -446,7 +460,7 @@ => l -- ^ Lower limit of integration. -> l -- ^ Upper limit of integration. -> l-integralFromTo x y = commS "int" <> commS "limits" !: x ^: y+integralFromTo x y = commS "int" <> commS "limits" <> raw"_" <> braces x <> raw"^" <> braces y -- | Partial-differentiation symbol ∂ partial :: LaTeXC l => l@@ -474,6 +488,16 @@ \l1 l2 -> (l1 <> commS "not") `op` l2 +infixl 6 +-, -+++-- | Plus-or-minus operator (±). Also available as symbol 'pm'.+(+-) :: LaTeXC l => l -> l -> l+(+-) = between $ comm0 "pm"++-- | Minus-or-plus operator (∓). Also available as symbol 'mp'.+(-+) :: LaTeXC l => l -> l -> l+(-+) = between $ comm0 "mp"+ -- | Centered-dot operator (⋅). cdot :: LaTeXC l => l -> l -> l cdot = between $ comm0 "cdot"@@ -490,6 +514,10 @@ frac :: LaTeXC l => l -> l -> l frac = liftL2 $ \p q -> TeXComm "frac" [FixArg p, FixArg q] +-- | Like 'frac' but smaller (uses subscript size for the numerator and denominator.+tfrac :: LaTeXC l => l -> l -> l+tfrac = liftL2 $ \p q -> TeXComm "tfrac" [FixArg p, FixArg q]+ infixl 7 *: -- | Asterisk operator (*).@@ -552,6 +580,14 @@ propto :: LaTeXC l => l -> l -> l propto = between $ comm0 "propto" +-- | Perpendicular (⟂). This is the infix version of 'bot'.+perp :: LaTeXC l => l -> l -> l+perp = between $ comm0 "perp"++-- | Parallel (‖).+parallel :: LaTeXC l => l -> l -> l+parallel = between $ comm0 "parallel"+ -- | Identical \/ defined-as \/ equivalent (≡). equiv :: LaTeXC l => l -> l -> l equiv = between $ comm0 "equiv"@@ -715,7 +751,7 @@ -- | Θ symbol. thetau :: LaTeXC l => l-thetau = comm0 "thetau"+thetau = comm0 "Theta" -- | /ι/ symbol. iota :: LaTeXC l => l@@ -827,7 +863,7 @@ ---- Other symbols --- | Plus-or-minus symbol (±).+-- | Plus-or-minus symbol (±). Also available as infix '+-'. pm :: LaTeXC l => l pm = comm0 "pm" @@ -875,6 +911,10 @@ jmath :: LaTeXC l => l jmath = comm0 "jmath" +-- | Bottom symbol ⟂. For the infix version see 'perp'.+bot :: LaTeXC l => l+bot = comm0 "bot"+ ------------------------------------- ------------ Math Fonts ------------- @@ -889,6 +929,12 @@ -- | Roman, i.e. not-italic math. mathrm :: LaTeXC l => l -> l mathrm = comm1 "mathrm"++-- | Escape from math mode, into a normal-text box.+-- Unlike 'mathrm', this won't squash spaces, i.e. you can write actual sentences.+-- You can embed 'math' again within such a box.+text :: LaTeXC l => l -> l+text = comm1 "text" -- | Calligraphic math symbols. mathcal :: LaTeXC l => l -> l
Text/LaTeX/Packages/Hyperref.hs view
@@ -15,12 +15,26 @@ , hyperimage , autoref , nameref+ -- * Package options+ , pdftex+ , pdftitle+ , pdfauthor+ , pdfsubject+ , pdfcreator+ , pdfproducer+ , pdfkeywords+ , pdftrapped+ , pdfstartpage+ , pdfpagelayout+ , PdfPageLayout(..) ) where import Text.LaTeX.Base.Syntax import Text.LaTeX.Base.Class+import Text.LaTeX.Base.Commands import Text.LaTeX.Base.Render import Text.LaTeX.Base.Types+import Data.Text (pack) -- | The 'hyperref' package. --@@ -85,3 +99,58 @@ -- included when importing 'hyperref'. nameref :: LaTeXC l => Label -> l nameref l = fromLaTeX $ TeXComm "nameref" [ FixArg $ rendertex l ]++-- | Creates a single-parameter package option.+packageOption :: LaTeXC l => Text -> l -> l+packageOption n p = raw n <> raw "={" <> p <> raw "}"++-- | This package option selects the pdfTeX backend for the Hyperref package.+pdftex :: LaTeXC l => l+pdftex = raw "pdftex"++-- | This package option sets the document information Title field.+pdftitle :: LaTeXC l => l -> l+pdftitle = packageOption "pdftitle"++-- | This package option sets the document information Author field.+pdfauthor :: LaTeXC l => l -> l+pdfauthor = packageOption "pdfauthor"++-- | This package option sets the document information Subject field.+pdfsubject :: LaTeXC l => l -> l+pdfsubject = packageOption "pdfsubject"++-- | This package option sets the document information Creator field.+pdfcreator :: LaTeXC l => l -> l+pdfcreator = packageOption "pdfcreator"++-- | This package option sets the document information Producer field.+pdfproducer :: LaTeXC l => l -> l+pdfproducer = packageOption "pdfproducer"++-- | This package option sets the document information Keywords field.+pdfkeywords :: LaTeXC l => l -> l+pdfkeywords = packageOption "pdfkeywords"++-- | This package option sets the document information Trapped entry.+-- An 'Nothing' value means, the entry is not set. +pdftrapped :: LaTeXC l => Maybe Bool -> l+pdftrapped Nothing = packageOption "pdftrapped" mempty+pdftrapped (Just t) = packageOption "pdftrapped" . raw . pack . show $ t++-- | This package option determines on which page the PDF file is opened.+pdfstartpage :: LaTeXC l => l -> l+pdfstartpage = packageOption "pdfstartpage"++-- | This package option sets the layout of PDF pages.+pdfpagelayout :: LaTeXC l => PdfPageLayout -> l+pdfpagelayout l = packageOption "pdfpagelayout" . raw . pack . show $ l++-- | Specification for how pages of a PDF should be displayed.+data PdfPageLayout = SinglePage -- ^ Displays a single page; advancing flips the page.+ | OneColumn -- ^ Displays a single page; advancing flips the page.+ | TwoColumnLeft -- ^ Displays the document in two columns, odd-numbered pages to the left.+ | TwoColumnRight -- ^ Displays the document in two columns, odd-numbered pages to the right.+ | TwoPageLeft -- ^ Displays two pages, odd-numbered pages to the left (since PDF 1.5).+ | TwoPageRight -- ^ Displays two pages, odd-numbered pages to the right (since PDF 1.5).+ deriving (Eq, Ord, Read, Show)
+ Text/LaTeX/Packages/QRCode.hs view
@@ -0,0 +1,81 @@++{-# LANGUAGE OverloadedStrings #-}++module Text.LaTeX.Packages.QRCode+ ( -- * qrcode package+ qrcode+ -- * qrcode commands+ , ErrorLevel(..)+ , CodeOptions(..)+ , defaultOptions+ , qr+ -- * Package Options+ , draft+ , final+ ) where++import Text.LaTeX.Base (raw)+import Text.LaTeX.Base.Syntax+import Text.LaTeX.Base.Class+import Text.LaTeX.Base.Render+import Text.LaTeX.Base.Types+import Text.LaTeX.Base.Texy+import qualified Data.Text as T+import Data.Char (toLower)++-- | qrcode package. Use it to import it like this:+--+-- > usepackage [] qrcode+qrcode :: PackageName+qrcode = "qrcode"++-- | The degree of error-correction redundancy to+-- include in the generated code.+data ErrorLevel = Low -- ^ Error recovery up to 7%.+ | Medium -- ^ Error recovery up to 15%.+ | Quality -- ^ Error recovery up to 25%.+ | High -- ^ Error recovery up to 30%.+ deriving (Eq, Ord, Read, Show)++-- | Options to use when generating a QR code.+data CodeOptions = CodeOptions {+ includePadding :: Bool -- ^ Whether to include 4 modules of whitespace around the code. False is the default.+ , link :: Bool -- ^ Whether, if the code encodes a link, it should be hyperlinked in the PDF document. The default is true. Links will only be generated when the document uses the hyperref package.+ , errorLevel :: ErrorLevel -- ^ The desired degree of error-correction redundancy to include in the code. The default is 'Medium'.+ }+ deriving (Eq, Show)++++-- | The default QR code generation options.+defaultOptions :: CodeOptions+defaultOptions = CodeOptions { includePadding = False, link = True, errorLevel = Medium }++-- | This package option sets the qrcode package to generate draft-quality placeholders for QR codes.+draft :: LaTeXC l => l+draft = "draft"++-- | This package option (which is the default) sets the qrcode package to generate print-quality QR codes.+final :: LaTeXC l => l+final = "draft"++-- | Generates a QR code with specified options and content.+--+-- This uses the \qrcode command from the package, but the identifier+-- 'qrcode' is already in use as the 'PackageName'.+qr :: LaTeXC l => CodeOptions -> Text -> l+qr opt payload = fromLaTeX $ TeXComm "qrcode" [opts, FixArg . raw . escape $ payload]+ where+ opts = MOptArg [ if includePadding opt then "padding" else "tight" + , if link opt then "link" else "nolink" + , texy . ("level=" <>) . T.singleton . toLower . head . show . errorLevel $ opt + ]++-- Helper functions for escaping code contents.+escape :: Text -> Text+escape = T.concatMap handleChar+ where handleChar c | isSpecial c = T.pack ['\\', c]+ | otherwise = T.singleton c++isSpecial :: Char -> Bool+isSpecial c = elem c ("#$&^_~% \\{}" :: String)
+ parsertest/example6.tex view
@@ -0,0 +1,8 @@+\documentclass{article}+\begin{document}+\begin{verbatim}+$ ls+$ cd directory+$ emacs file+\end{verbatim}+\end{document}
parsertest/parsertest.hs view
@@ -4,7 +4,7 @@ import System.Exit (exitSuccess, exitFailure) testNumbers :: [Int]-testNumbers = [1 .. 5]+testNumbers = [1 .. 6] testFile :: Int -> IO Bool testFile i = do@@ -14,7 +14,7 @@ Left err -> do putStrLn "Failed." putStrLn $ "The error was: " ++ show err return False- Right _ -> putStrLn "Succeed." >> return True+ Right _ -> putStrLn "Succeed." >> return True main :: IO () main = do