blob: 93e21a8ec896317d6d9a750260ec21342b7624b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Leave only HTML
import { strict as assert } from "assert";
import { stripHtml } from "../dist/string-strip-html.esm.js";
const someHtml = `<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>Title</h1>
Some text.
</body>
</html>`;
assert.equal(
stripHtml(someHtml).allTagLocations.reduce(
(acc, [from, to]) => `${acc}${someHtml.slice(from, to)}`,
""
),
`<!DOCTYPE html><html lang="en" dir="ltr"><head><meta charset="utf-8"><title></title></head><body><h1></h1></body></html>`
);
|