lhs2TeX-hl (empty) → 0.1.0.9
raw patch · 6 files changed
+173/−0 lines, 6 filesdep +Agdadep +MissingHdep +basesetup-changed
Dependencies added: Agda, MissingH, base, cmdargs, haskell-src-exts, haskell98, syb
Files
- LICENSE +19/−0
- LiterateHighlighter.hs +50/−0
- README +58/−0
- Setup.hs +4/−0
- examples/theme1.tex +17/−0
- lhs2TeX-hl.cabal +25/−0
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2010 Alessandro Vermeulen <me@alessandrovermeulen.me>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ LiterateHighlighter.hs view
@@ -0,0 +1,50 @@+module Main where++import Data.List++import System( getArgs )+import System.IO+++import Language.Haskell.Exts++-----------------------------++import Base.CLI+import System.Console.CmdArgs++import Literate.Agda+import Literate.Haskell +import Literate.SimpleInfo++-----------------------------+++main = do args <- cmdArgsRun standard++ hSetEncoding stdin utf8+ hSetEncoding stdout utf8+ hSetEncoding stderr utf8+ + hOutput <- openFile (output args) WriteMode+ hSetEncoding hOutput utf8++ let writer = writeOutput hOutput+ + if (agda_mode args)+ then+ mapM_ (\file -> runAgda file+ >>= (flip writer) Literate.Agda.mapping)+ (input args)+ else+ mapM_ (\file -> runHaskell file+ >>= (flip writer) Literate.Haskell.mapping)+ (input args)+ + hClose hOutput+ where printFormat keyword seek rep = "%format " ++ seek ++ " = \" {\\lhsCH" ++ keyword ++ "{" ++ rep ++ "}}\"" + writeOutput output si mapping = + mapM_ (\(keyword, f) -> mapM_ (\ (seek,rep) -> hPutStrLn output $ printFormat keyword seek rep) + (f si)) + mapping+
+ README view
@@ -0,0 +1,58 @@+ Literate HS to TeX Highlighter Helper+ =====================================+ + Hi there,+ + This is the very first release of the lhs2tex helper for syntax highlighting.+ Use it in addition with lhs2tex. Due to a huge demand I make this tool + publicly available. Use it your own risk. I am not responsible for any+ conveniences or inconveniences caused by using this software.+ + It aims to detect the `kind' of a token either by it's use or it's+ declaration. Trying to detect both local declarations and usages.+ + Regards,+ Alessandro Vermeulen+ + INSTALLING+ ----------+ + * Download the zip file.+ * Extract+ * Go to the directory and run+ > cabal install+ + * That's all+ + USAGE+ -----+ + > lhs2TeX-hl INPUTFILE -o OUTPUTFILE+ + For more details see:+ + > lhs2TeX-hl --help+ + Currently this is the only way to work with the tool.+ + In your .tex files add %include OUTPUFILE to tell lhs2tex to use the generated+ formatting directives. You'll need to provide the following commands yourself:+ + * \lhsCHkeyword+ * \lhsCHprelude+ * \lhsCHtype+ * \lhsCHlitNumber+ * \lhsCHconstructor+ * \lhsCHfunction+ * \lhsCHinfixoperator+ + KNOWN ISSUES+ ------------+ + * Infix operators may not work that great, or normal functions that are used+ `infix`.+ * It doesn't do literal string and char highlighting yet.+ * AGDA isn't supported yet unfortunately.+ * Errors aren't that informative. :)+ +
+ Setup.hs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++import Distribution.Simple+main = defaultMain
+ examples/theme1.tex view
@@ -0,0 +1,17 @@+% usepackage color+\definecolor{datatype}{RGB}{42,0,217}+\definecolor{class}{RGB}{197,11,16}+\definecolor{fieldname}{RGB}{0,0,162}+\definecolor{prelude}{RGB}{64,80,117}+\definecolor{numeral}{RGB}{0,0,205}+\definecolor{infixoperator}{RGB}{42,0,217}+\definecolor{constructor}{RGB}{0,161,0}+\definecolor{keyword}{RGB}{229,120,0}+\definecolor{special1}{RGB}{159,138,0}++\newcommand{\lhsCHfunction}[1]{\color{infixoperator}{\mathbf{#1}}}+\newcommand{\lhsCHprelude}[1]{\color{prelude}{\mathbf{#1}}}+\newcommand{\lhsCHkeyword}[1]{\color{keyword}{\textbf{#1}}}+\newcommand{\lhsCHconstructor}[1]{\color{constructor}{{#1}}}+\newcommand{\lhsCHlitNumber}[1]{\color{numeral}{{#1}}}+\newcommand{\lhsCHtype}[1]{\color{datatype}{{#1}}}
+ lhs2TeX-hl.cabal view
@@ -0,0 +1,25 @@+Name: lhs2TeX-hl+Version: 0.1.0.9+Cabal-Version: >= 1.6+License: MIT+Author: Alessandro Vermeulen <me@alessandrovermeulen.me>+Maintainer: Alessandro Vermeulen <me@alessandrovermeulen.me>+Synopsis: Literate highlighter preprocessor for lhs2tex +Description: A helper executable for highlighting code with lhs2tex. It+ parses any haskell file and outputs a format file to be used+ with lhs2tex. Currently no recursion is supported.+Build-Type: Simple+Stability: Expirimental+category: Development, Language+Data-files: README examples/theme1.tex+License-file: LICENSE++Executable lhs2TeX-hl+ Main-Is: LiterateHighlighter.hs+ Build-Depends: base >= 4 && <= 5+ , haskell98+ , haskell-src-exts >= 1.9.3+ , MissingH >= 1.1.0.3+ , syb >= 0.1.0.1+ , Agda >= 2.2.6+ , cmdargs >= 0.1