highlite

Source highlighter for programming or markup languages. Currently only few languages are supported, other languages may be added. The interface supports one language nested in another.

Note: Import packages/docutils/highlite to use this module

Types

TokenClass = enum
  gtEof, gtNone, gtWhitespace, gtDecNumber, gtBinNumber, gtHexNumber, gtOctNumber,
  gtFloatNumber, gtIdentifier, gtKeyword, gtStringLit, gtLongStringLit, gtCharLit,
  gtEscapeSequence, gtOperator, gtPunctuation, gtComment, gtLongComment,
  gtRegularExpression, gtTagStart, gtTagEnd, gtKey, gtValue, gtRawData, gtAssembler,
  gtPreprocessor, gtDirective, gtCommand, gtRule, gtHyperlink, gtLabel, gtReference,
  gtOther
  Source Edit
GeneralTokenizer = object of RootObj
  kind*: TokenClass
  start*, length*: int
  buf: cstring
  pos: int
  state: TokenClass
  Source Edit
SourceLanguage = enum
  langNone, langNim, langCpp, langCsharp, langC, langJava, langYaml
  Source Edit

Consts

sourceLanguageToStr: array[SourceLanguage, string] = ["none", "Nim", "C++", "C#", "C",
    "Java", "Yaml"]
  Source Edit
tokenClassToStr: array[TokenClass, string] = ["Eof", "None", "Whitespace", "DecNumber",
    "BinNumber", "HexNumber", "OctNumber", "FloatNumber", "Identifier", "Keyword",
    "StringLit", "LongStringLit", "CharLit", "EscapeSequence", "Operator",
    "Punctuation", "Comment", "LongComment", "RegularExpression", "TagStart",
    "TagEnd", "Key", "Value", "RawData", "Assembler", "Preprocessor", "Directive",
    "Command", "Rule", "Hyperlink", "Label", "Reference", "Other"]
  Source Edit

Procs

proc getSourceLanguage(name: string): SourceLanguage {...}{.raises: [], tags: [].}
  Source Edit
proc initGeneralTokenizer(g: var GeneralTokenizer; buf: cstring) {...}{.raises: [], tags: [].}
  Source Edit
proc initGeneralTokenizer(g: var GeneralTokenizer; buf: string) {...}{.raises: [], tags: [].}
  Source Edit
proc deinitGeneralTokenizer(g: var GeneralTokenizer) {...}{.raises: [], tags: [].}
  Source Edit
proc getNextToken(g: var GeneralTokenizer; lang: SourceLanguage) {...}{.raises: [], tags: [].}
  Source Edit