Portability | portable |
---|---|
Stability | alpha |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Safe Haskell | Safe-Infered |
Exports functions for syntax highlighting.
- languages :: [String]
- languagesByExtension :: String -> [String]
- highlight :: (FormatOptions -> [SourceLine] -> a) -> Attr -> String -> Maybe a
- formatLaTeXInline :: FormatOptions -> [SourceLine] -> String
- formatLaTeXBlock :: FormatOptions -> [SourceLine] -> String
- styleToLaTeX :: Style -> String
- formatHtmlInline :: FormatOptions -> [SourceLine] -> Html
- formatHtmlBlock :: FormatOptions -> [SourceLine] -> Html
- styleToCss :: Style -> String
- pygments :: Style
- espresso :: Style
- zenburn :: Style
- tango :: Style
- kate :: Style
- monochrome :: Style
- haddock :: Style
- data Style
Documentation
languagesByExtension :: String -> [String]
Returns a list of languages appropriate for the given file extension.
:: (FormatOptions -> [SourceLine] -> a) | Formatter |
-> Attr | Attributes of the CodeBlock |
-> String | Raw contents of the CodeBlock |
-> Maybe a | Maybe the formatted result |
formatLaTeXInline :: FormatOptions -> [SourceLine] -> String
Formats tokens as LaTeX using custom commands inside
|
characters. Assumes that |
is defined as a short verbatim
command by the macros produced by styleToLaTeX
.
A KeywordTok
is rendered using \KeywordTok{..}
, and so on.
formatLaTeXBlock :: FormatOptions -> [SourceLine] -> String
Format tokens as a LaTeX Highlighting
environment inside a
Shaded
environment. Highlighting
and Shaded
are
defined by the macros produced by styleToLaTeX
. Highlighting
is a verbatim environment using fancyvrb
; \
, {
, and }
have their normal meanings inside this environment, so that
formatting commands work. Shaded
is either nothing
(if the style's background color is default) or a snugshade
environment from framed
, providing a background color
for the whole code block, even if it spans multiple pages.
styleToLaTeX :: Style -> String
Converts a Style
to a set of LaTeX macro definitions,
which should be placed in the document's preamble.
Note: default LaTeX setup doesn't allow boldface typewriter font.
To make boldface work in styles, you need to use a different typewriter
font. This will work for computer modern:
\DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
Or, with xelatex:
\usepackage{fontspec} \setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman} \setsansfont{Latin Modern Sans} \setmonofont[SmallCapsFont={Latin Modern Mono Caps}]{Latin Modern Mono Light}
formatHtmlInline :: FormatOptions -> [SourceLine] -> Html
Format tokens using HTML spans inside code
tags. For example,
A KeywordTok
is rendered as a span with class kw
.
Short class names correspond to TokenType
s as follows:
KeywordTok
= kw
, DataTypeTok
= dt
,
DecValTok
= dv
, BaseNTok
= bn
, FloatTok
= fl
,
CharTok
= ch
, StringTok
= st
, CommontTok
= co
,
OtherTok
= ot
, AlertTok
= al
, FunctionTok
= fu
,
RegionMarkerTok
= re
, ErrorTok
= er
. A NormalTok
is not marked up at all.
formatHtmlBlock :: FormatOptions -> [SourceLine] -> Html
Format tokens as an HTML pre
block. If line numbering is
selected, this is put into a table row with line numbers in the
left cell.
styleToCss :: Style -> String
Returns CSS for styling highlighted code according to the given style.
monochrome :: Style
Style with no colors.