highlighting-kate-0.2.10: Syntax highlighting

Portability | portable
Stability | alpha
Maintainer | John MacFarlane <jgm@berkeley.edu>

Text.Highlighting.Kate

Description

This helper module exports the main highlighting and formatting functions.

A typical application will combine a highlighter and a formatter:

     main = do
       code <- getContents
       case highlightAs "ruby" code of
             Right result -> putStrLn $ renderHtmlFragment $
                             formatAsXHtml [OptNumberLines] "ruby" result
             Left  err    -> error $ "Could not parse input: " ++ err

Synopsis

- highlightAs :: String -> String -> Either String [SourceLine]
- languages :: [String]
- languagesByExtension :: String -> [String]
- languagesByFilename :: FilePath -> [String]
- formatAsXHtml :: [FormatOption] -> String -> [SourceLine] -> Html
- data FormatOption
  - = OptNumberLines
  - | OptNumberFrom Int
  - | OptLineAnchors
  - | OptTitleAttributes
  - | OptDetailed
  - | OptInline
- defaultHighlightingCss :: String
- type SourceLine = [LabeledSource]
- type LabeledSource = ([String], String)
- highlightingKateVersion :: String

# Documentation

highlightAs

Arguments

:: String | Language syntax
-> String | Source code to highlight
-> Either String [SourceLine] | Either error message or result

Highlight source code using a specified syntax definition.

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.

formatAsXHtml

Arguments

:: [FormatOption] | Options
-> String | Language
-> [SourceLine] | Source lines to format
-> Html |

Format a list of highlighted `SourceLine`s as XHtml.

data FormatOption

Options for formatters.

Constructors

OptNumberLines | Number lines
OptNumberFrom Int | Number of first line
OptLineAnchors | Anchors on each line number
OptTitleAttributes | Include title attributes
OptDetailed | Include detailed lexical information in classes. (By default, only the default style is included. This option causes output to be more verbose.)
OptInline | Format as span-level, not block-level element

Instances

Eq FormatOption |
Read FormatOption |
Show FormatOption |

defaultHighlightingCss :: String

type SourceLine = [LabeledSource]

A line of source, list of labeled source items.

type LabeledSource = ([String], String)

A pair consisting of a list of attributes and some text.

highlightingKateVersion :: String