Installation
Quick Take
Examples
Purpose
Detect, is an opening bracket (<) as string position X being a tag opening? Otherwise, it might be an un-encoded text.
API — isOpening()
The main function isOpening() is imported like this:
It’s a function which takes three input arguments:
| Input argument | Type | Obligatory | Description |
|---|---|---|---|
strType: String Obligatory: yes | |||
str | String | yes | The input string of zero or more characters |
idxType: Natural number or zero Obligatory: no (defaults to 0) | |||
idx | Natural number or zero | no (defaults to 0) | Index of an opening bracket (<) |
optsType: falsy or Plain Object Obligatory: no | |||
opts | falsy or Plain Object | no | Optional Options Object |
The optional options object has the following shape:
| Key | Type | Default | Description |
|---|---|---|---|
allowCustomTagNamesType: boolean Default: false | |||
allowCustomTagNames | boolean | false | Program is aware of all known HTML tag names and by default will exclude what it can’t recognise. You can turn off that behaviour and make it rely on bracket/attribute patterns only. |
skipOpeningBracketType: boolean Default: false | |||
skipOpeningBracket | boolean | false | By default, algorithm expects that idx is on a bracket <. If you enable it, you can start from idx at the first tag’s character. |
Here are all defaults in one place for copying:
Function returns a boolean.
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:
In Practice
This program allows us to tackle any raw unencoded brackets in HTML code, for example: <div> < </div>.
It will drive codsen-tokenizer which in turn will drive codsen-parser which in turn will drive emlint.