Installation
Quick Take
Idea
A parsing alternative of string-strip-html
.
Features
- Pick what to strip: HTML and/or CSS and/or text and/or templating tags
- Supports well: Nunjucks/Jinja, JSP, Responsys
- Should support all other templating languages and ESP templating tags
- Runs off our own lexer
API — stri()
The main function stri()
is imported like this:
It’s a function which takes two input arguments:
Input argument | Type | Obligatory | Description |
---|---|---|---|
input Type: String Obligatory: yes | |||
input | String | yes | Text you want to strip HTML tags from |
opts Type: Plain object Obligatory: no | |||
opts | Plain object | no | The Optional Options Object, see below for its API |
The Optional Options Object has the following shape:
Key | Type | Default | Description |
---|---|---|---|
html Type: Boolean Default: true | |||
html | Boolean | true | Should we strip HTML, XML tags and their comments |
css Type: Boolean Default: true | |||
css | Boolean | true | Should we strip head CSS style tags and CSS rules |
text Type: Boolean Default: false | |||
text | Boolean | false | Should we strip text |
templatingTags Type: Boolean Default: false | |||
templatingTags | Boolean | false | Should we strip any templating tags (like Nunjucks) |
js Type: Boolean Default: true | |||
js | Boolean | true | Should we strip any JS code |
reportProgressFunc Type: null or FunctionDefault: null | |||
reportProgressFunc | null or Function | null | Pass a function, progress value, 0 -100 will be passed to it |
reportProgressFuncFrom Type: Natural number [0; 100] Default: 0 | |||
reportProgressFuncFrom | Natural number [0; 100] | 0 | Starting progress percentage |
reportProgressFuncTo Type: Natural number [0; 100] Default: 100 | |||
reportProgressFuncTo | Natural number [0; 100] | 100 | Ending progress percentage |
Here are all defaults in one place for copying:
The function will return a plain object of a shape:
Key’s name | Type | Description |
---|---|---|
log Type: Plain object | ||
log | Plain object | Various statistics |
result Type: String | ||
result | String | The result. |
applicableOpts Type: Plain object, only boolean keys from opts | ||
applicableOpts | Plain object, only boolean keys from opts | Tells which options object keys would have made a difference for this string input, if toggled differently |
templatingLang Type: Plain object | ||
templatingLang | Plain object | Pipes the output of detect-templating-language |
API — defaults
You can import defaults
:
It's a plain object:
The main function calculates the options to be used by merging the options you passed with these defaults.
API — version
You can import version
: