Function: isHTML()
isHTML(
value):boolean
Tell whether a string looks like HTML: whether its first 1000 characters (after its leading and trailing spaces are trimmed) contain a <!doctype html>, or an opening tag of a standard HTML element (<p>, <div class="a">) or of a custom element named x-…. The markup is not validated ('<p>' alone is HTML, '<foo>bar</foo>' is not), and a tag anywhere in the head counts ('text <b>bold</b>' is HTML).
Parameters
value
string
The string to test; a value which is not a string (undefined, a number) gives false.
Returns
boolean
true when an HTML tag is found, false otherwise.
Example
typescript
import {isHTML} from 'lakutata/utils'
console.log(isHTML('<!doctype html><html></html>'), isHTML('<p>Hello</p>'))
//true true
console.log(isHTML('<note>Hello</note>'), isHTML('1 < 2'))
//false false