-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | syntax highlighting library -- -- Skylighting is a syntax highlighting library with support for over one -- hundred languages. It derives its tokenizers from XML syntax -- definitions used by KDE's KSyntaxHighlighting framework, so any syntax -- supported by that framework can be added. An optional command-line -- program is provided. Skylighting is intended to be the successor to -- highlighting-kate. @package skylighting @version 0.4.2 module Skylighting.Regex -- | A compiled regular expression data Regex :: * -- | An exception in compiling or executing a regex. data RegexException -- | A representation of a regular expression. data RE RE :: ByteString -> Bool -> RE [reString] :: RE -> ByteString [reCaseSensitive] :: RE -> Bool -- | Compile a PCRE regex. If the first parameter is True, the regex is -- case-sensitive, otherwise caseless. The regex is compiled from a -- bytestring interpreted as UTF-8. If the regex cannot be compiled, a -- RegexException is thrown. compileRegex :: Bool -> ByteString -> Regex -- | Match a Regex against a bytestring. Returns Nothing if -- no match, otherwise Just a nonempty list of bytestrings. The -- first bytestring in the list is the match, the others the captures, if -- any. If there are errors in executing the regex, a -- RegexException is thrown. matchRegex :: Regex -> ByteString -> Maybe [ByteString] -- | Convert octal escapes to the form pcre wants. Note: need at least pcre -- 8.34 for the form o{dddd}. So we prefer ddd or x{...}. convertOctalEscapes :: String -> String instance GHC.Generics.Generic Skylighting.Regex.RE instance Data.Data.Data Skylighting.Regex.RE instance GHC.Classes.Eq Skylighting.Regex.RE instance GHC.Classes.Ord Skylighting.Regex.RE instance GHC.Read.Read Skylighting.Regex.RE instance GHC.Show.Show Skylighting.Regex.RE instance GHC.Generics.Generic Skylighting.Regex.RegexException instance GHC.Show.Show Skylighting.Regex.RegexException instance GHC.Exception.Exception Skylighting.Regex.RegexException instance Data.Binary.Class.Binary Skylighting.Regex.RE instance Data.Aeson.Types.ToJSON.ToJSON Skylighting.Regex.RE instance Data.Aeson.Types.FromJSON.FromJSON Skylighting.Regex.RE -- | Basic types for Skylighting. module Skylighting.Types -- | Full name of a context: the first member of the pair is the full -- syntax name, the second the context name within that syntax. type ContextName = (Text, Text) -- | Attributes controlling how keywords are interpreted. data KeywordAttr KeywordAttr :: Bool -> Set Char -> KeywordAttr [keywordCaseSensitive] :: KeywordAttr -> Bool [keywordDelims] :: KeywordAttr -> Set Char -- | A set of "words," possibly case insensitive. data WordSet a -- | A set of words to match (either case-sensitive or case-insensitive). makeWordSet :: (FoldCase a, Ord a) => Bool -> [a] -> WordSet a -- | Test for membership in a WordSet. inWordSet :: (FoldCase a, Ord a) => a -> WordSet a -> Bool -- | Matchers correspond to the element types in a context. data Matcher DetectChar :: Char -> Matcher Detect2Chars :: Char -> Char -> Matcher AnyChar :: [Char] -> Matcher RangeDetect :: Char -> Char -> Matcher StringDetect :: Text -> Matcher WordDetect :: Text -> Matcher RegExpr :: RE -> Matcher Keyword :: KeywordAttr -> (WordSet Text) -> Matcher Int :: Matcher Float :: Matcher HlCOct :: Matcher HlCHex :: Matcher HlCStringChar :: Matcher HlCChar :: Matcher LineContinue :: Matcher IncludeRules :: ContextName -> Matcher DetectSpaces :: Matcher DetectIdentifier :: Matcher -- | A rule corresponds to one of the elements of a Kate syntax -- highlighting "context." data Rule Rule :: Matcher -> TokenType -> Bool -> Bool -> Bool -> [Rule] -> Bool -> Bool -> Maybe Int -> [ContextSwitch] -> Rule [rMatcher] :: Rule -> Matcher [rAttribute] :: Rule -> TokenType [rIncludeAttribute] :: Rule -> Bool [rDynamic] :: Rule -> Bool [rCaseSensitive] :: Rule -> Bool [rChildren] :: Rule -> [Rule] [rLookahead] :: Rule -> Bool [rFirstNonspace] :: Rule -> Bool [rColumn] :: Rule -> Maybe Int [rContextSwitch] :: Rule -> [ContextSwitch] -- | A Context corresponds to a context element in a Kate syntax -- description. data Context Context :: Text -> Text -> [Rule] -> TokenType -> [ContextSwitch] -> [ContextSwitch] -> [ContextSwitch] -> Bool -> [ContextSwitch] -> Bool -> Context [cName] :: Context -> Text [cSyntax] :: Context -> Text [cRules] :: Context -> [Rule] [cAttribute] :: Context -> TokenType [cLineEmptyContext] :: Context -> [ContextSwitch] [cLineEndContext] :: Context -> [ContextSwitch] [cLineBeginContext] :: Context -> [ContextSwitch] [cFallthrough] :: Context -> Bool [cFallthroughContext] :: Context -> [ContextSwitch] [cDynamic] :: Context -> Bool -- | A context switch, either pops or pushes a context. data ContextSwitch Pop :: ContextSwitch Push :: ContextName -> ContextSwitch -- | A syntax corresponds to a complete Kate syntax description. The -- sShortname field is derived from the filename. data Syntax Syntax :: Text -> String -> Text -> Map Text Context -> Text -> Text -> Text -> [String] -> Text -> Syntax [sName] :: Syntax -> Text [sFilename] :: Syntax -> String [sShortname] :: Syntax -> Text [sContexts] :: Syntax -> Map Text Context [sAuthor] :: Syntax -> Text [sVersion] :: Syntax -> Text [sLicense] :: Syntax -> Text [sExtensions] :: Syntax -> [String] [sStartingContext] :: Syntax -> Text -- | A map of syntaxes, keyed by full name. type SyntaxMap = Map Text Syntax -- | A pair consisting of a list of attributes and some text. type Token = (TokenType, Text) -- | KeywordTok corresponds to dsKeyword in Kate syntax -- descriptions, and so on. data TokenType KeywordTok :: TokenType DataTypeTok :: TokenType DecValTok :: TokenType BaseNTok :: TokenType FloatTok :: TokenType ConstantTok :: TokenType CharTok :: TokenType SpecialCharTok :: TokenType StringTok :: TokenType VerbatimStringTok :: TokenType SpecialStringTok :: TokenType ImportTok :: TokenType CommentTok :: TokenType DocumentationTok :: TokenType AnnotationTok :: TokenType CommentVarTok :: TokenType OtherTok :: TokenType FunctionTok :: TokenType VariableTok :: TokenType ControlFlowTok :: TokenType OperatorTok :: TokenType BuiltInTok :: TokenType ExtensionTok :: TokenType PreprocessorTok :: TokenType AttributeTok :: TokenType RegionMarkerTok :: TokenType InformationTok :: TokenType WarningTok :: TokenType AlertTok :: TokenType ErrorTok :: TokenType NormalTok :: TokenType -- | A line of source: a list of labeled tokens. type SourceLine = [Token] -- | Line numbers newtype LineNo LineNo :: Int -> LineNo [lineNo] :: LineNo -> Int -- | A TokenStyle determines how a token is to be rendered. data TokenStyle TokenStyle :: Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> TokenStyle [tokenColor] :: TokenStyle -> Maybe Color [tokenBackground] :: TokenStyle -> Maybe Color [tokenBold] :: TokenStyle -> Bool [tokenItalic] :: TokenStyle -> Bool [tokenUnderline] :: TokenStyle -> Bool -- | Default style. defStyle :: TokenStyle -- | A color (redgreenblue). data Color RGB :: Word8 -> Word8 -> Word8 -> Color -- | Things that can be converted to a color. class ToColor a toColor :: ToColor a => a -> Maybe Color -- | Different representations of a Color. class FromColor a fromColor :: FromColor a => Color -> a -- | A rendering style. This determines how each kind of token is to be -- rendered, and sets a default color and background color for normal -- tokens. Line numbers can have a different color and background color. data Style Style :: [(TokenType, TokenStyle)] -> Maybe Color -> Maybe Color -> Maybe Color -> Maybe Color -> Style [tokenStyles] :: Style -> [(TokenType, TokenStyle)] [defaultColor] :: Style -> Maybe Color [backgroundColor] :: Style -> Maybe Color [lineNumberColor] :: Style -> Maybe Color [lineNumberBackgroundColor] :: Style -> Maybe Color -- | Options for formatting source code. data FormatOptions FormatOptions :: Bool -> Int -> Bool -> Bool -> [Text] -> [Text] -> FormatOptions -- | Number lines [numberLines] :: FormatOptions -> Bool -- | Number of first line [startNumber] :: FormatOptions -> Int -- | Anchors on each line number [lineAnchors] :: FormatOptions -> Bool -- | Html titles with token types [titleAttributes] :: FormatOptions -> Bool -- | Additional classes for Html code tag [codeClasses] :: FormatOptions -> [Text] -- | Additional classes for Html container tag [containerClasses] :: FormatOptions -> [Text] -- | Default formatting options. defaultFormatOpts :: FormatOptions instance GHC.Generics.Generic Skylighting.Types.FormatOptions instance Data.Data.Data Skylighting.Types.FormatOptions instance GHC.Classes.Ord Skylighting.Types.FormatOptions instance GHC.Classes.Eq Skylighting.Types.FormatOptions instance GHC.Read.Read Skylighting.Types.FormatOptions instance GHC.Show.Show Skylighting.Types.FormatOptions instance GHC.Generics.Generic Skylighting.Types.Style instance Data.Data.Data Skylighting.Types.Style instance GHC.Classes.Ord Skylighting.Types.Style instance GHC.Classes.Eq Skylighting.Types.Style instance GHC.Show.Show Skylighting.Types.Style instance GHC.Read.Read Skylighting.Types.Style instance GHC.Generics.Generic Skylighting.Types.TokenStyle instance Data.Data.Data Skylighting.Types.TokenStyle instance GHC.Classes.Eq Skylighting.Types.TokenStyle instance GHC.Classes.Ord Skylighting.Types.TokenStyle instance GHC.Read.Read Skylighting.Types.TokenStyle instance GHC.Show.Show Skylighting.Types.TokenStyle instance GHC.Generics.Generic Skylighting.Types.Color instance Data.Data.Data Skylighting.Types.Color instance GHC.Classes.Eq Skylighting.Types.Color instance GHC.Classes.Ord Skylighting.Types.Color instance GHC.Read.Read Skylighting.Types.Color instance GHC.Show.Show Skylighting.Types.Color instance GHC.Enum.Enum Skylighting.Types.LineNo instance GHC.Show.Show Skylighting.Types.LineNo instance GHC.Generics.Generic Skylighting.Types.Syntax instance Data.Data.Data Skylighting.Types.Syntax instance GHC.Classes.Ord Skylighting.Types.Syntax instance GHC.Classes.Eq Skylighting.Types.Syntax instance GHC.Read.Read Skylighting.Types.Syntax instance GHC.Show.Show Skylighting.Types.Syntax instance GHC.Generics.Generic Skylighting.Types.Context instance Data.Data.Data Skylighting.Types.Context instance GHC.Classes.Ord Skylighting.Types.Context instance GHC.Classes.Eq Skylighting.Types.Context instance GHC.Read.Read Skylighting.Types.Context instance GHC.Show.Show Skylighting.Types.Context instance GHC.Generics.Generic Skylighting.Types.Rule instance Data.Data.Data Skylighting.Types.Rule instance GHC.Classes.Ord Skylighting.Types.Rule instance GHC.Classes.Eq Skylighting.Types.Rule instance GHC.Read.Read Skylighting.Types.Rule instance GHC.Show.Show Skylighting.Types.Rule instance GHC.Generics.Generic Skylighting.Types.TokenType instance Data.Data.Data Skylighting.Types.TokenType instance GHC.Enum.Enum Skylighting.Types.TokenType instance GHC.Classes.Ord Skylighting.Types.TokenType instance GHC.Classes.Eq Skylighting.Types.TokenType instance GHC.Show.Show Skylighting.Types.TokenType instance GHC.Read.Read Skylighting.Types.TokenType instance GHC.Generics.Generic Skylighting.Types.ContextSwitch instance Data.Data.Data Skylighting.Types.ContextSwitch instance GHC.Classes.Ord Skylighting.Types.ContextSwitch instance GHC.Classes.Eq Skylighting.Types.ContextSwitch instance GHC.Read.Read Skylighting.Types.ContextSwitch instance GHC.Show.Show Skylighting.Types.ContextSwitch instance GHC.Generics.Generic Skylighting.Types.Matcher instance Data.Data.Data Skylighting.Types.Matcher instance GHC.Classes.Ord Skylighting.Types.Matcher instance GHC.Classes.Eq Skylighting.Types.Matcher instance GHC.Read.Read Skylighting.Types.Matcher instance GHC.Show.Show Skylighting.Types.Matcher instance GHC.Generics.Generic (Skylighting.Types.WordSet a) instance (GHC.Classes.Ord a, Data.Data.Data a) => Data.Data.Data (Skylighting.Types.WordSet a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Skylighting.Types.WordSet a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Skylighting.Types.WordSet a) instance (GHC.Classes.Ord a, GHC.Read.Read a) => GHC.Read.Read (Skylighting.Types.WordSet a) instance GHC.Show.Show a => GHC.Show.Show (Skylighting.Types.WordSet a) instance GHC.Generics.Generic Skylighting.Types.KeywordAttr instance Data.Data.Data Skylighting.Types.KeywordAttr instance GHC.Classes.Ord Skylighting.Types.KeywordAttr instance GHC.Classes.Eq Skylighting.Types.KeywordAttr instance GHC.Read.Read Skylighting.Types.KeywordAttr instance GHC.Show.Show Skylighting.Types.KeywordAttr instance Data.Binary.Class.Binary Skylighting.Types.KeywordAttr instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Skylighting.Types.WordSet a) instance Data.Binary.Class.Binary Skylighting.Types.Matcher instance Data.Binary.Class.Binary Skylighting.Types.ContextSwitch instance Data.Binary.Class.Binary Skylighting.Types.Rule instance Data.Binary.Class.Binary Skylighting.Types.Syntax instance Data.Binary.Class.Binary Skylighting.Types.Context instance Data.Binary.Class.Binary Skylighting.Types.TokenType instance Data.Aeson.Types.ToJSON.ToJSON Skylighting.Types.TokenType instance Data.Aeson.Types.FromJSON.FromJSON Skylighting.Types.TokenType instance Data.Binary.Class.Binary Skylighting.Types.TokenStyle instance Data.Aeson.Types.FromJSON.FromJSON Skylighting.Types.TokenStyle instance Data.Aeson.Types.ToJSON.ToJSON Skylighting.Types.TokenStyle instance Data.Binary.Class.Binary Skylighting.Types.Color instance Skylighting.Types.ToColor GHC.Base.String instance Skylighting.Types.ToColor GHC.Types.Int instance Skylighting.Types.ToColor (GHC.Word.Word8, GHC.Word.Word8, GHC.Word.Word8) instance Skylighting.Types.ToColor (GHC.Types.Double, GHC.Types.Double, GHC.Types.Double) instance Data.Aeson.Types.FromJSON.FromJSON Skylighting.Types.Color instance Data.Aeson.Types.ToJSON.ToJSON Skylighting.Types.Color instance Skylighting.Types.FromColor GHC.Base.String instance Skylighting.Types.FromColor (GHC.Types.Double, GHC.Types.Double, GHC.Types.Double) instance Skylighting.Types.FromColor (GHC.Word.Word8, GHC.Word.Word8, GHC.Word.Word8) instance Data.Binary.Class.Binary Skylighting.Types.Style instance Data.Aeson.Types.FromJSON.FromJSON Skylighting.Types.Style instance Data.Aeson.Types.ToJSON.ToJSON Skylighting.Types.Style instance Data.Binary.Class.Binary Skylighting.Types.FormatOptions module Skylighting.Styles -- | Parse a KDE theme JSON document into a skylighting Style. parseTheme :: ByteString -> Either String Style -- | Style based on kate's default colors. kate :: Style -- | Style from the breeze-dark KDE syntax highlighting theme. breezeDark :: Style -- | Style based on pygments's default colors. pygments :: Style -- | Style based on ultraviolet's espresso_libre.css (dark background). espresso :: Style -- | Style based on pygments's tango colors. tango :: Style -- | Style based on haddock's source highlighting. haddock :: Style -- | Style with no colors. monochrome :: Style -- | Style based on the popular zenburn vim color scheme zenburn :: Style -- | Provides syntax highlighting definitions. THIS FILE IS AUTOMATICALLY -- GENERATED. DO NOT EDIT IT MANUALLY. module Skylighting.Syntax -- | Default mapping from short names to syntax definitions. defaultSyntaxMap :: SyntaxMap module Skylighting.Tokenizer -- | Tokenize some text using Syntax. tokenize :: TokenizerConfig -> Syntax -> Text -> Either String [SourceLine] -- | Configuration options for tokenize. data TokenizerConfig TokenizerConfig :: SyntaxMap -> Bool -> TokenizerConfig -- | Syntax map to use [syntaxMap] :: TokenizerConfig -> SyntaxMap -- | Generate trace output for debugging [traceOutput] :: TokenizerConfig -> Bool instance GHC.Show.Show Skylighting.Tokenizer.TokenizerConfig instance GHC.Show.Show Skylighting.Tokenizer.ContextStack module Skylighting.Parser -- | Parses a file containing a Kate XML syntax definition into a -- Syntax description. parseSyntaxDefinition :: String -> IO (Either String Syntax) -- | Adds a syntax definition to a syntax map, replacing any existing -- definition with the same name. addSyntaxDefinition :: Syntax -> SyntaxMap -> SyntaxMap -- | Scan a list of Syntaxs and make sure that IncludeRules -- never asks for a syntax not in this list. Produces a list of pairs -- where the first element is the including syntax name and the second -- element is the (missing) included syntax name. This is intended for -- sanity checks to avoid run-time errors. missingIncludes :: [Syntax] -> [(Text, Text)] module Skylighting.Format.LaTeX -- | 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. formatLaTeXInline :: FormatOptions -> [SourceLine] -> Text -- | 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. formatLaTeXBlock :: FormatOptions -> [SourceLine] -> Text -- | 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}
--
styleToLaTeX :: Style -> Text
module Skylighting.Format.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 TokenTypes as follows:
-- KeywordTok = kw, DataTypeTok = dt,
-- DecValTok = dv, BaseNTok = bn,
-- FloatTok = fl, CharTok = ch,
-- StringTok = st, CommentTok = co,
-- OtherTok = ot, AlertTok = al,
-- FunctionTok = fu, RegionMarkerTok =
-- re, ErrorTok = er, ConstantTok =
-- cn, SpecialCharTok = sc,
-- VerbatimStringTok = vs, SpecialStringTok =
-- ss, ImportTok = im, DocumentationTok =
-- do, AnnotationTok = an, CommentVarTok
-- = cv, VariableTok = va, ControlFlowTok
-- = cf, OperatorTok = op, BuiltInTok =
-- bu, ExtensionTok = ex, PreprocessorTok
-- = pp, AttributeTok = at,
-- InformationTok = in, WarningTok = wa.
-- A NormalTok is not marked up at all.
formatHtmlInline :: FormatOptions -> [SourceLine] -> Html
-- | Format tokens as an HTML pre block. Each line is wrapped in a
-- div with the class ‘source-line’. If line numbering is selected, this
-- surrounding div is given the class ‘number-source’, and the resulting
-- html will display line numbers thanks to the included css. Note that
-- the html produced will always include the line numbers as the
-- 'data-line-number' attribute. See the documentation for
-- formatHtmlInline for information about how tokens are encoded.
formatHtmlBlock :: FormatOptions -> [SourceLine] -> Html
-- | Returns CSS for styling highlighted code according to the given style.
styleToCss :: Style -> String
module Skylighting
-- | Lookup syntax by (in order) full name (case insensitive), short name
-- (case insensitive), extension.
lookupSyntax :: Text -> SyntaxMap -> Maybe Syntax
-- | Lookup a syntax by full name (case insensitive).
syntaxByName :: SyntaxMap -> Text -> Maybe Syntax
-- | Lookup a syntax by short name (case insensitive).
syntaxByShortName :: SyntaxMap -> Text -> Maybe Syntax
-- | Returns a list of syntaxes appropriate for the given file extension.
syntaxesByExtension :: SyntaxMap -> String -> [Syntax]
-- | Returns a list of syntaxes appropriate for the given filename.
syntaxesByFilename :: SyntaxMap -> String -> [Syntax]