Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→is-html-attribute-closingnext

is-html-attribute-closing4.2.1

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

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • PURPOSE
  • API — ISATTRCLOSING…
  • API — VERSION
  • Changelog

Installation

Quick Take

Examples

  • Broken #1
  • Broken #2
  • Broken #3
  • Return false for unusable source indexes
  • Recover when spaces replace attribute equals signs
  • Recover when an attribute value has no opening quote
  • Distinguish quotes inside a value from its closing quote
  • Detect the end of a single-quoted attribute value
  • Ignore quotes that belong to templating code inside a value

Purpose

This program detects, is a character at a given index in a given string being a closing of an attribute. In healthy code, that’s normally a double quotes character.

This program is aimed at fixing seriously broken HTML code — missing closing quotes, mismatching closing quotes, swapped quotes and unencoded “content” quotes as a part of attribute’s value.

It’s driving the codsen-tokenizer which in turn powers codsen-parser which in turn powers emlint.

For healthy HTML code, however, finding the closing double quotes is a trivial task.

API — isAttrClosing()

The main function isAttrClosing() is imported like this:

It’s a function which takes three input arguments:

Input argumentTypeObligatoryDescription
str
Type: String
Obligatory: yes
strStringyesThe input string of zero or more characters
idxOfAttrOpening
Type: Natural number or zero
Obligatory: yes
idxOfAttrOpeningNatural number or zeroyesIndex of an opening quote of an attribute
isThisClosingIdx
Type: Natural number
Obligatory: yes
isThisClosingIdxNatural numberyesIndex you ask this program to evaluate, is it a closing quote

The function returns a boolean.

If anything is wrong with the input arguments, the program returns false. It never throws.

API — version

You can import version:

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab