Global scope
Members
Methods
Call highlightElement on element with a css class starting with `shj-lang-`(optopt)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
opt
[optional] |
HighlightOptions | {} | Customization options |
Change the current used theme for highlighting(name)
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)
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)
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}
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}
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');
Try to find the language the given code belong to(code) → {String}
Parameters:
Name | Type | Description |
---|---|---|
code
|
String | The code |
Returns:
The language of the code
- Type
- String
Type Definitions
HighlightOptions
Properties:
Name | Type | Default | Description |
---|---|---|---|
hideLineNumbers
[optional] |
Boolean | false | Indicates whether to hide line numbers |
Type:
Object