highlighting-kate-0.5.11: Syntax highlighting

CopyrightCopyright (C) 2008-2011 John MacFarlane
LicenseGNU GPL, version 2 or above
MaintainerJohn MacFarlane <jgm@berkeley.edu>
Stabilityalpha
Portabilityportable
Safe HaskellNone
LanguageHaskell98

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

Documentation

highlightAs Source

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: abc, actionscript, ada, agda, alert, alert_indent, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd, eiffel, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go, haskell, haxe, html, ini, isocpp, java, javadoc, javascript, json, jsp, julia, latex, lex, lilypond, literatecurry, literatehaskell, lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima, mediawiki, metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php, pike, postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest, rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml, zsh.

languages :: [String] Source

List of supported languages.

languagesByExtension :: String -> [String] Source

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

languagesByFilename :: FilePath -> [String] Source

Returns a list of languages appropriate for the given filename.