lhs2TeX-hl 0.1.2.2 → 0.1.3
raw patch · 8 files changed
+193/−88 lines, 8 filesdep ~MissingH
Dependency ranges changed: MissingH
Files
- README +0/−77
- README.asciidoc +159/−0
- lhs2TeX-hl.cabal +11/−6
- src/Base/CLI.hs +2/−0
- src/Base/Common.hs +1/−1
- src/Language/LaTeX.hs +9/−3
- src/Literate/Haskell.hs +9/−1
- src/LiterateHighlighter.hs +2/−0
− README
@@ -1,77 +0,0 @@- 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 -o OUTPUTFILE INPUTFILE- - 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:- - * \lhsCHsyntax- * \lhsCHkeyword- * \lhsCHprelude- * \lhsCHtype- * \lhsCHconstructor- * \lhsCHfunction- * \lhsCHinfixoperator- * \lhsCHclass- - This only generates formatting directives for keywords for you. If you want to- change the formatting of characters, strings or literal numbers add the- following directives:- - > %subst char a = "\color{char}\text{\tt ''" a "''}"- > %subst string a = "\color{string}\text{\tt \char34 " a "\char34}"- > %subst numeral a = "\color{numeral}{ " a " }"- - KNOWN ISSUES- ------------- - * Infix operators may not work that great, or normal functions that are used- `infix`. Sometimes you might get an `ambiguous infix operator' error.- * AGDA isn't supported yet unfortunately.- * Errors aren't that informative. :)- - CHANGES- -------- 1.2.2: * And classes are now also written to the output file, somewhere I was- sleeping during all this. :)- 1.2.1: * Fixed a regression, detection of language pragmas was apparently- broken and now they aren't anymore.- 1.2.0: * Hopefully the ``ambiguous infix operator'' error shouldn't occur - that often anymore.- * Removed the AGDA dependency for until it actually works.- * Classes are now detected.- -
+ README.asciidoc view
@@ -0,0 +1,159 @@+Literate HS to TeX Highlighter Helper+=====================================++Hi there,++welcome to the lhs2TeX-hl readme. lhs2TeX-hl is a tool for generating+formatting rules used by lhs2TeX. This tool is to be used in combination with+lhs2TeX. +++It aims to detect the `kind' of an identifier either by it's use or it's+declaration. Trying to detect both local declarations and usages.++Regards,+Alessandro Vermeulen++INSTALLING+----------++* Make sure you have cabal installed and run++ cabal install lhs2TeX-hl+ +* Or download the latest release from:+ http://hackage.haskell.org/package/lhs2TeX-hl+ and install in the standard way.++* Or visit the github page:+ https://github.com/spockz/lhs2texhl++USAGE or HOW-TO+---------------+Using lhs2TeX-hl is very simple. Just pass it your Haskell source file and it+will automatically generating formatting directives for you. Including but not+limited to formatting directives for data constructors and functions. Currently+`functions' that are strictly constants are not highlighted as functions.++----+lhs2TeX-hl -o <filename>.fmt <filename>.lhs+----++For more details see:++----+lhs2TeX-hl --help+----++Currently this is the only way to work with the tool.++In your .lhs file include the generated formatting files, like this:++----+%include polycode.fmt+%include <filename>.fmt+----++After this you'll need to provide the following LaTeX commands yourself:++* \lhsCHsyntax +* \lhsCHkeyword+* \lhsCHprelude+* \lhsCHtype+* \lhsCHconstructor+* \lhsCHfunction+* \lhsCHinfixoperator+* \lhsCHclass++Check out the ./examples directory and the examples section for example themes.++This tool only generates formatting directives for identifiers (including+operators) for you. If you want to change the formatting of characters,+strings or literal numbers add the following directives:++----+%subst char a = "\color{char}\text{\tt ''" a "''}"+%subst string a = "\color{string}\text{\tt \char34 " a "\char34}"+%subst numeral a = "\color{numeral}{ " a " }"+----++For other available substitutions consult the lhs2TeX manual.++Automatic markup+~~~~~~~~~~~~~~~~+For your convenience there are some automatic rewrites being done.++* If a identifier names in a sequence of digits, the digits will be+ typeset in subscript.+* If you have trailing underscores they will be omitted in the typesetting.+ This is so you can do something like:++ -----+ data Foo = Foo_ a;+ -----+ + And have Foo highlighted as a type constructor, and Foo_ highlighted as+ `Foo' in a data constructor colour. + +* If there are underscores in the middle of your identifier, everything+ after the underscores will be typeset in subscript.++THEMES+------++emacs+~~~~~+[source, latex]+--------------------------------------------------------------------------------+% use package color+\definecolor{syntax}{RGB}{0, 0, 0}+\definecolor{datatype}{RGB}{196, 6, 11}+\definecolor{class}{RGB}{168,37,39}+\definecolor{fieldname}{RGB}{0,0,162}+\definecolor{prelude}{RGB}{64,80,117}+\definecolor{numeral}{RGB}{0,0,205}+\definecolor{infixoperator}{RGB}{19, 19, 168}+\definecolor{constructor}{RGB}{196, 6, 11}+\definecolor{keyword}{RGB}{4, 58, 252}+\definecolor{special1}{RGB}{159,138,0}+\definecolor{string}{RGB}{3, 106, 7}+\definecolor{char} {RGB}{3, 106, 7}++\newcommand{\lhsCHsyntax}[1]{\color{syntax}{{#1}}}+\newcommand{\lhsCHfunction}[1]{\color{infixoperator}{{#1}}}+\newcommand{\lhsCHinfixoperator}[1]{\color{infixoperator}{{#1}}}+\newcommand{\lhsCHprelude}[1]{\color{prelude}{\mathbf{#1}}}+\newcommand{\lhsCHkeyword}[1]{\color{keyword}{\textbf{#1}}}+\newcommand{\lhsCHconstructor}[1]{\color{constructor}{\textbf{#1}}}+\newcommand{\lhsCHtype}[1]{\color{datatype}{{#1}}}+\newcommand{\lhsCHclass}[1]{\color{class}{{#1}}}++%subst char a = "\color{char}\text{\tt ''" a "''}"+%subst string a = "\color{string}\text{\tt \char34 " a "\char34}"+%subst numeral a = "\color{numeral}{ " a " }"+--------------------------------------------------------------------------------++KNOWN ISSUES+------------++* Infix operators may not work that great, or normal functions that are used+ `infix`. Sometimes you might get an `ambiguous infix operator' error.+* AGDA isn't supported yet unfortunately.+* Errors aren't that informative. :)++CHANGES+-------+1.3.0::+ * Added automatic rewrite rules, see section `Automatic markup'.+1.2.2::+ * And classes are now also written to the output file, somewhere I was+ sleeping during all this. :)+1.2.1:: + * Fixed a regression, detection of language pragmas was apparently broken and+ now they aren't anymore.+1.2.0::+ * Hopefully the ``ambiguous infix operator'' error shouldn't occur that often+ anymore.+ * Removed the AGDA dependency for until it actually works.+ * Classes are now detected.+
lhs2TeX-hl.cabal view
@@ -1,18 +1,23 @@ Name: lhs2TeX-hl-Version: 0.1.2.2+Version: 0.1.3 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.+Description: A helper executable for highlighting code with lhs2tex. Pass+ an Haskell file to lhs2TeX-hl and it will generate a file+ with formatting directives to be used with lhs2TeX for you.+ + For more information, please visit the repository, or look+ at the release blog post:+ http://alessandrovermeulen.me/projects/lhs2texhl/ Build-Type: Simple Stability: Experimental category: Development, Language-Data-files: README examples/theme1.tex+Data-files: README.asciidoc examples/theme1.tex License-file: LICENSE+Homepage: http://spockz.github.com/lhs2texhl/ bug-reports: http://github.com/spockz/lhs2texhl/issues Executable lhs2TeX-hl@@ -20,9 +25,9 @@ Build-Depends: base >= 4 && <= 5 , haskell98 , haskell-src-exts >= 1.9.3- , MissingH >= 1.1.0.3 , syb >= 0.1.0.1 , cmdargs >= 0.1+ , MissingH hs-source-dirs: src Other-Modules: Language.LaTeX, Literate.Agda, Literate.Haskell, Literate.SimpleInfo, Base.CLI, Base.Common
src/Base/CLI.hs view
@@ -16,6 +16,8 @@ usage :: String usage = unlines [ programName ++" "++ programVersion ++" - A lhs2TeX Syntax Coloring pre-processor"+ , "Consult the README file for extra information or visit:\n"+ , " https://github.com/spockz/lhs2texhl" , "Copyright 2010, Alessandro Vermeulen <me@alessandrovermeulen.me>" ]
src/Base/Common.hs view
@@ -1,4 +1,4 @@ module Base.Common where -programVersion = "0.1.2.2"+programVersion = "0.1.3" programName = "lhs2TeX-hl"
src/Language/LaTeX.hs view
@@ -1,11 +1,17 @@ module Language.LaTeX where ++--------- import Data.String.Utils +import Language.Markup+---------++ makeLatexSafe :: String -> String makeLatexSafe = replace ">" "\\textgreater" . replace "<" "\\textless"- . replace "_" "\\_"+ -- . replace "_" "\\_" . replace "\"" "\\\"" . replace "&" "\\&"@@ -13,7 +19,7 @@ {- This part is to conserve some lhs2TeX behaviour. Really shouldn't be here... -} . replace "=" "\\ = \\ "- . replace "_" "\\ \\anonymous\\ "+ -- . replace "_" "\\ \\anonymous\\ " . replace "$" "\\ \\mathbin{\\$}\\ " . replace "&&" "\\ \\mathrel{\\wedge}\\ " . replace "||" "\\ \\mathrel{\\vee}\\ "@@ -48,4 +54,4 @@ char n = "\\ \\char''" ++ show n ++"\\ " dp :: String -> (String, String)-dp a = (a, makeLatexSafe a)+dp a = (a, (markup . makeLatexSafe) a)
src/Literate/Haskell.hs view
@@ -41,11 +41,19 @@ getData _ = [] listConstructors :: Module -> [String]-listConstructors = nub . everything (++) ([] `mkQ` listConstructor)+listConstructors = nub . everything (++) ([] `mkQ` listConstructor + `extQ` listConstructorPat + `extQ` listConstructorUse) where listConstructor :: ConDecl -> [String] listConstructor (ConDecl (i) _) = [prettyPrint i] listConstructor (InfixConDecl _ i _) = [prettyPrint i] listConstructor (RecDecl i _) = [prettyPrint i]+ listConstructorPat :: Pat -> [String]+ listConstructorPat (PApp i _) = [prettyPrint i]+ listConstructorPat _ = []+ listConstructorUse :: Exp -> [String]+ listConstructorUse (Con i) = [prettyPrint i]+ listConstructorUse _ = [] listFunctions :: Module -> [String] listFunctions = nub . everything (++) ([] `mkQ` functionBinding `extQ` functionUse)
src/LiterateHighlighter.hs view
@@ -17,6 +17,8 @@ import Literate.Haskell import Literate.SimpleInfo ++import Language.Markup -----------------------------