0.1.8 • Published 1 year ago

html-tag-check v0.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Introduction

This library enable to check html tag whether html is missed opening or closing tags by TypeScript

Installation

You can use this from Node.js or JavaScript whatever.

npm install html-tag-check # npm
yarn add html-tag-check # yarn
pnpm add html-tag-check # pnpm

How to use

import { htmlTagCheck } from "html-tag-check";

const HTML = "<div><p>Opening div tag isn't necessary!!</p>";
htmlTagCheck(HTML);
// => { type: "invalid_extra_opening_tag", detail: { type: "opening", tag: "<div>", index: 0 } }

Arguments

NameTypeRequiredDescription
htmlstringtruehtml you want to check
optionsobjectfalsethe options of checker

options

NameTypeRequiredDescription
trimHtmlbooleanfalseremove new lines and white spaces from html string
ignoreTagNamesstring[]falsetag names you want to ignore check. e.g. "size","template"

Return

Valid

{
  type: "valid";
}

Invalid

extra closing tag error
{
  type: "invalid_extra_closing_tag";
  detail: [
    {
      type: "closing"; // closing tag error
      tag: string; // tag name like </div>
      index: number; // tag index number from html string.
    }
  ];
}
mismatch opening and closing tag error
{
  type: "invalid_mismatch_opening_and_closing_tag";
  detail: [
    {
      type: "opening";
      tag: string;
      index: number;
    },
    {
      type: "closing";
      tag: string;
      index: number;
    }
  ];
}
extra opening tag error
{
  type: "invalid_extra_opening_tag";
  detail: [
    {
      type: "opening";
      tag: string;
      index: number;
    }
  ];
};
0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago