-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | syntax highlighting library -- -- Skylighting is a syntax highlighting library. 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. This -- package provides the core highlighting functionality under a -- permissive license. It also bundles XML parser definitions licensed -- under the GPL. @package skylighting-core @version 0.13 module Skylighting.Regex data Regex MatchAnyChar :: Regex MatchDynamic :: !Int -> Regex MatchChar :: (Char -> Bool) -> Regex MatchSome :: !Regex -> Regex MatchAlt :: !Regex -> !Regex -> Regex MatchConcat :: !Regex -> !Regex -> Regex MatchCapture :: !Int -> !Regex -> Regex MatchCaptured :: !Int -> Regex AssertWordBoundary :: Regex AssertBeginning :: Regex AssertEnd :: Regex AssertPositive :: !Direction -> !Regex -> Regex AssertNegative :: !Direction -> !Regex -> Regex Possessive :: !Regex -> Regex Lazy :: !Regex -> Regex Subroutine :: !Int -> Regex MatchNull :: Regex -- | A representation of a regular expression. data RE RE :: ByteString -> Bool -> RE [reString] :: RE -> ByteString [reCaseSensitive] :: RE -> Bool -- | Compile a UTF-8 encoded ByteString as a Regex. If the first parameter -- is True, then the Regex will be case sensitive. compileRegex :: Bool -> ByteString -> Either String Regex -- | Match a Regex against a (presumed UTF-8 encoded) ByteString, returning -- the matched text and a map of (offset, size) pairs for captures. Note -- that all matches are from the beginning of the string (a ^ -- anchor is implicit). Note also that to avoid pathological performance -- in certain cases, the matcher is limited to considering 2000 possible -- matches at a time; when that threshold is reached, it discards smaller -- matches. Hence certain regexes may incorrectly fail to match: e.g. -- a*a{3000}$ on a string of 3000 as. matchRegex :: Regex -> ByteString -> Maybe (ByteString, IntMap (Int, Int)) testRegex :: Bool -> String -> String -> Maybe (String, [(Int, String)]) isWordChar :: Char -> Bool 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 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 CaseSensitiveWords :: !Set a -> WordSet a CaseInsensitiveWords :: !Set a -> 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 -- | A list item is either just a textual value or an included list. -- IncludeList (x,y) includes list y from syntax with full name x. data ListItem Item :: !Text -> ListItem IncludeList :: !(Text, Text) -> ListItem -- | Matchers correspond to the element types in a context. data Matcher DetectChar :: !Char -> Matcher Detect2Chars :: !Char -> !Char -> Matcher AnyChar :: !Set Char -> Matcher RangeDetect :: !Char -> !Char -> Matcher StringDetect :: !Text -> Matcher WordDetect :: !Text -> Matcher RegExpr :: !RE -> Matcher Keyword :: !KeywordAttr -> Either Text (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 [ListItem] -> !Map Text Context -> !Text -> !Text -> !Text -> ![String] -> !Text -> Syntax [sName] :: Syntax -> !Text [sFilename] :: Syntax -> !String [sShortname] :: Syntax -> !Text [sLists] :: Syntax -> !Map Text [ListItem] [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 (red, green, blue). 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 :: !Map TokenType TokenStyle -> !Maybe Color -> !Maybe Color -> !Maybe Color -> !Maybe Color -> Style [tokenStyles] :: Style -> !Map TokenType TokenStyle [defaultColor] :: Style -> !Maybe Color [backgroundColor] :: Style -> !Maybe Color [lineNumberColor] :: Style -> !Maybe Color [lineNumberBackgroundColor] :: Style -> !Maybe Color -- | The available levels of color complexity in ANSI terminal output. data ANSIColorLevel -- | 16-color mode ANSI16Color :: ANSIColorLevel -- | 256-color mode ANSI256Color :: ANSIColorLevel -- | True-color mode ANSITrueColor :: ANSIColorLevel -- | Options for formatting source code. data FormatOptions FormatOptions :: !Bool -> !Int -> !Bool -> !Bool -> ![Text] -> ![Text] -> !Text -> !ANSIColorLevel -> 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] -- | Prefix for id attributes on lines [lineIdPrefix] :: FormatOptions -> !Text -- | Level of ANSI color support to use [ansiColorLevel] :: FormatOptions -> !ANSIColorLevel -- | Default formatting options. defaultFormatOpts :: FormatOptions 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 GHC.Generics.Generic (Skylighting.Types.WordSet a) instance (Data.Data.Data a, GHC.Classes.Ord 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.Read.Read a, GHC.Classes.Ord 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.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.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.ListItem instance Data.Data.Data Skylighting.Types.ListItem instance GHC.Read.Read Skylighting.Types.ListItem instance GHC.Classes.Ord Skylighting.Types.ListItem instance GHC.Classes.Eq Skylighting.Types.ListItem instance GHC.Show.Show Skylighting.Types.ListItem 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.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.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.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.Enum.Enum Skylighting.Types.LineNo instance GHC.Show.Show Skylighting.Types.LineNo 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.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.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.ANSIColorLevel instance Data.Data.Data Skylighting.Types.ANSIColorLevel instance GHC.Enum.Bounded Skylighting.Types.ANSIColorLevel instance GHC.Enum.Enum Skylighting.Types.ANSIColorLevel instance GHC.Classes.Ord Skylighting.Types.ANSIColorLevel instance GHC.Classes.Eq Skylighting.Types.ANSIColorLevel instance GHC.Read.Read Skylighting.Types.ANSIColorLevel instance GHC.Show.Show Skylighting.Types.ANSIColorLevel 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 Data.Binary.Class.Binary Skylighting.Types.FormatOptions instance Data.Binary.Class.Binary Skylighting.Types.ANSIColorLevel 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.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 (GHC.Classes.Ord a, GHC.Float.Floating a) => Skylighting.Types.FromColor (Data.Colour.Internal.Colour a) 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 (GHC.Real.RealFrac a, GHC.Float.Floating a) => Skylighting.Types.ToColor (Data.Colour.Internal.Colour a) instance Data.Aeson.Types.FromJSON.FromJSON Skylighting.Types.Color 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 Data.Binary.Class.Binary Skylighting.Types.Syntax instance Data.Binary.Class.Binary Skylighting.Types.Context instance Data.Binary.Class.Binary Skylighting.Types.Rule instance Data.Binary.Class.Binary Skylighting.Types.TokenType instance Data.Aeson.Types.ToJSON.ToJSON Skylighting.Types.TokenType instance Data.Aeson.Types.ToJSON.ToJSONKey Skylighting.Types.TokenType instance Data.Aeson.Types.FromJSON.FromJSON Skylighting.Types.TokenType instance Data.Aeson.Types.FromJSON.FromJSONKey Skylighting.Types.TokenType instance Data.Binary.Class.Binary Skylighting.Types.ListItem instance Data.Binary.Class.Binary Skylighting.Types.ContextSwitch instance Data.Binary.Class.Binary Skylighting.Types.Matcher instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Skylighting.Types.WordSet a) instance Data.Binary.Class.Binary Skylighting.Types.KeywordAttr 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 module Skylighting.Parser -- | Parses a file containing a Kate XML syntax definition into a -- Syntax description. parseSyntaxDefinition :: FilePath -> IO (Either String Syntax) parseSyntaxDefinitionFromText :: FilePath -> Text -> Either String Syntax -- | Adds a syntax definition to a syntax map, replacing any existing -- definition with the same name. addSyntaxDefinition :: Syntax -> SyntaxMap -> SyntaxMap -- | Resolve Keyword matchers that refer to lists; following up include -- directives in the syntax map and producing WordSets. resolveKeywords :: SyntaxMap -> Syntax -> Syntax -- | 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.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.ContextStack instance GHC.Show.Show Skylighting.Tokenizer.TokenizerConfig instance GHC.Base.Functor (Skylighting.Tokenizer.Result e) instance (GHC.Show.Show a, GHC.Show.Show e) => GHC.Show.Show (Skylighting.Tokenizer.Result e a) instance GHC.Base.Functor Skylighting.Tokenizer.TokenizerM instance GHC.Base.Applicative Skylighting.Tokenizer.TokenizerM instance GHC.Base.Monad Skylighting.Tokenizer.TokenizerM instance GHC.Base.Alternative Skylighting.Tokenizer.TokenizerM instance GHC.Base.MonadPlus Skylighting.Tokenizer.TokenizerM instance Control.Monad.Reader.Class.MonadReader Skylighting.Tokenizer.TokenizerConfig Skylighting.Tokenizer.TokenizerM instance Control.Monad.State.Class.MonadState Skylighting.Tokenizer.TokenizerState Skylighting.Tokenizer.TokenizerM instance Control.Monad.Error.Class.MonadError GHC.Base.String Skylighting.Tokenizer.TokenizerM -- | This module provides routines to load syntax definitions from disk -- files. module Skylighting.Loader -- | Loads a syntax definition from the specified file path. The file path -- must refer to a file containing an XML Kate syntax definition. loadSyntaxFromFile :: FilePath -> IO (Either String Syntax) -- | Loads all syntax definitions from the specified directory by looking -- for files with an ".xml" extension. This function assumes such files -- are Kate XML syntax definitions, so XML files with unexpected contents -- will cause a parsing error returned as a Left. loadSyntaxesFromDir :: FilePath -> IO (Either String SyntaxMap) module Skylighting.Core -- | 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]