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 | 
|---|---|---|---|
| inputType: String Obligatory: yes | |||
| input | String | yes | Text you want to strip HTML tags from | 
| optsType: 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 | 
|---|---|---|---|
| htmlType: Boolean Default: true | |||
| html | Boolean | true | Should we strip HTML, XML tags and their comments | 
| cssType: Boolean Default: true | |||
| css | Boolean | true | Should we strip head CSS style tags and CSS rules | 
| textType: Boolean Default: false | |||
| text | Boolean | false | Should we strip text | 
| templatingTagsType: Boolean Default: false | |||
| templatingTags | Boolean | false | Should we strip any templating tags (like Nunjucks) | 
| jsType: Boolean Default: true | |||
| js | Boolean | true | Should we strip any JS code | 
| reportProgressFuncType: nullor FunctionDefault: null | |||
| reportProgressFunc | nullor Function | null | Pass a function, progress value, 0-100will be passed to it | 
| reportProgressFuncFromType: Natural number [0; 100] Default: 0 | |||
| reportProgressFuncFrom | Natural number [0; 100] | 0 | Starting progress percentage | 
| reportProgressFuncToType: 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 | 
|---|---|---|
| logType: Plain object | ||
| log | Plain object | Various statistics | 
| resultType: String | ||
| result | String | The result. | 
| applicableOptsType: 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 | 
| templatingLangType: 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: