searchfetch 3.3.4 → 4.1.0
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/README.md +147 -120
- package/package.json +32 -28
- package/src/browser.js +213 -0
- package/src/compose.js +126 -0
- package/src/extract.js +233 -0
- package/src/index.js +45 -0
- package/src/markdown.js +50 -0
- package/src/server.js +174 -0
- package/src/templates.js +273 -0
- package/templates/crates-package.json +1 -1
- package/templates/devto.json +1 -1
- package/templates/docker-hub.json +1 -1
- package/templates/docs-page.json +1 -1
- package/templates/docs-rs.json +1 -1
- package/templates/duckduckgo-lite-search.json +49 -0
- package/templates/duckduckgo-search.json +3 -1
- package/templates/github-issue.json +1 -1
- package/templates/github-repo.json +1 -1
- package/templates/gitlab.json +1 -1
- package/templates/go-pkg.json +1 -1
- package/templates/google-search.json +3 -1
- package/templates/javadoc.json +1 -1
- package/templates/mdn-web-docs.json +1 -1
- package/templates/npm-package.json +1 -1
- package/templates/pypi-package.json +1 -1
- package/templates/raw.json +1 -1
- package/templates/reddit.json +1 -1
- package/templates/wikipedia.json +1 -1
- package/templates/youtube.json +1 -1
- package/index.js +0 -1276
- package/lib/output.js +0 -9
- package/lib/selectors.js +0 -27
- package/templates/__init__.py +0 -1
package/lib/output.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Paginate Unicode code points so offsets agree with Python and never split a surrogate pair. */
|
|
2
|
-
export function paginate(text, templateName, startIndex, maxLength) {
|
|
3
|
-
const characters = Array.from(text);
|
|
4
|
-
const start = Math.min(startIndex, characters.length);
|
|
5
|
-
const page = characters.slice(start, start + maxLength);
|
|
6
|
-
const end = start + page.length;
|
|
7
|
-
const next = end < characters.length ? ` Use start_index=${end} to read more.` : "";
|
|
8
|
-
return `${page.join("")}\n\n---\n[webfetch: template="${templateName}", showing characters ${start} to ${end} of ${characters.length} total.${next}]`;
|
|
9
|
-
}
|
package/lib/selectors.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** Split fallback selectors without breaking CSS functions, attributes, or escapes. */
|
|
2
|
-
export function splitSelectors(value = "") {
|
|
3
|
-
const selectors = [];
|
|
4
|
-
let start = 0;
|
|
5
|
-
let depth = 0;
|
|
6
|
-
let quote = null;
|
|
7
|
-
for (let i = 0; i < value.length; i++) {
|
|
8
|
-
const char = value[i];
|
|
9
|
-
if (char === "\\") {
|
|
10
|
-
i++;
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
if (quote) {
|
|
14
|
-
if (char === quote) quote = null;
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
if (char === '"' || char === "'") quote = char;
|
|
18
|
-
else if (char === "(" || char === "[") depth++;
|
|
19
|
-
else if (char === ")" || char === "]") depth--;
|
|
20
|
-
else if (char === "," && depth === 0) {
|
|
21
|
-
selectors.push(value.slice(start, i).trim());
|
|
22
|
-
start = i + 1;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
selectors.push(value.slice(start).trim());
|
|
26
|
-
return selectors;
|
|
27
|
-
}
|
package/templates/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""Built-in extraction templates distributed with SearchFetch."""
|