packages feed

HaTeX 3.9.1.0 → 3.10.0.0

raw patch · 8 files changed

+104/−38 lines, 8 filesdep ~attoparsecdep ~base

Dependency ranges changed: attoparsec, base

Files

HaTeX.cabal view
@@ -1,5 +1,5 @@ Name: HaTeX
-Version: 3.9.1.0
+Version: 3.10.0.0
 Author: Daniel Díaz
 Category: Text, LaTeX
 Build-type: Simple
@@ -47,7 +47,7 @@                , bytestring >= 0.9.2.1 && < 0.11
                , transformers >= 0.2.2 && < 0.4
                , text >= 0.11.2.3 && < 2
-               , attoparsec >= 0.10.2 && < 0.11
+               , attoparsec >= 0.10.2 && < 0.12
                , matrix
                , containers >= 0.4.2.1 && < 0.6
   Exposed-modules:
@@ -72,6 +72,7 @@         Text.LaTeX.Packages.Color
         Text.LaTeX.Packages.Fancyhdr
         Text.LaTeX.Packages.Fontenc
+        Text.LaTeX.Packages.Geometry
         Text.LaTeX.Packages.Graphicx
         Text.LaTeX.Packages.Hyperref
         Text.LaTeX.Packages.Inputenc
Text/LaTeX/Base/Commands.hs view
@@ -216,6 +216,10 @@ -- | Insert a raw piece of 'Text'. -- This functions doesn't care about @LaTeX@ reserved characters, -- it insert the text just as it is received.+--+-- /Warning:/ This function is /unsafe/, in the sense that it does+-- not check that the input text is a valid LaTeX /block/.+-- Make sure any braces, commands or environments are properly closed. raw :: LaTeXC l => Text -> l raw = fromLaTeX . TeXRaw @@ -235,6 +239,10 @@ -- -- > textbf "I'm just an example." %: "Insert a few words here." --+-- The implementation is+--+-- > (%:) l = (l <>) . comment+-- -- Since you are writing in Haskell, you may not need to output comments -- as you can add them in the Haskell source. I added this feature -- for completeness. It may be useful for debugging the output as well.@@ -248,15 +256,15 @@  -- | Set the title of your document. title :: LaTeXC l => l -> l-title = liftL $ \t -> TeXComm "title" [FixArg t]+title = comm1 "title"  -- | Set a date for your document. date :: LaTeXC l => l -> l-date = liftL $ \t -> TeXComm "date" [FixArg t]+date = comm1 "date"  -- | Set the author(s) of the document. author :: LaTeXC l => l -> l-author = liftL $ \t -> TeXComm "author" [FixArg t]+author = comm1 "author"  -- | Set either an institute or an organization -- for the document. It does /not/ work for@@ -266,7 +274,7 @@ institute (Just s) = liftL2 (\l1 l2 -> TeXComm "institute" [OptArg l1,FixArg l2]) s  thanks :: LaTeXC l => l -> l-thanks = liftL $ \l -> TeXComm "thanks" [FixArg l]+thanks = comm1 "thanks"  -- | Import a package. First argument is a list of options for -- the package named in the second argument.@@ -286,30 +294,30 @@ newline = comm0 "newline"  part :: LaTeXC l => l -> l-part = liftL $ \p -> TeXComm "part" [FixArg p]+part = comm1 "part"  chapter :: LaTeXC l => l -> l-chapter = liftL $ \c -> TeXComm "chapter" [FixArg c]+chapter = comm1 "chapter"  -- | Start a new section with a given title. section :: LaTeXC l => l -> l-section = liftL $ \s -> TeXComm "section" [FixArg s]+section = comm1 "section"  -- | Start a new subsection. subsection :: LaTeXC l => l -> l-subsection = liftL $ \sub -> TeXComm "subsection" [FixArg sub]+subsection = comm1 "subsection"  -- | Start a new sub/sub/section. subsubsection :: LaTeXC l => l -> l-subsubsection = liftL $ \sub -> TeXComm "subsubsection" [FixArg sub]+subsubsection = comm1 "subsubsection"  -- | Start a paragraph. paragraph :: LaTeXC l => l -> l-paragraph = liftL $ \p -> TeXComm "paragraph" [FixArg p]+paragraph = comm1 "paragraph"  -- | Start a subparagraph (minimal level of sectioning). subparagraph :: LaTeXC l => l -> l-subparagraph = liftL $ \p -> TeXComm "subparagraph" [FixArg p]+subparagraph = comm1 "subparagraph"  -- | Create the table of contents, automatically generated -- from your 'section's, 'subsection's, and other related stuff.
Text/LaTeX/Base/Parser.hs view
@@ -15,7 +15,6 @@   , latexParser   , latexBlockParser   , latexAtOnce-  , latexDocParser #ifdef _TEST   , specials #endif@@ -50,31 +49,15 @@  {-# DEPRECATED latexAtOnce "Use parseLaTeX instead." #-} +-- | Same as 'parseLaTeX'. latexAtOnce :: Text -> Either String LaTeX latexAtOnce = parseLaTeX  --------------------------------------------------------------------------- | Incremental Parser that terminates after the /document/ envionment--------------------------------------------------------------------------latexDocParser :: Parser LaTeX-latexDocParser = blockTillDoc-------------------------------------------------------------------------- -- | Incremental 'LaTeX' parser. ------------------------------------------------------------------------ latexParser :: Parser LaTeX latexParser = mconcat <$> latexBlockParser `manyTill` endOfInput --blockTillDoc :: Parser LaTeX-blockTillDoc = do-  b <- latexBlockParser-  if isMainDoc b then return  b-                 else mappend b <$> blockTillDoc---- | Test if a 'LaTeX' block is a @document@ environment.-isMainDoc :: LaTeX -> Bool-isMainDoc (TeXEnv "document" _ _) = True-isMainDoc _ = False  -- | Parser of a single 'LaTeX' constructor, no appending blocks. latexBlockParser :: Parser LaTeX
Text/LaTeX/Base/Render.hs view
@@ -163,5 +163,10 @@   render = fromString . showFloat
 instance Render Word8 where
 
+-- | 'Render' instance for 'Bool'. It satisfies @render True = "true"@ and @render False = "false"@.
+instance Render Bool where
+  render True = "true"
+  render _ = "false"
+
 instance Render a => Render [a] where
  render xs = "[" <> renderCommas xs <> "]"
Text/LaTeX/Base/Syntax.hs view
@@ -1,5 +1,5 @@ 
-{-# LANGUAGE CPP #-}
+{-# LANGUAGE CPP, DeriveDataTypeable #-}
 
 -- | LaTeX syntax description in the definition of the 'LaTeX' datatype.
 --   If you want to add new commands or environments not defined in
@@ -75,7 +75,7 @@                       -- Use '<>' preferably.
  | TeXEmpty -- ^ An empty block.
             -- /Neutral element/ of '<>'.
-   deriving (Eq,Show)
+   deriving (Eq,Show,Typeable)
 
 -- | An argument for a 'LaTeX' command or environment.
 data TeXArg =
@@ -127,9 +127,6 @@ protectChar '\\' = "\\textbackslash{}"
 protectChar '_'  = "\\_{}"
 protectChar x = [x]
-
-instance Typeable LaTeX where
-  typeOf _ = mkTyConApp (mkTyCon3 "HaTeX" "Text.LaTeX.Base.Syntax" "LaTeX") []
 
 -- Syntax analysis
 
+ Text/LaTeX/Packages/Geometry.hs view
@@ -0,0 +1,57 @@++{-# LANGUAGE OverloadedStrings #-}++-- | The geometry package provides an easy interface to page dimensions.+--+-- CTAN page for geometry: <http://www.ctan.org/pkg/geometry>.+module Text.LaTeX.Packages.Geometry (+    -- * Geometry package+    geometry+  , importGeometry+    -- * Geometry options+  , GeometryOption (..)+  , applyGeometry+  ) where++import Text.LaTeX+import Text.LaTeX.Base.Syntax+import Text.LaTeX.Base.Class++-- | Geometry package. Use it to import it like this:+--+-- > usepackage [] geometry+--+-- In most cases, it is recommended to use 'importGeometry' instead.+geometry :: PackageName+geometry = "geometry"++-- | Options of the geometry package.+data GeometryOption = +    GHeight Measure+  | GWidth  Measure+  | GPaper PaperType+  | GCentered+  | GPaperHeight Measure+  | GPaperWidth Measure+  | GLandscape Bool+    deriving Show++renderOption :: Render a => Text -> a -> Text+renderOption t x = t <> "=" <> render x++instance Render GeometryOption where+  render (GHeight m) = renderOption "height" m+  render (GWidth  m) = renderOption "width"  m+  render (GPaper  p) = render (Paper p)+  render GCentered   = "centered"+  render (GPaperHeight m) = renderOption "paperheight" m+  render (GPaperWidth m) = renderOption "paperwidth" m+  render (GLandscape b) = renderOption "landscape" b++-- | Apply the given geometry options to the document.+applyGeometry :: LaTeXC l => [GeometryOption] -> l+applyGeometry opts = fromLaTeX $ TeXComm "geometry" [FixArg $ raw $ renderCommas opts]++-- | Import the geometry package with additional options.+importGeometry :: LaTeXC l => [GeometryOption] -> l+importGeometry opts = usepackage (fmap rendertex opts) geometry
+ parsertest/example3.tex view
@@ -0,0 +1,15 @@+\documentclass{article}+\begin{document}++\section{Math formulae}++$\lambda (2+2) = 4$++\[\lambda (2+2) = 4\]++\(\lambda (2+2) = 4\)++\begin{displaymath}+\lambda (2+2) = 4+\end{displaymath}+\end{document}
parsertest/parsertest.hs view
@@ -4,7 +4,7 @@ import qualified Data.Text.IO as T  testNumbers :: [Int]-testNumbers = [1 .. 2]+testNumbers = [1 .. 3]  testFile :: Int -> IO Bool testFile i = do@@ -15,7 +15,7 @@                    putStrLn $ "The error was: " ++ err                    return False     Right _  -> putStrLn "Succeed." >> return True-  + main :: IO () main = do   putStrLn "Running Parser Test..."