Module: index Base script

index Base script

Source:
index.js, line 1

Methods

highlightAll(optopt)

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

highlightElement(elm, langopt, modeopt, optopt)

Source:
index.js, line 111
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

highlightText(src, lang, multilineopt, optopt) → {String}

Source:
index.js, line 90
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');

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

Source:
index.js, line 21
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

Type Definitions

HighlightOptions

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

Object