webforai 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/extract-hast.js
CHANGED
|
@@ -25,20 +25,23 @@ var import_hast_util_select = require("hast-util-select");
|
|
|
25
25
|
var import_unist_util_filter = require("unist-util-filter");
|
|
26
26
|
const REMOVE_REGEX = /header|nav|speechify-ignore|assist|-ad-|hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|assist|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i;
|
|
27
27
|
const extractHast = (hast) => {
|
|
28
|
-
const
|
|
28
|
+
const selectors = ["article", "div#article", "main", "div.container"];
|
|
29
|
+
let selectedElement = hast;
|
|
30
|
+
for (const selector of selectors) {
|
|
31
|
+
const element = (0, import_hast_util_select.select)(selector, hast);
|
|
32
|
+
if (element) {
|
|
33
|
+
selectedElement = element;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const removedElements = (0, import_unist_util_filter.filter)(selectedElement, (node) => {
|
|
29
38
|
if (node.type !== "element")
|
|
30
39
|
return true;
|
|
31
40
|
const element = node;
|
|
32
41
|
const elementName = `${element.tagName} ${element.properties.id} ${element.properties.className}`;
|
|
33
42
|
return !REMOVE_REGEX.test(elementName);
|
|
34
43
|
});
|
|
35
|
-
|
|
36
|
-
for (const selector of selectors) {
|
|
37
|
-
const element = (0, import_hast_util_select.select)(selector, removeElements);
|
|
38
|
-
if (element)
|
|
39
|
-
return element;
|
|
40
|
-
}
|
|
41
|
-
return removeElements;
|
|
44
|
+
return removedElements;
|
|
42
45
|
};
|
|
43
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
47
|
0 && (module.exports = {
|
package/dist/extract-hast.js
CHANGED
|
@@ -3,20 +3,23 @@ import { select } from "hast-util-select";
|
|
|
3
3
|
import { filter } from "unist-util-filter";
|
|
4
4
|
var REMOVE_REGEX = /header|nav|speechify-ignore|assist|-ad-|hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|assist|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i;
|
|
5
5
|
var extractHast = (hast) => {
|
|
6
|
-
const
|
|
6
|
+
const selectors = ["article", "div#article", "main", "div.container"];
|
|
7
|
+
let selectedElement = hast;
|
|
8
|
+
for (const selector of selectors) {
|
|
9
|
+
const element = select(selector, hast);
|
|
10
|
+
if (element) {
|
|
11
|
+
selectedElement = element;
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const removedElements = filter(selectedElement, (node) => {
|
|
7
16
|
if (node.type !== "element")
|
|
8
17
|
return true;
|
|
9
18
|
const element = node;
|
|
10
19
|
const elementName = `${element.tagName} ${element.properties.id} ${element.properties.className}`;
|
|
11
20
|
return !REMOVE_REGEX.test(elementName);
|
|
12
21
|
});
|
|
13
|
-
|
|
14
|
-
for (const selector of selectors) {
|
|
15
|
-
const element = select(selector, removeElements);
|
|
16
|
-
if (element)
|
|
17
|
-
return element;
|
|
18
|
-
}
|
|
19
|
-
return removeElements;
|
|
22
|
+
return removedElements;
|
|
20
23
|
};
|
|
21
24
|
export {
|
|
22
25
|
extractHast
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-hast.js","sourceRoot":"","sources":["../../src/extract-hast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,YAAY,GACjB,kQAAkQ,CAAC;AAEpQ,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAU,EAAE,EAAE;IACzC,MAAM,
|
|
1
|
+
{"version":3,"file":"extract-hast.js","sourceRoot":"","sources":["../../src/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