highlighting-kate-0.5.1: Syntax highlighting

Portability | portable
Stability | alpha
Maintainer | John MacFarlane <jgm@berkeley.edu>
Safe Haskell | Safe-Infered

Text.Highlighting.Kate

Description

This helper module exports the main highlighting and formatting functions.

A typical application will combine a highlighter and a formatter. This one reads ruby code from stdin and writes HTML:

     import Text.Highlighting.Kate
     import Text.Blaze.Html.Renderer.String (renderHtml)
     import Text.Blaze.Html (toHtml)
     import Text.Blaze.Html5 as H
     import Text.Blaze.Html5.Attributes as A

     main = do
       code <- getContents
       putStrLn $ renderHtml
                $ do H.head $ H.style ! A.type_ (toValue "text/css")
                            $ toHtml $ styleToCss tango
                     H.body $ toHtml
                            $ formatHtmlBlock defaultFormatOpts
                            $ highlightAs "ruby" code

Synopsis

- highlightAs :: String -> String -> [SourceLine]
- languages :: [String]
- languagesByExtension :: String -> [String]
- languagesByFilename :: FilePath -> [String]
- highlightingKateVersion :: String
- module Text.Highlighting.Kate.Types
- module Text.Highlighting.Kate.Styles
- module Text.Highlighting.Kate.Format.HTML
- module Text.Highlighting.Kate.Format.LaTeX

# Documentation

highlightAs

Arguments

:: String | Language syntax (e.g. haskell) or extension (e.g. hs).
-> String | Source code to highlight
-> [SourceLine] | List of highlighted source lines

Highlight source code. The source language may be specified by its canonical name (case-insensitive) or by a canonical extension (if unique). The parsers read the input lazily and parse line by line; results are returned immediately. Supported languages: `actionscript`, `ada`, `alert`, `alert_indent`, `apache`, `asn1`, `asp`, `awk`, `bash`, `bibtex`, `boo`, `c`, `changelog`, `clojure`, `cmake`, `coffeescript`, `coldfusion`, `commonlisp`, `cpp`, `cs`, `css`, `d`, `diff`, `djangotemplate`, `doxygen`, `dtd`, `eiffel`, `email`, `erlang`, `fortran`, `fsharp`, `gnuassembler`, `go`, `haskell`, `haxe`, `html`, `ini`, `java`, `javadoc`, `javascript`, `json`, `jsp`, `latex`, `lex`, `literatehaskell`, `lua`, `makefile`, `mandoc`, `matlab`, `maxima`, `metafont`, `mips`, `modula2`, `modula3`, `monobasic`, `nasm`, `noweb`, `objectivec`, `objectivecpp`, `ocaml`, `octave`, `pascal`, `perl`, `php`, `pike`, `postscript`, `prolog`, `python`, `r`, `relaxngcompact`, `rhtml`, `ruby`, `scala`, `scheme`, `sci`, `sed`, `sgml`, `sql`, `sqlmysql`, `sqlpostgresql`, `tcl`, `texinfo`, `verilog`, `vhdl`, `xml`, `xorg`, `xslt`, `xul`, `yacc`, `yaml`.

languages :: [String]

List of supported languages.

languagesByExtension :: String -> [String]

Returns a list of languages appropriate for the given file extension.

languagesByFilename :: FilePath -> [String]

Returns a list of languages appropriate for the given filename.

highlightingKateVersion :: String

module Text.Highlighting.Kate.Types

module Text.Highlighting.Kate.Styles

module Text.Highlighting.Kate.Format.HTML

module Text.Highlighting.Kate.Format.LaTeX