haskintex 0.5.0.3 → 0.5.1.0
raw patch · 2 files changed
+27/−9 lines, 2 filesdep ~haskell-src-extsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: haskell-src-exts
API changes (from Hackage documentation)
- Haskintex: instance Show Syntax
+ Haskintex: instance GHC.Show.Show Haskintex.Syntax
Files
- Haskintex.hs +24/−8
- haskintex.cabal +3/−1
Haskintex.hs view
@@ -40,6 +40,7 @@ import Data.Typeable import qualified Language.Haskell.Exts.Pretty as H import qualified Language.Haskell.Exts.Parser as H+import qualified Language.Haskell.Exts.Syntax as H -- Map import qualified Data.Map as M -- Binary@@ -98,6 +99,7 @@ , debugFlag :: Bool , memoFlag :: Bool , memocleanFlag :: Bool+ , autotexyFlag :: Bool , unknownFlags :: [String] , inputs :: [FilePath] , memoTree :: MemoTree@@ -116,10 +118,11 @@ , ("debug" , debugFlag) , ("memo" , memoFlag) , ("memoclean" , memocleanFlag)+ , ("autotexy" , autotexyFlag) ] readConf :: [String] -> Conf-readConf = go $ Conf False False False False False False False False False False False [] [] M.empty+readConf = go $ Conf False False False False False False False False False False False False [] [] M.empty where go c [] = c go c (x:xs) =@@ -138,6 +141,7 @@ "debug" -> go (c {debugFlag = True}) xs "memo" -> go (c {memoFlag = True}) xs "memoclean" -> go (c {memocleanFlag = True}) xs+ "autotexy" -> go (c {autotexyFlag = True}) xs _ -> go (c {unknownFlags = unknownFlags c ++ [flag]}) xs -- Otherwise, an input file. _ -> go (c {inputs = inputs c ++ [x]}) xs@@ -177,10 +181,12 @@ xs = [ string "memo" >> return True , string "notmemo" >> return False ] -processExp :: Text -> Text-processExp t =- case H.parseExp (unpack t) of- H.ParseOk e -> pack $ H.prettyPrint e +processExp :: (H.Exp -> H.Exp) -- ^ Transformation to apply to Haskell Expression+ -> Text -- ^ Haskell expression+ -> Parser Text+processExp f t = do+ return $ case H.parseExp (unpack t) of+ H.ParseOk e -> pack $ H.prettyPrint $ f e _ -> t p_inserthatex :: Bool -- False for pure, True for IO@@ -194,7 +200,12 @@ b <- readMemo _ <- char '{' h <- p_haskell 0- return $ cons b $ processExp $ pack h+ auto <- lift $ autotexyFlag <$> get+ let v = H.Var . H.UnQual . H.Ident+ f = if auto then H.App $ if isIO then v "fmap" `H.App` v "texy"+ else v "texy" + else id+ cons b <$> processExp f (pack h) p_evalhaskell :: Parser Syntax p_evalhaskell = choice [ p_evalhaskellenv, p_evalhaskellcomm ]@@ -204,7 +215,7 @@ _ <- try $ string "\\begin{evalhaskell}" b <- readMemo h <- manyTill anyChar $ try $ string "\\end{evalhaskell}"- return $ EvalHaskell True b $ processExp $ pack h+ EvalHaskell True b <$> processExp id (pack h) p_evalhaskellcomm :: Parser Syntax p_evalhaskellcomm = do@@ -212,7 +223,7 @@ b <- readMemo _ <- char '{' h <- p_haskell 0- return $ EvalHaskell False b $ processExp $ pack h+ EvalHaskell False b <$> processExp id (pack h) p_haskell :: Int -> Parser String p_haskell n = choice [@@ -638,6 +649,11 @@ , " -memoclean Cleans the memo tree after the execution of haskintex. If " , " several files are processed, the memo tree will be cleaned" , " after processing all of them."+ , ""+ , " -autotexy Apply the function texy from HaTeX to every expression in a hatex"+ , " or iohatex command. This effectively allows the user to write"+ , " expressions in types other than LaTeX and have haskintex to perform"+ , " the required transformation." , "" , "Any unsupported flag will be ignored." ]
haskintex.cabal view
@@ -1,5 +1,5 @@ name: haskintex-version: 0.5.0.3+version: 0.5.1.0 synopsis: Haskell Evaluation inside of LaTeX code. description: The /haskintex/ (Haskell in LaTeX) program is a tool that reads a LaTeX file and evaluates Haskell expressions contained@@ -8,6 +8,8 @@ Additionally, it is possible to include expressions of 'LaTeX' type (see /HaTeX/ package) and render them as LaTeX code. You can freely add any Haskell code you need, and make this code appear /optionally/ in the LaTeX output. It is a tiny program, and therefore, easy to understand, use and predict.+ .+ Addition from last version: new flag autotexy. See project homepage for description. homepage: http://daniel-diaz.github.io/projects/haskintex bug-reports: https://github.com/Daniel-Diaz/haskintex/issues license: BSD3