Quick Take

import { strict as assert } from "assert";
import { cparser } from "codsen-parser";

assert.deepEqual(cparser("<br>z</a>"), [
  {
    type: "tag",
    kind: "inline",
    tagName: "br",
    tagNameStartsAt: 1,
    tagNameEndsAt: 3,
    closing: false,
    void: true,
    pureHTML: true,
    recognised: true,
    start: 0,
    end: 4,
    value: "<br>",
    attribs: [],
    children: [],
  },
  {
    type: "text",
    start: 4,
    end: 5,
    value: "z",
  },
  {
    type: "tag",
    kind: "inline",
    tagName: "a",
    tagNameStartsAt: 7,
    tagNameEndsAt: 8,
    closing: true,
    void: false,
    pureHTML: true,
    recognised: true,
    start: 5,
    end: 9,
    value: "</a>",
    attribs: [],
    children: [],
  },
]);

Notice

codsen-parser is currently being developed. Please come back later.

Changelog

See it in the monorepo opens in a new tab, on GitHub.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub opens in a new tab.

Any code contributions welcome! All Pull Requests will be dealt promptly.

Licence

MIT opens in a new tab

Copyright © 2010–2021 Roy Revelt and other contributors

Related articles:

Related packages:

📦 codsen-tokenizer 6.0.1
HTML and CSS lexer aimed at code with fatal errors, accepts mixed coding languages
📦 emlint 5.0.1
Pluggable email template code linter