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

Package detail

is-html-attribute-closing

codsen395MIT4.0.22TypeScript support: included

Is a character on a given index a closing of an HTML attribute?

attribute, character, codsen, emlint, end, ending, ends, html, is, lexer, parsing, tag, tokeniser, tokenizer

readme

is-html-attribute-closing

Is a character on a given index a closing of an HTML attribute?

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.3.0 (npm i is-html-attribute-closing@2.3.0).

npm i is-html-attribute-closing

Quick Take

import { strict as assert } from "assert";

import { isAttrClosing } from "is-html-attribute-closing";

const str = '<a href="zzz" target="_blank" style="color: black;">';

// <a href="zzz" target="_blank" ...
//                      ^
//                  index 21

// <a href="zzz" target="_blank" ...
//                             ^
//                         index 28

assert.equal(
  isAttrClosing(
    str, // reference string
    21, // known opening (or in absence of a quote, a start of a value)
    28, // we ask, is this a closing on the attribute?
  ),
  true, // the answer
);

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.0 (2021-09-09)

Features

BREAKING CHANGES

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

2.3.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

2.2.6 (2021-04-11)

Reverts

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

2.2.0 (2021-03-23)

Features

  • improved recognition of HTML inline style attribute patterns (5c104d3)

2.1.0 (2021-02-07)

Features

  • improved ERB templating tag recognition (ecb3272)

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 (6a8cf5a)

BREAKING CHANGES

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

1.5.0 (2020-12-11)

Fixed

  • correctly interpret equal chars inside urls (71f8dcf)

Features

  • improve the safeguards against legit equal characters (d1b34fa)

1.4.0 (2020-11-28)

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

1.3.0 (2020-10-12)

Features

  • algorithm improvements (e2b2471)
  • recognise nested rogue quote pairs inside attr values (7366a63)

1.2.0 (2020-05-17)

Features

  • insurance against the Killer Triplet (21c64a2)

1.1.0 (2020-04-13)

Features

  • initial scaffolding (5968866)
  • improve the mismatching quote recognition (967bd66)
  • improvements to mismatching HTML attribute quote pair recognition (050dbe0)
  • recognise missing tag closing brackets (2639868)
  • recognise repeated (even spaced) equal signs in front of attributes (a1fa244)
  • starting index is not on a quote; attribute is missing opening quote (795d3a8)