html-get 2.24.11 → 2.26.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/package.json +1 -1
- package/scripts/postinstall +1 -0
- package/src/auto-domains.json +6 -0
- package/src/index.js +27 -12
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "html-get",
|
|
3
3
|
"description": "Get the HTML from any website, fine-tuned for correction & speed",
|
|
4
4
|
"homepage": "https://nicedoc.com/microlinkhq/html-get",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.26.0",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"bin": {
|
package/scripts/postinstall
CHANGED
|
@@ -26,6 +26,7 @@ const domains = [
|
|
|
26
26
|
[['domainWithoutSuffix', 'github']],
|
|
27
27
|
[['domainWithoutSuffix', 'gitlab']],
|
|
28
28
|
[['domainWithoutSuffix', 'google']],
|
|
29
|
+
[['domainWithoutSuffix', 'houzz']],
|
|
29
30
|
[['domainWithoutSuffix', 'huffingtonpost']],
|
|
30
31
|
[['domainWithoutSuffix', 'imdb']],
|
|
31
32
|
[['domainWithoutSuffix', 'imgur']],
|
package/src/auto-domains.json
CHANGED
package/src/index.js
CHANGED
|
@@ -244,21 +244,29 @@ const defaultGetTemporalFile = (input, ext) => {
|
|
|
244
244
|
return { path: filepath }
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
//
|
|
248
|
-
// and
|
|
247
|
+
// Resolve a binary path once and cache it: html-get owns the pandoc/mutool
|
|
248
|
+
// lookup, so both the internal runners and the exposed accessors share a single
|
|
249
|
+
// `which` per binary for the whole process. execFileSync (no shell) is faster
|
|
250
|
+
// than execSync and free of any interpolation surface.
|
|
251
|
+
const whichCache = new Map()
|
|
249
252
|
const whichSync = bin => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
if (!whichCache.has(bin)) {
|
|
254
|
+
let resolved
|
|
255
|
+
try {
|
|
256
|
+
resolved = execFileSync('which', [bin], {
|
|
257
|
+
stdio: ['pipe', 'pipe', 'ignore']
|
|
258
|
+
})
|
|
259
|
+
.toString()
|
|
260
|
+
.trim()
|
|
261
|
+
} catch (_) {}
|
|
262
|
+
whichCache.set(bin, resolved)
|
|
263
|
+
}
|
|
264
|
+
return whichCache.get(bin)
|
|
257
265
|
}
|
|
258
266
|
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
//
|
|
267
|
+
// The default runners are wired as default parameters (evaluated on every
|
|
268
|
+
// call), so memoizeOne builds each runner once instead of re-running the pandoc
|
|
269
|
+
// `--list-input-formats` probe and rebuilding the closure per request.
|
|
262
270
|
const defaultMutool = memoizeOne(() => {
|
|
263
271
|
const mutoolPath = whichSync('mutool')
|
|
264
272
|
if (!mutoolPath) return
|
|
@@ -420,3 +428,10 @@ module.exports.isFetchMode = isFetchMode
|
|
|
420
428
|
module.exports.getContent = getContent
|
|
421
429
|
module.exports.defaultMutool = defaultMutool
|
|
422
430
|
module.exports.defaultPandoc = defaultPandoc
|
|
431
|
+
|
|
432
|
+
// html-get already resolves pandoc/mutool for office and PDF conversion; expose
|
|
433
|
+
// the cached paths so a consumer (e.g. the microlink api markdown pipeline)
|
|
434
|
+
// reuses them instead of running its own `which`. Each returns undefined when
|
|
435
|
+
// the binary is not installed. Lazy: nothing runs until first call.
|
|
436
|
+
module.exports.getPandocPath = () => whichSync('pandoc')
|
|
437
|
+
module.exports.getMutoolPath = () => whichSync('mutool')
|