webforai 4.2.0 → 4.3.1

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.
Files changed (44) hide show
  1. package/THIRD_PARTY_NOTICES.md +42 -0
  2. package/dist/adapters/sites/hackernews.js +3 -3
  3. package/dist/adapters/sites/youtube.js +4 -2
  4. package/dist/bin.js +738 -474
  5. package/dist/cjs/adapters/sites/hackernews.js +3 -3
  6. package/dist/cjs/adapters/sites/youtube.js +5 -2
  7. package/dist/cjs/detect-client-shell.js +2 -0
  8. package/dist/cjs/extractors/lib/layout-tables.js +48 -9
  9. package/dist/cjs/extractors/lib/sanitize.js +38 -2
  10. package/dist/cjs/extractors/lib/terminators.js +2 -0
  11. package/dist/cjs/index.js +3 -0
  12. package/dist/cjs/mdast-handlers/custom-code-handler.js +31 -2
  13. package/dist/cjs/normalize/index.js +97 -4
  14. package/dist/cjs/utils/detect-code-lang.js +4 -5
  15. package/dist/cjs/utils/parse-html.js +73 -5
  16. package/dist/detect-client-shell.js +1 -0
  17. package/dist/extractors/lib/layout-tables.js +48 -9
  18. package/dist/extractors/lib/sanitize.js +38 -2
  19. package/dist/extractors/lib/terminators.js +2 -0
  20. package/dist/index.js +2 -0
  21. package/dist/mdast-handlers/custom-code-handler.js +31 -2
  22. package/dist/normalize/index.js +94 -3
  23. package/dist/types/adapters/sites/hackernews.js.map +1 -1
  24. package/dist/types/adapters/sites/youtube.d.ts +2 -0
  25. package/dist/types/adapters/sites/youtube.js.map +1 -1
  26. package/dist/types/detect-client-shell.d.ts +2 -0
  27. package/dist/types/detect-client-shell.js.map +1 -1
  28. package/dist/types/extractors/lib/layout-tables.d.ts +9 -2
  29. package/dist/types/extractors/lib/layout-tables.js.map +1 -1
  30. package/dist/types/extractors/lib/sanitize.js.map +1 -1
  31. package/dist/types/extractors/lib/terminators.js.map +1 -1
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/index.js.map +1 -1
  34. package/dist/types/mdast-handlers/custom-code-handler.d.ts +5 -0
  35. package/dist/types/mdast-handlers/custom-code-handler.js.map +1 -1
  36. package/dist/types/normalize/index.d.ts +21 -0
  37. package/dist/types/normalize/index.js.map +1 -1
  38. package/dist/types/utils/detect-code-lang.d.ts +7 -1
  39. package/dist/types/utils/detect-code-lang.js.map +1 -1
  40. package/dist/types/utils/parse-html.d.ts +12 -6
  41. package/dist/types/utils/parse-html.js.map +1 -1
  42. package/dist/utils/detect-code-lang.js +4 -5
  43. package/dist/utils/parse-html.js +73 -5
  44. package/package.json +3 -2
@@ -0,0 +1,42 @@
1
+ # Third-party notices
2
+
3
+ webforai is licensed under the Apache License 2.0. Parts of its behaviour are adapted from the
4
+ projects below, whose licenses require this notice. Each adapted place in the source names the
5
+ project it comes from.
6
+
7
+ ## Defuddle
8
+
9
+ <https://github.com/kepano/defuddle>
10
+
11
+ webforai reimplements two of Defuddle's rules on its own HTML tree:
12
+
13
+ - `src/extractors/lib/layout-tables.ts` — small multi-column tables are data tables, not page
14
+ layout (Defuddle keeps every multi-column table that does not nest tables; webforai keeps small
15
+ ones when their cells are short).
16
+ - `src/extractors/lib/sanitize.ts` — text repeated in an `aria-hidden="true"` element is not
17
+ converted twice (Defuddle removes every `aria-hidden` element; webforai removes only an exact
18
+ copy of a visible sibling).
19
+
20
+ ```
21
+ MIT License
22
+
23
+ Copyright (c) 2025 Steph Ango (@kepano)
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ of this software and associated documentation files (the "Software"), to deal
27
+ in the Software without restriction, including without limitation the rights
28
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ copies of the Software, and to permit persons to whom the Software is
30
+ furnished to do so, subject to the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be included in all
33
+ copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ SOFTWARE.
42
+ ```
@@ -23,11 +23,11 @@ var commentDepth = (row) => {
23
23
  return width === void 0 ? 0 : Math.round(width / 40);
24
24
  };
25
25
  var nest = (content, depth) => {
26
- let current = content;
26
+ let current = element("div", content);
27
27
  for (let level = 0; level < Math.min(depth, MAX_QUOTE_DEPTH); level++) {
28
- current = [element("blockquote", current)];
28
+ current = element("blockquote", [current]);
29
29
  }
30
- return current[0];
30
+ return current;
31
31
  };
32
32
  var storyNodes = (root) => {
33
33
  const nodes = [];
@@ -44,12 +44,13 @@ var extractAssignedJson = (source, name) => {
44
44
  var scriptText = (root) => collectElements(root, (element2) => element2.tagName === "script").map(
45
45
  (script) => script.children.map((child) => child.type === "text" ? child.value : "").join("")
46
46
  );
47
+ var PLAYER_RESPONSE_VARIABLE = "ytInitialPlayerResponse";
47
48
  var findPlayerResponse = (root) => {
48
49
  for (const source of scriptText(root)) {
49
- if (!source.includes("ytInitialPlayerResponse")) {
50
+ if (!source.includes(PLAYER_RESPONSE_VARIABLE)) {
50
51
  continue;
51
52
  }
52
- const parsed = extractAssignedJson(source, "ytInitialPlayerResponse");
53
+ const parsed = extractAssignedJson(source, PLAYER_RESPONSE_VARIABLE);
53
54
  if (parsed && typeof parsed === "object") {
54
55
  return parsed;
55
56
  }
@@ -158,6 +159,7 @@ var youtubeAdapter = {
158
159
  };
159
160
  var isYoutubeElement = isElement;
160
161
  export {
162
+ PLAYER_RESPONSE_VARIABLE,
161
163
  extractAssignedJson,
162
164
  isYoutubeElement,
163
165
  youtubeAdapter,