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

1.0.0 • Public • Published

is-html-ts

forked from is-html

Check if a string is HTML

You should not use this for any kind of validation, sanitation, or XSS checks.

Install

$ npm install is-html-ts
$ yarn add is-html-ts

Usage

import isHtml, { basic, full } from 'is-html-ts';
import type { Options } from 'is-html-ts'

isHtml('<p>I am HTML</p>');
//=> true

isHtml('<!doctype><html><body><h1>I ❤ unicorns</h1></body></html>');
//=> true

isHtml('<cake>I am XML</cake>');
//=> false

isHtml('>+++++++>++++++++++>+++>+<<<<-');
//=> false

const customOptions: Options = {
    regExp: 'basic',
    length: 'all',
};

isHtml('<!doctype><html><body><h1>I ❤ unicorns</h1></body></html>', customOptions);
//=> true

isHtml('<cake>I am XML</cake>', customOptions);
//=> false

Note: It does not detect deprecated HTML tags.

Package Sidebar

Install

npm i is-html-ts

Weekly Downloads

31

Version

1.0.0

License

MIT

Unpacked Size

9.05 kB

Total Files

10

Last publish

Collaborators

  • ikloster