Global

Global scope

Members

languages

Language detector
Source:
detect.js, line 5

Methods

Call highlightElement on element with a css class starting with `shj-lang-`(optopt)

Source:
index.js, line 130
Parameters:
Name Type Default Description
opt
[optional]
HighlightOptions {} Customization options

Change the current used theme for highlighting(name)

Source:
term.js, line 33
Parameters:
Name Type Description
name
String The name of the theme

Find the tokens in the given code and call the callback(src, lang, token)

Source:
index.js, line 20
Parameters:
Name Type Description
src
String The code
lang
String or Object The language of the code
token
function The callback function this function will be given * the text of the token * the type of the token

Highlight a DOM element by getting the new innerHTML with highlightText(elm, langopt, modeopt, optopt)

Source:
index.js, line 110
Parameters:
Name Type Default Description
elm
HTMLElement The DOM element
lang
[optional]
String The language of the code (seaching by default on `elm` for a 'shj-lang-' class)
mode
[optional]
String The display mode (guessed by default) * inline inside `code` element * oneline inside `div` element and containing only one line * multiline inside `div` element
opt
[optional]
HighlightOptions {} Customization options

Highlight a string passed as argument and return a string that can directly be printed(src, lang) → {String}

Source:
term.js, line 9
Parameters:
Name Type Description
src
String The code
lang
String The language of the code
Returns:
The highlighted string
Type
String

Highlight a string passed as argument and return it(src, lang, multilineopt, optopt) → {String}

Source:
index.js, line 89
Parameters:
Name Type Default Description
src
String The code
lang
String The language of the code
multiline
[optional]
Boolean true If it is multiline, it will add a wrapper for the line numbering and header
opt
[optional]
HighlightOptions {} Customization options
Returns:
The highlighted string
Type
String
Example
elm.innerHTML = await highlightText(code, 'js');

Highlight and print a given string(code)

Source:
term.js, line 25
Parameters:
Name Type Description
code
String The code

Try to find the language the given code belong to(code) → {String}

Source:
detect.js, line 29
Parameters:
Name Type Description
code
String The code
Returns:
The language of the code
Type
String

Type Definitions

HighlightOptions

Source:
index.js, line 84
Properties:
Name Type Default Description
hideLineNumbers
[optional]
Boolean false Indicates whether to hide line numbers
Type:

Object