Needlessly Provoking Marsupials

    is-html-attribute-closing
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.7 • Public • Published

    is-html-attribute-closing

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

    Install

    This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:

    npm i is-html-attribute-closing

    If you need a legacy version which works with require, use version 2.3.0

    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 and examples.

    Contributing

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

    Licence

    MIT License

    Copyright (c) 2010-2021 Roy Revelt and other contributors

    ok codsen star

    Install

    npm i is-html-attribute-closing

    DownloadsWeekly Downloads

    254

    Version

    3.0.7

    License

    MIT

    Unpacked Size

    69.5 kB

    Total Files

    13

    Last publish

    Collaborators

    • royston