HighlightJS

@native @JSImport("highlight.js") @JSType object HighlightJS extends HighlightStatic
class Object
trait Any
class Object
trait Matchable
class Any

Value members

Inherited methods

def getLanguage(name: String): UndefOr[Object]

Looks up a language by name or alias. Returns the language object if found, undefined otherwise.

Looks up a language by name or alias. Returns the language object if found, undefined otherwise.

Inherited from
HighlightStatic
def hasOwnProperty(v: String): Boolean
Inherited from
Object
def highlight(name: String, value: String, ignoreIllegals: UndefOr[Boolean], continuation: UndefOr[Object]): HighlightJSResult

Core highlighting function. Accepts a language name, or an alias, and a string with the code to highlight. The ignore_illegals parameter, when present and evaluates to a true value, forces highlighting to finish even in case of detecting illegal syntax for the language instead of throwing an exception. The continuation is an optional mode stack representing unfinished parsing. When present, the function will restart parsing from this state instead of initializing a new one.

Core highlighting function. Accepts a language name, or an alias, and a string with the code to highlight. The ignore_illegals parameter, when present and evaluates to a true value, forces highlighting to finish even in case of detecting illegal syntax for the language instead of throwing an exception. The continuation is an optional mode stack representing unfinished parsing. When present, the function will restart parsing from this state instead of initializing a new one.

Returns

Returns an object with the following properties: language: language name, same as the one passed into a function, returned for consistency with highlightAuto relevance: integer value value: HTML string with highlighting markup top: top of the current mode stack

Inherited from
HighlightStatic
def highlightAuto(value: String, languageSubset: UndefOr[Array[String]]): HighlightJSResult

Highlighting with language detection. Accepts a string with the code to highlight and an optional array of language names and aliases restricting detection to only those languages. The subset can also be set with configure, but the local parameter overrides the option if set.

Highlighting with language detection. Accepts a string with the code to highlight and an optional array of language names and aliases restricting detection to only those languages. The subset can also be set with configure, but the local parameter overrides the option if set.

Returns

Returns an object with the following properties: language: detected language relevance: integer value value: HTML string with highlighting markup second_best: object with the same structure for second-best heuristically detected language, may be absent

Inherited from
HighlightStatic
def highlightBlock(el: Element): Unit

Applies highlighting to a DOM node containing code. This function is the one to use to apply highlighting dynamically after page load or within initialization code of third-party Javascript frameworks. The function uses language detection by default but you can specify the language in the class attribute of the DOM node. See the class reference for all available language names and aliases.

Applies highlighting to a DOM node containing code. This function is the one to use to apply highlighting dynamically after page load or within initialization code of third-party Javascript frameworks. The function uses language detection by default but you can specify the language in the class attribute of the DOM node. See the class reference for all available language names and aliases.

Inherited from
HighlightStatic
def initHighlighting(): Unit

Applies highlighting to all `

Applies highlighting to all `

..

` blocks on a page.

..

Inherited from
HighlightStatic

Attaches highlighting to the page load event.

Attaches highlighting to the page load event.

Inherited from
HighlightStatic
def isPrototypeOf(v: Object): Boolean
Inherited from
Object
def listLanguages(): Array[String]

Returns the languages names list.

Returns the languages names list.

Inherited from
HighlightStatic
def propertyIsEnumerable(v: String): Boolean
Inherited from
Object
def registerLanguage(name: String, language: Function): Unit

Adds new language to the library under the specified name. Used mostly internally.

Adds new language to the library under the specified name. Used mostly internally.

Value Params
language

A function that returns an object which represents the language definition. The function is passed the hljs object to be able to use common regular expressions defined within it.

name

A string with the name of the language being registered

Inherited from
HighlightStatic
def toLocaleString(): String
Inherited from
Object
def valueOf(): Any
Inherited from
Object

Inherited fields

val configure: UndefOr[Object]

Configures global options: * tabReplace: a string used to replace TAB characters in indentation. useBR: a flag to generate
tags instead of new-line characters in the output, useful when code is marked up using a non-

Configures global options: * tabReplace: a string used to replace TAB characters in indentation. useBR: a flag to generate
tags instead of new-line characters in the output, useful when code is marked up using a non-

 container.
classPrefix: a string prefix added before class names in the generated markup, used for backwards compatibility with stylesheets.
languages: an array of language names and aliases restricting auto detection to only these languages.
Accepts an object representing options with the values to updated. Other options don’t change
{{{
 hljs.configure({
   tabReplace: '    ', // 4 spaces
   classPrefix: ''     // don't append class prefix
                       // … other options aren't changed
 });
 hljs.initHighlighting();
}}}
Inherited from
HighlightStatic
val fixMarkup: UndefOr[String]

Post-processing of the highlighted markup. Currently consists of replacing indentation TAB characters and using
tags instead of new-line characters. Options are set globally with configure. Accepts a string with the highlighted markup.

Post-processing of the highlighted markup. Currently consists of replacing indentation TAB characters and using
tags instead of new-line characters. Options are set globally with configure. Accepts a string with the highlighted markup.

Inherited from
HighlightStatic