Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-html-tag-opening

codsen290MIT4.0.33TypeScript support: included

Does an HTML tag start at given position?

bracket, brackets, cleaning, code, codsen, html, is, non-parsing, opening, parsing, tag, tokenizer, utility

readme

is-html-tag-opening

Does an HTML tag start at given position?

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 2.1.0 (npm i is-html-tag-opening@2.1.0).

npm i is-html-tag-opening

Quick Take

import { strict as assert } from "assert";

import { isOpening } from "is-html-tag-opening";

const text = "<span>a < b<span>";

// opening span tag's opening
assert.equal(isOpening(text, 0), true);

// unencoded bracket between a and b
assert.equal(isOpening(text, 8), false);

// closing span tag's opening
assert.equal(isOpening(text, 11), true);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

ok codsen star

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

3.1.0 (2022-08-12)

Features

3.0.15 (2022-04-18)

Fixed

3.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

2.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

2.0.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

2.0.9 (2021-03-23)

Fixed

  • address the opts.allowCustomTagNames in context of malformed closing tags (0a785fa)
  • better detection of missing opening bracket when slash + known tag name follows (b569953)

2.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

2.0.0 (2021-01-23)

Features

  • rewrite in TS, start using named exports (7842225)

BREAKING CHANGES

  • previously, you'd consume like: import isOpening from ... - now import { isOpening } from ...

1.10.1 (2020-12-15)

Performance Improvements

  • improve from 1.91 opts/sec to 186.179 opts/sec in one branch (eadc8ee)

1.10.0 (2020-12-13)

Features

  • improve the broken tag recognition, set up more exhaustive tests (811a166), closes #1

1.9.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

1.8.0 (2020-09-07)

Features

  • add type checks and split tests into multiple files (6a40e8b)

1.7.0 (2020-03-16)

Fixed

  • require that tag name would not be followed by equal sign (9081082)

Features

  • add more tests and finally fix the dashes in front of tag names (2a36483)
  • make the requirements more strict for when opening bracket is missing (a672d99)
  • opts.skipOpeningBracket (6238e92)
  • require that tag names matched if !opts.allowCustomTagNames (0638865)
  • require that tag names would not start with a dash (messes up broken comment tag logic) (e0ff061)

1.6.0 (2020-02-09)

Features

  • opts.allowCustomTagNames (1771e43)

1.5.0 (2019-12-27)

Features

  • recognise tags that have attributes with no quotes (cfe677c)

1.4.0 (2019-12-21)

Features

  • recognise unknown html attributes with dashes (d13d043)

1.3.0 (2019-12-14)

Features

  • add one more type of char arrangement - slash in front, confirmed tag name follows (8d1ecc9)

1.2.0 (2019-11-18)

Features

  • improve the algorithm to include way more broken tag cases (fd94b61)
  • loosen the requirements for the character that follows recognised tag name sequence (6201e2b)

1.1.0 (2019-11-02)

Features

  • init (04dfb3b)
  • recognise any html tags which start with bracket followed by a known tag name (3ac6327)

1.0.0 (2019-11-01)

  • First public release