• api
  • since 7.5.0.0
CloneableInstantiable
Constants
public Highlight\Highlighter::SPAN_END_TAG = ''
 


  • since 9.12.0.4
Methods
public __construct()
public disableSafeMode()
 


  • since 9.17.1.0
  • return void
public enableSafeMode()
 


  • since 9.17.1.0
  • return void
public getAliasesForLanguage( $name)
 
Returns list of all available aliases for given language name.

  • throws DomainException if the requested language was not in this Highlighter's language set
  • since 9.12.0.3
  • return string[] An array of all aliases associated with the requested language name language. Passed-in name is included as well.
public getClassPrefix()
 
Get the class prefix string.

  • return string The class prefix string
public getTabReplace()
 
Get the tab replacement string.

  • return string The tab replacement string
public highlight( $languageName, $code, $ignoreIllegals = true, $continuation = NULL)
 
Core highlighting function. Accepts a language name, or an alias, and a string with the code to highlight. Returns an object with the following properties: - relevance (int) - value (an HTML string with highlighting markup).

  • todo In v10.x, change the return type from \stdClass to HighlightResult
  • throws DomainException if the requested language was not in this Highlighter's language set
  • throws Exception if an invalid regex was given in a language file
  • return HighlightResult|\stdClass
public highlightAuto( $code, $languageSubset = NULL)
 
Highlight the given code by highlighting the given code with each registered language and then finding the match with highest accuracy.

  • throws Exception if an invalid regex was given in a language file
  • throws DomainException if the attempted language to check does not exist
  • return HighlightResult|\stdClass
public listLanguages( $include_aliases = false)
 
Return a list of all supported languages. Using this list in setAutodetectLanguages will turn on autodetection for all supported languages.

  • since 9.12.0.3The `$include_aliases` parameter was added
  • since 8.3.0.0
  • return string[] An array of language names
public static registerLanguage( $languageId, $filePath, $overwrite = false)
 
Register a language definition with the Highlighter's internal language storage. Languages are stored in a static variable, so they'll be available across all instances. You only need to register a language once.

public setAutodetectLanguages(array $set)
 
Set the set of languages used for autodetection. When using autodetection the code to highlight will be probed for every language in this set. Limiting this set to only the languages you want to use will greatly improve highlighting speed.

  • return void
public setClassPrefix( $classPrefix)
 
Set the class prefix string.

  • return void
public setTabReplace( $tabReplace)
 
Set the tab replacement string. This defaults to NULL: no tabs will be replaced.

  • return void
Properties
private static $aliases
 


  • var array A mapping from alias (key) to main language ID (value)
private static $classMap
 


  • var array A mapping of a language ID to a Language definition
private $codeToHighlight
 


  • var string The current code we are highlighting
private $continuations
 


  • var array
private $ignoreIllegals
 


  • var bool
private $language
 


  • var Language|null
private static $languages
 


  • var string[] A list of registered language IDs
private $lastMatch
private $modeBuffer
 


  • var string
private $options
 


  • var array
private $relevance
 


  • var int
private $result
 


  • var string
private $safeMode
 


  • var bool
private $top
 


  • var Mode|null
Methods
private autoDetection( $name)
 
Determine whether or not a language definition supports auto detection.

  • return bool
private buildSpan( $className, $insideSpan, $leaveOpen = false, $noPrefix = false)
 


  • return string
private doBeginMatch( $match)
 


  • return int
private doEndMatch( $match)
 


  • return int|null
private endOfMode( $mode, $lexeme)
 


  • return Mode|null
private escape( $value)
 


  • return string
private escapeRe( $value)
 
private getLanguage( $name)
 


  • return Language|null
private keywordMatch( $mode, $match)
 


  • return mixed|null
private processBuffer()
 


  • return void
private processKeywords()
 


  • return string
private processLexeme( $textBeforeMatch, $match = NULL)
 


  • return int
private processSubLanguage()
 


  • return string
private static registerLanguages()
 
Loop through all of the languages in our `languages` folder and automatically register them all.

  • since 8.3.0.0
  • return void
private replaceTabs( $code)
 
Replace tabs for something more usable.

  • return string
private startNewMode( $mode)
 


  • return void
private testRe( $re, $lexeme)
 


  • return bool
Properties
private static $aliases
 


  • var array A mapping from alias (key) to main language ID (value)
private static $classMap
 


  • var array A mapping of a language ID to a Language definition
private static $languages
 


  • var string[] A list of registered language IDs
Methods
public static registerLanguage( $languageId, $filePath, $overwrite = false)
 
Register a language definition with the Highlighter's internal language storage. Languages are stored in a static variable, so they'll be available across all instances. You only need to register a language once.

private static registerLanguages()
 
Loop through all of the languages in our `languages` folder and automatically register them all.

  • since 8.3.0.0
  • return void
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only