@dinoxx/dinox-cli 2.20.2 → 3.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 +17 -16
- package/dist/chunks/{applePodcast-V4FSJOC5.js → applePodcast-YDYM4JYQ.js} +3 -3
- package/dist/chunks/{bbc-NTMRPYRF.js → bbc-N3BM2EGG.js} +3 -3
- package/dist/chunks/{bilibili-UA3MBSPH.js → bilibili-V4XVW33T.js} +63 -9
- package/dist/chunks/{bohaishibei-B7UVXH4Y.js → bohaishibei-IQO5CZTN.js} +3 -3
- package/dist/chunks/{chunk-BZQYECIH.js → chunk-52XLDO77.js} +1 -1
- package/dist/chunks/{chunk-XEPDFQYD.js → chunk-5SORBZTD.js} +27 -27
- package/dist/chunks/{chunk-XMMTGPZ6.js → chunk-AZ43P73A.js} +56 -2
- package/dist/chunks/{chunk-W4EWLODY.js → chunk-DKY574LO.js} +3 -3
- package/dist/chunks/{chunk-4GM3PRSK.js → chunk-G6Y3MOUL.js} +6167 -3846
- package/dist/chunks/{chunk-BKCNERPB.js → chunk-JNRA4TTH.js} +99 -18
- package/dist/chunks/{chunk-3VZNZWDG.js → chunk-LAWV5XGL.js} +5 -0
- package/dist/chunks/{chunk-FIQYJ6KZ.js → chunk-LLAXR5EG.js} +1 -1
- package/dist/chunks/{chunk-MLOITAK6.js → chunk-LXC3IW4L.js} +2 -2
- package/dist/chunks/{chunk-TILRKKRN.js → chunk-MKEL2KNU.js} +893 -468
- package/dist/chunks/{chunk-7MGDG5BW.js → chunk-MMO7CINX.js} +499 -651
- package/dist/chunks/{chunk-FGQRYB7F.js → chunk-MZMOE3RX.js} +13 -1
- package/dist/chunks/{chunk-D3CETVY5.js → chunk-OZXS77HJ.js} +7 -7
- package/dist/chunks/{chunk-MDWXLRRN.js → chunk-PCB2JD6H.js} +6 -6
- package/dist/chunks/{chunk-6AZT4ARG.js → chunk-R2CGNGOT.js} +3 -3
- package/dist/chunks/{chunk-GTDX2LIJ.js → chunk-RSSEVU2F.js} +58 -10
- package/dist/chunks/{chunk-6D3QLMRM.js → chunk-TOGYWN3D.js} +1 -1
- package/dist/chunks/{chunk-CHGKDZV6.js → chunk-WCY3EKJQ.js} +4 -4
- package/dist/chunks/{chunk-QFSMFANX.js → chunk-YFGDTC2F.js} +9 -2
- package/dist/chunks/{chunk-QFUD3I7W.js → chunk-YX4SIEVS.js} +3 -4
- package/dist/chunks/{cookies-6QQHSM26.js → cookies-UUQZXH4R.js} +4 -6
- package/dist/chunks/{doubanGroup-HR4K2KMY.js → doubanGroup-MADXDGDI.js} +4 -4
- package/dist/chunks/{doubao-MXUHPLUB.js → doubao-DKZERP6Y.js} +2 -2
- package/dist/chunks/{douyin-UU2FSQPS.js → douyin-PIWFZHK7.js} +91 -5
- package/dist/chunks/{ensure-E3DIRHSQ.js → ensure-2OPNFDRW.js} +7 -7
- package/dist/chunks/{execute-YP2N2AMS.js → execute-C5W5ZJDC.js} +5 -5
- package/dist/chunks/{facebook-SZFOVE7R.js → facebook-TI2CF5UY.js} +2 -2
- package/dist/chunks/{feishu-ISWRJ7HI.js → feishu-XSSEBWQD.js} +2 -2
- package/dist/chunks/{ima-D7CX5WR4.js → ima-SKE2C64C.js} +2 -2
- package/dist/chunks/{instagram-HNDPO37H.js → instagram-4W4HCWJN.js} +2 -2
- package/dist/chunks/{install-IIMVFNAT.js → install-VBMWNPO6.js} +1 -3
- package/dist/chunks/{jike-H7L4LJTN.js → jike-GS64MEEO.js} +4 -4
- package/dist/chunks/{mcp-AK373P5P.js → mcp-WK7KIU44.js} +14 -12
- package/dist/chunks/{mcpServer-7VL4KJH2.js → mcpServer-M4HJFSNU.js} +17 -15
- package/dist/chunks/{metaso-ZVZW5UBB.js → metaso-RRYEUXIL.js} +2 -2
- package/dist/chunks/{run-OYMMVKCB.js → run-WNHMZLSJ.js} +11 -11
- package/dist/chunks/{runCli-ZJ7WYHJ7.js → runCli-GKTCIDBF.js} +12 -12
- package/dist/chunks/{setup-EEU6GSWX.js → setup-UYCLFOZH.js} +6 -6
- package/dist/chunks/{threads-ADW6IANQ.js → threads-JKMT3E73.js} +3 -3
- package/dist/chunks/{twitter-NAGCB3NI.js → twitter-WNBOJELM.js} +2 -2
- package/dist/chunks/{web-QFKZCM4F.js → web-LJESVHHV.js} +4 -4
- package/dist/chunks/{wechat-OXNNLT4J.js → wechat-N7O77CB4.js} +40 -1
- package/dist/chunks/{weibo-PMVGDNQU.js → weibo-XPEV5CLQ.js} +4 -4
- package/dist/chunks/{workbuddy-NNAXIIIZ.js → workbuddy-ZXNDX7O7.js} +5 -5
- package/dist/chunks/{xiaoheihe-WFQJRBAD.js → xiaoheihe-WXFAORLQ.js} +3 -3
- package/dist/chunks/{xiaohongshu-5CXBELGW.js → xiaohongshu-3N3ZVSXJ.js} +2 -2
- package/dist/chunks/{xiaoyuzhou-6L6IB46Y.js → xiaoyuzhou-OGIWFABL.js} +3 -3
- package/dist/chunks/{youtube-52NGBTQC.js → youtube-YRSK7CWC.js} +3 -3
- package/dist/chunks/{zcool-HDSWK4KD.js → zcool-K5KJ2KDG.js} +2 -2
- package/dist/chunks/{zhihu-EX2VRJYY.js → zhihu-X6XSPD6B.js} +2 -2
- package/dist/dinox.js +7 -7
- package/dist/dsh-plugin/lib/client.js +1030 -578
- package/dist/dsh-plugin/lib/index.js +11 -7
- package/dist/dsh-plugin/package.json +1 -1
- package/dist/dsh-plugin/runtime.json +2 -2
- package/dist/editor-ui/mcp-app.html +449 -583
- package/package.json +25 -12
|
@@ -27,10 +27,10 @@ import {
|
|
|
27
27
|
} from "./chunk-QZQRG3JY.js";
|
|
28
28
|
import {
|
|
29
29
|
composeClipMarkdown
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-LLAXR5EG.js";
|
|
31
31
|
import {
|
|
32
32
|
normalizeClipMarkdownBody
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-AZ43P73A.js";
|
|
34
34
|
import {
|
|
35
35
|
replaceRemoteMarkdownImageUrls
|
|
36
36
|
} from "./chunk-6VMHHE5Y.js";
|
|
@@ -44,9 +44,9 @@ import {
|
|
|
44
44
|
__toESM
|
|
45
45
|
} from "./chunk-XQZUX7OT.js";
|
|
46
46
|
|
|
47
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
47
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils.js
|
|
48
48
|
var require_utils = __commonJS({
|
|
49
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
49
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils.js"(exports) {
|
|
50
50
|
"use strict";
|
|
51
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
52
|
exports.CJK_CHAR_RANGES = void 0;
|
|
@@ -130,9 +130,9 @@ var require_utils = __commonJS({
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
133
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/metadata.js
|
|
134
134
|
var require_metadata = __commonJS({
|
|
135
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
135
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/metadata.js"(exports) {
|
|
136
136
|
"use strict";
|
|
137
137
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
138
138
|
exports.MetadataExtractor = void 0;
|
|
@@ -185,11 +185,12 @@ var require_metadata = __commonJS({
|
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
// Returns true if the string is not a usable metadata value — either an
|
|
188
|
-
// unresolved template literal (e.g. "#author.fullName}", "
|
|
189
|
-
// placeholder containing no letters/digits (e.g. ". .",
|
|
190
|
-
// by some CMSes when a field is empty.
|
|
188
|
+
// unresolved template literal (e.g. "#author.fullName}", "#author.fullName",
|
|
189
|
+
// "{{title}}") or a placeholder containing no letters/digits (e.g. ". .",
|
|
190
|
+
// "-", "_") emitted by some CMSes when a field is empty. A leading hashtag
|
|
191
|
+
// alone is real text ("#TidyTuesday week 12").
|
|
191
192
|
static isPlaceholderValue(s) {
|
|
192
|
-
if (/[{}]/.test(s) || /^#[a-zA-
|
|
193
|
+
if (/[{}]/.test(s) || /^#[a-zA-Z_$][\w$]*(\.[\w$]+)+$/.test(s))
|
|
193
194
|
return true;
|
|
194
195
|
if (!/[\p{L}\p{N}]/u.test(s))
|
|
195
196
|
return true;
|
|
@@ -759,52 +760,9 @@ var require_metadata = __commonJS({
|
|
|
759
760
|
}
|
|
760
761
|
});
|
|
761
762
|
|
|
762
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
763
|
-
var require_base = __commonJS({
|
|
764
|
-
"../../node_modules/.pnpm/defuddle@0.19.6_patch_hash=e98f4d40cd4a29709220f9fb1dda972652eec23ebb2d6f21a7cfa75ff70377c6/node_modules/defuddle/dist/extractors/_base.js"(exports) {
|
|
765
|
-
"use strict";
|
|
766
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
767
|
-
exports.BaseExtractor = void 0;
|
|
768
|
-
var BaseExtractor = class {
|
|
769
|
-
constructor(document2, url, schemaOrgData, options) {
|
|
770
|
-
this.document = document2;
|
|
771
|
-
this.url = url;
|
|
772
|
-
this.schemaOrgData = schemaOrgData;
|
|
773
|
-
this.options = options || {};
|
|
774
|
-
}
|
|
775
|
-
get fetch() {
|
|
776
|
-
const fn = this.options.fetch || globalThis.fetch;
|
|
777
|
-
return fn.bind(globalThis);
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Generate a title from the post description text, falling back to
|
|
781
|
-
* "Post by {author}" if the description is empty.
|
|
782
|
-
*/
|
|
783
|
-
postTitle(author, site) {
|
|
784
|
-
return `Post by ${author} on ${site}`;
|
|
785
|
-
}
|
|
786
|
-
canExtractAsync() {
|
|
787
|
-
return false;
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* When true, parseAsync() will prefer extractAsync() over extract(),
|
|
791
|
-
* even if sync extraction produces content. Use this when the async
|
|
792
|
-
* path provides strictly better results (e.g. YouTube transcripts).
|
|
793
|
-
*/
|
|
794
|
-
prefersAsync() {
|
|
795
|
-
return false;
|
|
796
|
-
}
|
|
797
|
-
async extractAsync() {
|
|
798
|
-
return this.extract();
|
|
799
|
-
}
|
|
800
|
-
};
|
|
801
|
-
exports.BaseExtractor = BaseExtractor;
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
// ../../node_modules/.pnpm/defuddle@0.19.6_patch_hash=e98f4d40cd4a29709220f9fb1dda972652eec23ebb2d6f21a7cfa75ff70377c6/node_modules/defuddle/dist/utils/dom.js
|
|
763
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/dom.js
|
|
806
764
|
var require_dom = __commonJS({
|
|
807
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
765
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/dom.js"(exports) {
|
|
808
766
|
"use strict";
|
|
809
767
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
810
768
|
exports.transferContent = transferContent;
|
|
@@ -876,12 +834,14 @@ var require_dom = __commonJS({
|
|
|
876
834
|
"ANIMATECOLOR",
|
|
877
835
|
"DISCARD"
|
|
878
836
|
]);
|
|
879
|
-
var UNSAFE_ELEMENT_SELECTOR = 'script:not([type^="math/"]), style, noscript, template, frame, frameset, object, embed, applet, base, animate, set, animatemotion, animatetransform, animatecolor, discard, animateMotion, animateTransform, animateColor';
|
|
837
|
+
var UNSAFE_ELEMENT_SELECTOR = 'script:not([type^="math/"]), style, noscript, template, frame, frameset, object, embed, applet, base, animate, set, animatemotion, animatetransform, animatecolor, discard, animateMotion, animateTransform, animateColor, math title';
|
|
880
838
|
var URL_ATTRIBUTES = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "xlink:href"]);
|
|
881
839
|
function isUnsafeElement(el) {
|
|
882
840
|
const tag = el.tagName.toUpperCase();
|
|
883
841
|
if (tag === "SCRIPT")
|
|
884
842
|
return !(el.getAttribute("type") || "").toLowerCase().startsWith("math/");
|
|
843
|
+
if (tag === "TITLE")
|
|
844
|
+
return !!el.closest("math");
|
|
885
845
|
return UNSAFE_ELEMENT_TAGS.has(tag);
|
|
886
846
|
}
|
|
887
847
|
function neutralizeUnsafeElement(el) {
|
|
@@ -983,9 +943,129 @@ var require_dom = __commonJS({
|
|
|
983
943
|
}
|
|
984
944
|
});
|
|
985
945
|
|
|
986
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
946
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/_base.js
|
|
947
|
+
var require_base = __commonJS({
|
|
948
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/_base.js"(exports) {
|
|
949
|
+
"use strict";
|
|
950
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
951
|
+
exports.BaseExtractor = void 0;
|
|
952
|
+
var dom_1 = require_dom();
|
|
953
|
+
var BaseExtractor = class {
|
|
954
|
+
constructor(document2, url, schemaOrgData, options) {
|
|
955
|
+
this.document = document2;
|
|
956
|
+
this.url = url;
|
|
957
|
+
this.schemaOrgData = schemaOrgData;
|
|
958
|
+
this.options = options || {};
|
|
959
|
+
}
|
|
960
|
+
get fetch() {
|
|
961
|
+
const fn = this.options.fetch || globalThis.fetch;
|
|
962
|
+
return fn.bind(globalThis);
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Change Defuddle's copy of the page before the standard pipeline reads a
|
|
966
|
+
* returned contentSelector. Do DOM changes here, never on this.document,
|
|
967
|
+
* which can be the live page the user sees.
|
|
968
|
+
*/
|
|
969
|
+
prepareDocument(doc) {
|
|
970
|
+
}
|
|
971
|
+
/** Append rendered HTML to the copy, inside a wrapper a contentSelector can find. */
|
|
972
|
+
appendWrapper(doc, attr, html) {
|
|
973
|
+
if (!html || !doc.body)
|
|
974
|
+
return;
|
|
975
|
+
const wrapper = doc.createElement("div");
|
|
976
|
+
wrapper.setAttribute(attr, "");
|
|
977
|
+
wrapper.appendChild((0, dom_1.parseHTML)(doc, html));
|
|
978
|
+
doc.body.appendChild(wrapper);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Generate a title from the post description text, falling back to
|
|
982
|
+
* "Post by {author}" if the description is empty.
|
|
983
|
+
*/
|
|
984
|
+
postTitle(author, site) {
|
|
985
|
+
return `Post by ${author} on ${site}`;
|
|
986
|
+
}
|
|
987
|
+
canExtractAsync() {
|
|
988
|
+
return false;
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* When true, parseAsync() will prefer extractAsync() over extract(),
|
|
992
|
+
* even if sync extraction produces content. Use this when the async
|
|
993
|
+
* path provides strictly better results (e.g. YouTube transcripts).
|
|
994
|
+
*/
|
|
995
|
+
prefersAsync() {
|
|
996
|
+
return false;
|
|
997
|
+
}
|
|
998
|
+
async extractAsync() {
|
|
999
|
+
return this.extract();
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
exports.BaseExtractor = BaseExtractor;
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
|
|
1006
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/transcript.js
|
|
1007
|
+
var require_transcript = __commonJS({
|
|
1008
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/transcript.js"(exports) {
|
|
1009
|
+
"use strict";
|
|
1010
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1011
|
+
exports.TRANSCRIPT_SITES = void 0;
|
|
1012
|
+
exports.isTranscriptClass = isTranscriptClass;
|
|
1013
|
+
exports.formatTimestamp = formatTimestamp;
|
|
1014
|
+
exports.buildTranscript = buildTranscript;
|
|
1015
|
+
var dom_1 = require_dom();
|
|
1016
|
+
exports.TRANSCRIPT_SITES = ["bilibili", "youtube"];
|
|
1017
|
+
var TRANSCRIPT_SITE_SET = new Set(exports.TRANSCRIPT_SITES);
|
|
1018
|
+
var TRANSCRIPT_CLASS_TOKEN = /^(?:transcript|transcript-segment|timestamp|speaker-\d+)$/;
|
|
1019
|
+
function isTranscriptClass(token) {
|
|
1020
|
+
return TRANSCRIPT_SITE_SET.has(token) || TRANSCRIPT_CLASS_TOKEN.test(token);
|
|
1021
|
+
}
|
|
1022
|
+
function formatTimestamp(seconds) {
|
|
1023
|
+
const h = Math.floor(seconds / 3600);
|
|
1024
|
+
const m = Math.floor(seconds % 3600 / 60);
|
|
1025
|
+
const s = Math.floor(seconds % 60);
|
|
1026
|
+
if (h > 0) {
|
|
1027
|
+
return `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
|
|
1028
|
+
}
|
|
1029
|
+
return `${m}:${String(s).padStart(2, "0")}`;
|
|
1030
|
+
}
|
|
1031
|
+
function buildTranscript(site, segments, chapters = []) {
|
|
1032
|
+
const sortedChapters = [...chapters].sort((a, b) => a.start - b.start);
|
|
1033
|
+
let chapterIdx = 0;
|
|
1034
|
+
const htmlParts = [];
|
|
1035
|
+
const textParts = [];
|
|
1036
|
+
for (const segment of segments) {
|
|
1037
|
+
while (chapterIdx < sortedChapters.length && sortedChapters[chapterIdx].start <= segment.start) {
|
|
1038
|
+
const title = sortedChapters[chapterIdx].title;
|
|
1039
|
+
htmlParts.push(`<h3>${(0, dom_1.escapeHtml)(title)}</h3>`);
|
|
1040
|
+
if (textParts.length > 0)
|
|
1041
|
+
textParts.push("");
|
|
1042
|
+
textParts.push(`### ${title}`);
|
|
1043
|
+
textParts.push("");
|
|
1044
|
+
chapterIdx++;
|
|
1045
|
+
}
|
|
1046
|
+
const timestamp = formatTimestamp(segment.start);
|
|
1047
|
+
const speakerClass = segment.speaker !== void 0 ? ` speaker-${segment.speaker}` : "";
|
|
1048
|
+
const tsHtml = `<strong><span class="timestamp" data-timestamp="${segment.start}">${timestamp}</span></strong>`;
|
|
1049
|
+
htmlParts.push(`<p class="transcript-segment${speakerClass}">${tsHtml} \xB7 ${(0, dom_1.escapeHtml)(segment.text)}</p>`);
|
|
1050
|
+
if (segment.speakerChange && textParts.length > 0) {
|
|
1051
|
+
textParts.push("");
|
|
1052
|
+
}
|
|
1053
|
+
textParts.push(`**${timestamp}** \xB7 ${segment.text}`);
|
|
1054
|
+
}
|
|
1055
|
+
return {
|
|
1056
|
+
html: `<div class="${site} transcript">
|
|
1057
|
+
<h2>Transcript</h2>
|
|
1058
|
+
${htmlParts.join("\n")}
|
|
1059
|
+
</div>`,
|
|
1060
|
+
text: textParts.join("\n")
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/comments.js
|
|
987
1067
|
var require_comments = __commonJS({
|
|
988
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
1068
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/comments.js"(exports) {
|
|
989
1069
|
"use strict";
|
|
990
1070
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
991
1071
|
exports.SITE_TOKENS = void 0;
|
|
@@ -995,6 +1075,7 @@ var require_comments = __commonJS({
|
|
|
995
1075
|
exports.buildComment = buildComment;
|
|
996
1076
|
exports.buildQuotedPost = buildQuotedPost;
|
|
997
1077
|
var dom_1 = require_dom();
|
|
1078
|
+
var transcript_1 = require_transcript();
|
|
998
1079
|
exports.SITE_TOKENS = [
|
|
999
1080
|
"bluesky",
|
|
1000
1081
|
"discourse",
|
|
@@ -1011,7 +1092,7 @@ var require_comments = __commonJS({
|
|
|
1011
1092
|
var SITE_TOKEN_SET = new Set(exports.SITE_TOKENS);
|
|
1012
1093
|
var EXTRACTOR_CLASS_TOKEN = /^(?:comments?|posts?|quoted-post|x-article)(?:-[\w-]+)?$/;
|
|
1013
1094
|
function isExtractorClass(token) {
|
|
1014
|
-
return SITE_TOKEN_SET.has(token) || EXTRACTOR_CLASS_TOKEN.test(token);
|
|
1095
|
+
return SITE_TOKEN_SET.has(token) || EXTRACTOR_CLASS_TOKEN.test(token) || (0, transcript_1.isTranscriptClass)(token);
|
|
1015
1096
|
}
|
|
1016
1097
|
function buildContentHtml(site, postContent, comments) {
|
|
1017
1098
|
return `
|
|
@@ -1098,9 +1179,9 @@ var require_comments = __commonJS({
|
|
|
1098
1179
|
}
|
|
1099
1180
|
});
|
|
1100
1181
|
|
|
1101
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
1182
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/reddit.js
|
|
1102
1183
|
var require_reddit = __commonJS({
|
|
1103
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
1184
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/reddit.js"(exports) {
|
|
1104
1185
|
"use strict";
|
|
1105
1186
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1106
1187
|
exports.RedditExtractor = void 0;
|
|
@@ -1421,9 +1502,9 @@ var require_reddit = __commonJS({
|
|
|
1421
1502
|
}
|
|
1422
1503
|
});
|
|
1423
1504
|
|
|
1424
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
1505
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/twitter.js
|
|
1425
1506
|
var require_twitter = __commonJS({
|
|
1426
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
1507
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/twitter.js"(exports) {
|
|
1427
1508
|
"use strict";
|
|
1428
1509
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1429
1510
|
exports.TwitterExtractor = void 0;
|
|
@@ -1437,11 +1518,44 @@ var require_twitter = __commonJS({
|
|
|
1437
1518
|
this.threadTweets = [];
|
|
1438
1519
|
this.replyTweets = [];
|
|
1439
1520
|
this.replyDepths = [];
|
|
1440
|
-
|
|
1521
|
+
const legacy = !!document2.querySelector('article[data-testid="tweet"]');
|
|
1522
|
+
this.classifyEntries(legacy ? this.legacyEntries() : this.conversationEntries());
|
|
1441
1523
|
if (!this.mainTweet) {
|
|
1442
|
-
this.mainTweet = document2.querySelector('article[data-testid="tweet"]');
|
|
1524
|
+
this.mainTweet = legacy ? document2.querySelector('article[data-testid="tweet"]') : this.topLevelPosts()[0] || null;
|
|
1443
1525
|
}
|
|
1444
1526
|
}
|
|
1527
|
+
/** Tweets in timeline order, with null where a cell holds no tweet. */
|
|
1528
|
+
legacyEntries() {
|
|
1529
|
+
return this.conversationCells().map((cell) => cell.querySelector('article[data-testid="tweet"]'));
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Posts that aren't quoted inside another post, in the X redesign from
|
|
1533
|
+
* November 2026, which has no data-testid attributes.
|
|
1534
|
+
*/
|
|
1535
|
+
topLevelPosts() {
|
|
1536
|
+
return Array.from(this.document.querySelectorAll("article")).filter((article) => !article.parentElement?.closest("article") && this.statusLink(article));
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Posts in the redesigned X, with null between list items.
|
|
1540
|
+
*
|
|
1541
|
+
* The conversation is one list with an item per entry, and a reply chain
|
|
1542
|
+
* shares an item. Server-rendered pages hold the list in a hidden element
|
|
1543
|
+
* until it hydrates, so the list is found through its posts.
|
|
1544
|
+
*/
|
|
1545
|
+
conversationEntries() {
|
|
1546
|
+
const posts = this.topLevelPosts();
|
|
1547
|
+
const list = posts.map((post) => post.closest("li")?.parentElement).find(Boolean);
|
|
1548
|
+
if (!list)
|
|
1549
|
+
return posts.slice(0, 1);
|
|
1550
|
+
const entries = [];
|
|
1551
|
+
for (const item of Array.from(list.children)) {
|
|
1552
|
+
const itemPosts = posts.filter((post) => item.contains(post));
|
|
1553
|
+
if (!itemPosts.length && entries.length && item.querySelector("h2"))
|
|
1554
|
+
break;
|
|
1555
|
+
entries.push(...itemPosts, null);
|
|
1556
|
+
}
|
|
1557
|
+
return entries;
|
|
1558
|
+
}
|
|
1445
1559
|
/**
|
|
1446
1560
|
* Conversation cells, in document order, stopping at X's "Discover more" and
|
|
1447
1561
|
* similar trailing sections.
|
|
@@ -1468,19 +1582,18 @@ var require_twitter = __commonJS({
|
|
|
1468
1582
|
return cells;
|
|
1469
1583
|
}
|
|
1470
1584
|
/**
|
|
1471
|
-
* Walk
|
|
1585
|
+
* Walk entries to classify tweets:
|
|
1472
1586
|
* 1. Main tweet (first article)
|
|
1473
1587
|
* 2. Thread tweets: consecutive self-replies by the main author at the top of
|
|
1474
1588
|
* the timeline, before any reply by a different person
|
|
1475
1589
|
* 3. Reply tweets: everything after the thread ends
|
|
1476
1590
|
*/
|
|
1477
|
-
|
|
1591
|
+
classifyEntries(entries) {
|
|
1478
1592
|
let mainHandle = "";
|
|
1479
1593
|
let threadEnded = false;
|
|
1480
1594
|
let lastWasTweet = false;
|
|
1481
1595
|
let currentDepth = 0;
|
|
1482
|
-
for (const
|
|
1483
|
-
const article = cell.querySelector('article[data-testid="tweet"]');
|
|
1596
|
+
for (const article of entries) {
|
|
1484
1597
|
if (!article) {
|
|
1485
1598
|
lastWasTweet = false;
|
|
1486
1599
|
continue;
|
|
@@ -1550,6 +1663,33 @@ var require_twitter = __commonJS({
|
|
|
1550
1663
|
});
|
|
1551
1664
|
return (0, comments_1.buildCommentTree)(commentData);
|
|
1552
1665
|
}
|
|
1666
|
+
/** Matches of `selector` in `root` that aren't inside a quoted post. */
|
|
1667
|
+
own(root, selector) {
|
|
1668
|
+
return Array.from(root.querySelectorAll(selector)).filter((el) => {
|
|
1669
|
+
const scope = el.parentElement?.closest(`article, ${_TwitterExtractor.EMBEDDED_POST}`);
|
|
1670
|
+
return !scope || scope === root || !root.contains(scope);
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
/** The post's own permalink, which also gives its author and ID. */
|
|
1674
|
+
statusLink(tweet) {
|
|
1675
|
+
for (const link of this.own(tweet, "a[href]")) {
|
|
1676
|
+
const href = link.getAttribute("href") || "";
|
|
1677
|
+
const match = href.match(_TwitterExtractor.STATUS_PATH);
|
|
1678
|
+
if (match)
|
|
1679
|
+
return { href, handle: match[1], id: match[2] };
|
|
1680
|
+
}
|
|
1681
|
+
return null;
|
|
1682
|
+
}
|
|
1683
|
+
tweetTextElement(tweet) {
|
|
1684
|
+
return tweet.querySelector('[data-testid="tweetText"]') || this.own(tweet, 'div[dir="auto"][lang]')[0] || null;
|
|
1685
|
+
}
|
|
1686
|
+
/** Post IDs since November 2010 encode the time they were created. */
|
|
1687
|
+
snowflakeDate(id) {
|
|
1688
|
+
if (id.length < 15)
|
|
1689
|
+
return "";
|
|
1690
|
+
const time = Math.floor(Number(id) / 4194304) + 1288834974657;
|
|
1691
|
+
return new Date(time).toISOString().split("T")[0];
|
|
1692
|
+
}
|
|
1553
1693
|
/**
|
|
1554
1694
|
* The @handle for a tweet.
|
|
1555
1695
|
*
|
|
@@ -1560,8 +1700,10 @@ var require_twitter = __commonJS({
|
|
|
1560
1700
|
*/
|
|
1561
1701
|
getHandle(tweet) {
|
|
1562
1702
|
const nameElement = tweet.querySelector('[data-testid="User-Name"]');
|
|
1563
|
-
if (!nameElement)
|
|
1564
|
-
|
|
1703
|
+
if (!nameElement) {
|
|
1704
|
+
const status = this.statusLink(tweet);
|
|
1705
|
+
return status ? `@${status.handle}` : "";
|
|
1706
|
+
}
|
|
1565
1707
|
const links = Array.from(nameElement.querySelectorAll("a"));
|
|
1566
1708
|
for (const link of links) {
|
|
1567
1709
|
const text = link.textContent?.trim() || "";
|
|
@@ -1603,6 +1745,9 @@ var require_twitter = __commonJS({
|
|
|
1603
1745
|
});
|
|
1604
1746
|
}
|
|
1605
1747
|
findQuotedTweet(tweet) {
|
|
1748
|
+
const embedded = this.own(tweet, _TwitterExtractor.EMBEDDED_POST)[0];
|
|
1749
|
+
if (embedded)
|
|
1750
|
+
return embedded;
|
|
1606
1751
|
return tweet.querySelector('[aria-labelledby*="id__"]')?.querySelector('[data-testid="User-Name"]')?.closest('[aria-labelledby*="id__"]') || null;
|
|
1607
1752
|
}
|
|
1608
1753
|
extractTweetContent(tweet) {
|
|
@@ -1610,7 +1755,7 @@ var require_twitter = __commonJS({
|
|
|
1610
1755
|
return "";
|
|
1611
1756
|
const tweetClone = tweet.cloneNode(true);
|
|
1612
1757
|
this.replaceEmojiImages(tweetClone);
|
|
1613
|
-
const tweetTextEl =
|
|
1758
|
+
const tweetTextEl = this.tweetTextElement(tweetClone);
|
|
1614
1759
|
const tweetText = tweetTextEl ? (0, dom_1.serializeHTML)(tweetTextEl) : "";
|
|
1615
1760
|
const formattedText = this.formatTweetText(tweetText);
|
|
1616
1761
|
const quotedTweet = this.findQuotedTweet(tweet);
|
|
@@ -1632,9 +1777,10 @@ ${quotedHtml}`;
|
|
|
1632
1777
|
return html;
|
|
1633
1778
|
}
|
|
1634
1779
|
extractQuotedTweet(quotedTweet) {
|
|
1780
|
+
quotedTweet = quotedTweet.matches(_TwitterExtractor.EMBEDDED_POST) ? quotedTweet.querySelector("article") || quotedTweet : quotedTweet;
|
|
1635
1781
|
const tweetClone = quotedTweet.cloneNode(true);
|
|
1636
1782
|
this.replaceEmojiImages(tweetClone);
|
|
1637
|
-
const tweetTextEl =
|
|
1783
|
+
const tweetTextEl = this.tweetTextElement(tweetClone);
|
|
1638
1784
|
const tweetText = tweetTextEl ? (0, dom_1.serializeHTML)(tweetTextEl) : "";
|
|
1639
1785
|
const formattedText = this.formatTweetText(tweetText);
|
|
1640
1786
|
const userInfo = this.extractUserInfo(quotedTweet);
|
|
@@ -1655,7 +1801,7 @@ ${images.join("\n")}`;
|
|
|
1655
1801
|
extractUserInfo(tweet) {
|
|
1656
1802
|
const nameElement = tweet.querySelector('[data-testid="User-Name"]');
|
|
1657
1803
|
if (!nameElement)
|
|
1658
|
-
return
|
|
1804
|
+
return this.extractRedesignUserInfo(tweet);
|
|
1659
1805
|
const handle = this.getHandle(tweet);
|
|
1660
1806
|
let fullName = Array.from(nameElement.querySelectorAll("a")).map((link) => link.querySelector("time") ? "" : link.textContent?.trim() || "").find((text) => text && text !== handle && !text.startsWith("@")) || "";
|
|
1661
1807
|
if (!fullName) {
|
|
@@ -1669,6 +1815,20 @@ ${images.join("\n")}`;
|
|
|
1669
1815
|
const permalink = timestamp?.closest("a")?.href || "";
|
|
1670
1816
|
return { fullName, handle, date, permalink };
|
|
1671
1817
|
}
|
|
1818
|
+
/** The display name is the profile link that isn't the avatar or the @handle. */
|
|
1819
|
+
extractRedesignUserInfo(tweet) {
|
|
1820
|
+
const status = this.statusLink(tweet);
|
|
1821
|
+
if (!status)
|
|
1822
|
+
return { fullName: "", handle: "", date: "", permalink: "" };
|
|
1823
|
+
const profilePath = `/${status.handle}`.toLowerCase();
|
|
1824
|
+
const fullName = this.own(tweet, "a[href]").filter((link) => (link.getAttribute("href") || "").toLowerCase() === profilePath).map((link) => link.textContent?.trim() || "").find((text) => text && !text.startsWith("@")) || "";
|
|
1825
|
+
return {
|
|
1826
|
+
fullName,
|
|
1827
|
+
handle: `@${status.handle}`,
|
|
1828
|
+
date: this.snowflakeDate(status.id),
|
|
1829
|
+
permalink: new URL(status.href, this.url).href
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1672
1832
|
extractImages(tweet, quotedTweet) {
|
|
1673
1833
|
const imageContainers = [
|
|
1674
1834
|
'[data-testid="tweetPhoto"]',
|
|
@@ -1714,7 +1874,7 @@ ${images.join("\n")}`;
|
|
|
1714
1874
|
createDescription(tweet) {
|
|
1715
1875
|
if (!tweet)
|
|
1716
1876
|
return "";
|
|
1717
|
-
const tweetText =
|
|
1877
|
+
const tweetText = this.tweetTextElement(tweet)?.textContent || "";
|
|
1718
1878
|
return tweetText.trim().slice(0, 140).replace(/\s+/g, " ");
|
|
1719
1879
|
}
|
|
1720
1880
|
};
|
|
@@ -1731,12 +1891,14 @@ ${images.join("\n")}`;
|
|
|
1731
1891
|
"hashtag",
|
|
1732
1892
|
"intent"
|
|
1733
1893
|
]);
|
|
1894
|
+
TwitterExtractor.STATUS_PATH = /^(?:https?:\/\/(?:www\.)?(?:x|twitter)\.com)?\/(\w{1,15})\/status\/(\d+)\/?(?:[?#]|$)/;
|
|
1895
|
+
TwitterExtractor.EMBEDDED_POST = '[data-slot="embedded-tweet-frame"]';
|
|
1734
1896
|
}
|
|
1735
1897
|
});
|
|
1736
1898
|
|
|
1737
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
1899
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/x-article.js
|
|
1738
1900
|
var require_x_article = __commonJS({
|
|
1739
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
1901
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/x-article.js"(exports) {
|
|
1740
1902
|
"use strict";
|
|
1741
1903
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1742
1904
|
exports.XArticleExtractor = void 0;
|
|
@@ -2013,61 +2175,9 @@ var require_x_article = __commonJS({
|
|
|
2013
2175
|
}
|
|
2014
2176
|
});
|
|
2015
2177
|
|
|
2016
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
2017
|
-
var require_transcript = __commonJS({
|
|
2018
|
-
"../../node_modules/.pnpm/defuddle@0.19.6_patch_hash=e98f4d40cd4a29709220f9fb1dda972652eec23ebb2d6f21a7cfa75ff70377c6/node_modules/defuddle/dist/utils/transcript.js"(exports) {
|
|
2019
|
-
"use strict";
|
|
2020
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2021
|
-
exports.formatTimestamp = formatTimestamp;
|
|
2022
|
-
exports.buildTranscript = buildTranscript;
|
|
2023
|
-
var dom_1 = require_dom();
|
|
2024
|
-
function formatTimestamp(seconds) {
|
|
2025
|
-
const h = Math.floor(seconds / 3600);
|
|
2026
|
-
const m = Math.floor(seconds % 3600 / 60);
|
|
2027
|
-
const s = Math.floor(seconds % 60);
|
|
2028
|
-
if (h > 0) {
|
|
2029
|
-
return `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
|
|
2030
|
-
}
|
|
2031
|
-
return `${m}:${String(s).padStart(2, "0")}`;
|
|
2032
|
-
}
|
|
2033
|
-
function buildTranscript(site, segments, chapters = []) {
|
|
2034
|
-
const sortedChapters = [...chapters].sort((a, b) => a.start - b.start);
|
|
2035
|
-
let chapterIdx = 0;
|
|
2036
|
-
const htmlParts = [];
|
|
2037
|
-
const textParts = [];
|
|
2038
|
-
for (const segment of segments) {
|
|
2039
|
-
while (chapterIdx < sortedChapters.length && sortedChapters[chapterIdx].start <= segment.start) {
|
|
2040
|
-
const title = sortedChapters[chapterIdx].title;
|
|
2041
|
-
htmlParts.push(`<h3>${(0, dom_1.escapeHtml)(title)}</h3>`);
|
|
2042
|
-
if (textParts.length > 0)
|
|
2043
|
-
textParts.push("");
|
|
2044
|
-
textParts.push(`### ${title}`);
|
|
2045
|
-
textParts.push("");
|
|
2046
|
-
chapterIdx++;
|
|
2047
|
-
}
|
|
2048
|
-
const timestamp = formatTimestamp(segment.start);
|
|
2049
|
-
const speakerClass = segment.speaker !== void 0 ? ` speaker-${segment.speaker}` : "";
|
|
2050
|
-
const tsHtml = `<strong><span class="timestamp" data-timestamp="${segment.start}">${timestamp}</span></strong>`;
|
|
2051
|
-
htmlParts.push(`<p class="transcript-segment${speakerClass}">${tsHtml} \xB7 ${(0, dom_1.escapeHtml)(segment.text)}</p>`);
|
|
2052
|
-
if (segment.speakerChange && textParts.length > 0) {
|
|
2053
|
-
textParts.push("");
|
|
2054
|
-
}
|
|
2055
|
-
textParts.push(`**${timestamp}** \xB7 ${segment.text}`);
|
|
2056
|
-
}
|
|
2057
|
-
return {
|
|
2058
|
-
html: `<div class="${site} transcript">
|
|
2059
|
-
<h2>Transcript</h2>
|
|
2060
|
-
${htmlParts.join("\n")}
|
|
2061
|
-
</div>`,
|
|
2062
|
-
text: textParts.join("\n")
|
|
2063
|
-
};
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
});
|
|
2067
|
-
|
|
2068
|
-
// ../../node_modules/.pnpm/defuddle@0.19.6_patch_hash=e98f4d40cd4a29709220f9fb1dda972652eec23ebb2d6f21a7cfa75ff70377c6/node_modules/defuddle/dist/extractors/youtube.js
|
|
2178
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/youtube.js
|
|
2069
2179
|
var require_youtube = __commonJS({
|
|
2070
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
2180
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/youtube.js"(exports) {
|
|
2071
2181
|
"use strict";
|
|
2072
2182
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2073
2183
|
exports.YoutubeExtractor = void 0;
|
|
@@ -2517,9 +2627,19 @@ var require_youtube = __commonJS({
|
|
|
2517
2627
|
if (startIndex === -1)
|
|
2518
2628
|
continue;
|
|
2519
2629
|
let depth = 0;
|
|
2630
|
+
let scan = "code";
|
|
2520
2631
|
for (let i = startIndex; i < text.length; i++) {
|
|
2521
2632
|
const char = text[i];
|
|
2522
|
-
if (
|
|
2633
|
+
if (scan === "escape") {
|
|
2634
|
+
scan = "string";
|
|
2635
|
+
} else if (scan === "string") {
|
|
2636
|
+
if (char === "\\")
|
|
2637
|
+
scan = "escape";
|
|
2638
|
+
else if (char === '"')
|
|
2639
|
+
scan = "code";
|
|
2640
|
+
} else if (char === '"') {
|
|
2641
|
+
scan = "string";
|
|
2642
|
+
} else if (char === "{") {
|
|
2523
2643
|
depth += 1;
|
|
2524
2644
|
} else if (char === "}") {
|
|
2525
2645
|
depth -= 1;
|
|
@@ -3129,9 +3249,9 @@ var require_youtube = __commonJS({
|
|
|
3129
3249
|
}
|
|
3130
3250
|
});
|
|
3131
3251
|
|
|
3132
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
3252
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/bilibili.js
|
|
3133
3253
|
var require_bilibili = __commonJS({
|
|
3134
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
3254
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/bilibili.js"(exports) {
|
|
3135
3255
|
"use strict";
|
|
3136
3256
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3137
3257
|
exports.BilibiliExtractor = void 0;
|
|
@@ -3174,12 +3294,11 @@ var require_bilibili = __commonJS({
|
|
|
3174
3294
|
let transcript;
|
|
3175
3295
|
if (aid && cid) {
|
|
3176
3296
|
if (cacheKey && _BilibiliExtractor.transcriptCache.has(cacheKey)) {
|
|
3177
|
-
|
|
3178
|
-
transcript = cached ?? void 0;
|
|
3297
|
+
transcript = _BilibiliExtractor.transcriptCache.get(cacheKey);
|
|
3179
3298
|
} else {
|
|
3180
3299
|
transcript = await this.fetchTranscript(aid, cid, bvid);
|
|
3181
|
-
if (cacheKey) {
|
|
3182
|
-
_BilibiliExtractor.transcriptCache.set(cacheKey, transcript
|
|
3300
|
+
if (cacheKey && transcript) {
|
|
3301
|
+
_BilibiliExtractor.transcriptCache.set(cacheKey, transcript);
|
|
3183
3302
|
if (_BilibiliExtractor.transcriptCache.size > 300) {
|
|
3184
3303
|
const firstKey = _BilibiliExtractor.transcriptCache.keys().next().value;
|
|
3185
3304
|
if (firstKey)
|
|
@@ -3338,10 +3457,7 @@ var require_bilibili = __commonJS({
|
|
|
3338
3457
|
try {
|
|
3339
3458
|
const url = `https://api.bilibili.com/x/web-interface/view?bvid=${encodeURIComponent(bvid)}`;
|
|
3340
3459
|
const response = await this.fetch(url, {
|
|
3341
|
-
headers: {
|
|
3342
|
-
"Accept": "application/json",
|
|
3343
|
-
"User-Agent": "Mozilla/5.0 (compatible; Defuddle/1.0)"
|
|
3344
|
-
},
|
|
3460
|
+
headers: { "Accept": "application/json" },
|
|
3345
3461
|
credentials: "include",
|
|
3346
3462
|
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
3347
3463
|
});
|
|
@@ -3376,10 +3492,7 @@ var require_bilibili = __commonJS({
|
|
|
3376
3492
|
}
|
|
3377
3493
|
async fetchPlayerV2(url) {
|
|
3378
3494
|
const response = await this.fetch(url, {
|
|
3379
|
-
headers: {
|
|
3380
|
-
"Accept": "application/json",
|
|
3381
|
-
"User-Agent": "Mozilla/5.0 (compatible; Defuddle/1.0)"
|
|
3382
|
-
},
|
|
3495
|
+
headers: { "Accept": "application/json" },
|
|
3383
3496
|
credentials: "include",
|
|
3384
3497
|
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
3385
3498
|
});
|
|
@@ -3425,10 +3538,7 @@ var require_bilibili = __commonJS({
|
|
|
3425
3538
|
return void 0;
|
|
3426
3539
|
}
|
|
3427
3540
|
const subtitleResponse = await this.fetch(subtitleUrl.toString(), {
|
|
3428
|
-
headers: {
|
|
3429
|
-
"Accept": "application/json",
|
|
3430
|
-
"User-Agent": "Mozilla/5.0 (compatible; Defuddle/1.0)"
|
|
3431
|
-
},
|
|
3541
|
+
headers: { "Accept": "application/json" },
|
|
3432
3542
|
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
3433
3543
|
});
|
|
3434
3544
|
if (!subtitleResponse.ok) {
|
|
@@ -3533,9 +3643,9 @@ var require_bilibili = __commonJS({
|
|
|
3533
3643
|
}
|
|
3534
3644
|
});
|
|
3535
3645
|
|
|
3536
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
3646
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/hackernews.js
|
|
3537
3647
|
var require_hackernews = __commonJS({
|
|
3538
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
3648
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/hackernews.js"(exports) {
|
|
3539
3649
|
"use strict";
|
|
3540
3650
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3541
3651
|
exports.HackerNewsExtractor = void 0;
|
|
@@ -3627,7 +3737,7 @@ var require_hackernews = __commonJS({
|
|
|
3627
3737
|
const site = row.querySelector(".sitestr")?.textContent?.trim() || "";
|
|
3628
3738
|
const subRow = row.nextElementSibling;
|
|
3629
3739
|
const score = subRow?.querySelector(".score")?.textContent?.trim() || "";
|
|
3630
|
-
const author = subRow?.querySelector("
|
|
3740
|
+
const author = subRow?.querySelector('a[href^="user?id"]')?.textContent?.trim() || "";
|
|
3631
3741
|
const ageEl = subRow?.querySelector(".age");
|
|
3632
3742
|
const timestamp = ageEl?.getAttribute("title") || "";
|
|
3633
3743
|
const date = timestamp.split("T")[0] || "";
|
|
@@ -3676,7 +3786,7 @@ var require_hackernews = __commonJS({
|
|
|
3676
3786
|
if (!this.mainPost)
|
|
3677
3787
|
return "";
|
|
3678
3788
|
if (this.isCommentPage && this.mainComment) {
|
|
3679
|
-
const author = this.mainComment.querySelector("
|
|
3789
|
+
const author = this.mainComment.querySelector('a[href^="user?id"]')?.textContent || "[deleted]";
|
|
3680
3790
|
const commtext = this.mainComment.querySelector(".commtext");
|
|
3681
3791
|
const commentText = commtext ? (0, dom_1.serializeHTML)(commtext) : "";
|
|
3682
3792
|
const timeElement = this.mainComment.querySelector(".age");
|
|
@@ -3717,7 +3827,7 @@ var require_hackernews = __commonJS({
|
|
|
3717
3827
|
const indent = comment.querySelector(".ind img")?.getAttribute("width") || "0";
|
|
3718
3828
|
const depth = parseInt(indent) / 40;
|
|
3719
3829
|
const commentText = comment.querySelector(".commtext");
|
|
3720
|
-
const author = comment.querySelector("
|
|
3830
|
+
const author = comment.querySelector('a[href^="user?id"]')?.textContent || "[deleted]";
|
|
3721
3831
|
const timeElement = comment.querySelector(".age");
|
|
3722
3832
|
const points = comment.querySelector(".score")?.textContent?.trim() || "";
|
|
3723
3833
|
if (!commentText)
|
|
@@ -3742,7 +3852,7 @@ var require_hackernews = __commonJS({
|
|
|
3742
3852
|
}
|
|
3743
3853
|
getPostTitle() {
|
|
3744
3854
|
if (this.isCommentPage && this.mainComment) {
|
|
3745
|
-
const author = this.mainComment.querySelector("
|
|
3855
|
+
const author = this.mainComment.querySelector('a[href^="user?id"]')?.textContent || "[deleted]";
|
|
3746
3856
|
const commentText = this.mainComment.querySelector(".commtext")?.textContent || "";
|
|
3747
3857
|
const preview = commentText.trim().slice(0, 50) + (commentText.length > 50 ? "..." : "");
|
|
3748
3858
|
return `Comment by ${author}: ${preview}`;
|
|
@@ -3750,7 +3860,7 @@ var require_hackernews = __commonJS({
|
|
|
3750
3860
|
return this.mainPost?.querySelector(".titleline")?.textContent?.trim() || "";
|
|
3751
3861
|
}
|
|
3752
3862
|
getPostAuthor() {
|
|
3753
|
-
return this.mainPost?.querySelector("
|
|
3863
|
+
return this.mainPost?.querySelector('a[href^="user?id"]')?.textContent?.trim() || "";
|
|
3754
3864
|
}
|
|
3755
3865
|
createDescription() {
|
|
3756
3866
|
const title = this.getPostTitle();
|
|
@@ -3772,9 +3882,9 @@ var require_hackernews = __commonJS({
|
|
|
3772
3882
|
}
|
|
3773
3883
|
});
|
|
3774
3884
|
|
|
3775
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
3885
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/_conversation.js
|
|
3776
3886
|
var require_conversation = __commonJS({
|
|
3777
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
3887
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/_conversation.js"(exports) {
|
|
3778
3888
|
"use strict";
|
|
3779
3889
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3780
3890
|
exports.ConversationExtractor = void 0;
|
|
@@ -3858,9 +3968,9 @@ ${footnotesHtml}`.trim();
|
|
|
3858
3968
|
}
|
|
3859
3969
|
});
|
|
3860
3970
|
|
|
3861
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
3971
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/chatgpt.js
|
|
3862
3972
|
var require_chatgpt = __commonJS({
|
|
3863
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
3973
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/chatgpt.js"(exports) {
|
|
3864
3974
|
"use strict";
|
|
3865
3975
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3866
3976
|
exports.ChatGPTExtractor = void 0;
|
|
@@ -3993,9 +4103,9 @@ var require_chatgpt = __commonJS({
|
|
|
3993
4103
|
}
|
|
3994
4104
|
});
|
|
3995
4105
|
|
|
3996
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
4106
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/claude.js
|
|
3997
4107
|
var require_claude = __commonJS({
|
|
3998
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
4108
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/claude.js"(exports) {
|
|
3999
4109
|
"use strict";
|
|
4000
4110
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4001
4111
|
exports.ClaudeExtractor = void 0;
|
|
@@ -4075,9 +4185,9 @@ var require_claude = __commonJS({
|
|
|
4075
4185
|
}
|
|
4076
4186
|
});
|
|
4077
4187
|
|
|
4078
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
4188
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/grok.js
|
|
4079
4189
|
var require_grok = __commonJS({
|
|
4080
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
4190
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/grok.js"(exports) {
|
|
4081
4191
|
"use strict";
|
|
4082
4192
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4083
4193
|
exports.GrokExtractor = void 0;
|
|
@@ -4200,9 +4310,9 @@ var require_grok = __commonJS({
|
|
|
4200
4310
|
}
|
|
4201
4311
|
});
|
|
4202
4312
|
|
|
4203
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
4313
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/gemini.js
|
|
4204
4314
|
var require_gemini = __commonJS({
|
|
4205
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
4315
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/gemini.js"(exports) {
|
|
4206
4316
|
"use strict";
|
|
4207
4317
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4208
4318
|
exports.GeminiExtractor = void 0;
|
|
@@ -4315,9 +4425,9 @@ var require_gemini = __commonJS({
|
|
|
4315
4425
|
}
|
|
4316
4426
|
});
|
|
4317
4427
|
|
|
4318
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
4428
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/github.js
|
|
4319
4429
|
var require_github = __commonJS({
|
|
4320
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
4430
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/github.js"(exports) {
|
|
4321
4431
|
"use strict";
|
|
4322
4432
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4323
4433
|
exports.GitHubExtractor = void 0;
|
|
@@ -4546,15 +4656,16 @@ var require_github = __commonJS({
|
|
|
4546
4656
|
}
|
|
4547
4657
|
});
|
|
4548
4658
|
|
|
4549
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
4659
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/x-oembed.js
|
|
4550
4660
|
var require_x_oembed = __commonJS({
|
|
4551
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
4661
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/x-oembed.js"(exports) {
|
|
4552
4662
|
"use strict";
|
|
4553
4663
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4554
4664
|
exports.XOembedExtractor = void 0;
|
|
4555
4665
|
var _base_1 = require_base();
|
|
4556
4666
|
var dom_1 = require_dom();
|
|
4557
4667
|
var comments_1 = require_comments();
|
|
4668
|
+
var FETCH_TIMEOUT_MS = 4e3;
|
|
4558
4669
|
var XOembedExtractor = class extends _base_1.BaseExtractor {
|
|
4559
4670
|
canExtract() {
|
|
4560
4671
|
return false;
|
|
@@ -4584,7 +4695,7 @@ var require_x_oembed = __commonJS({
|
|
|
4584
4695
|
}
|
|
4585
4696
|
async extractOembed() {
|
|
4586
4697
|
const oembedUrl = `https://publish.twitter.com/oembed?url=${encodeURIComponent(this.url)}&omit_script=true`;
|
|
4587
|
-
const response = await this.fetch(oembedUrl);
|
|
4698
|
+
const response = await this.fetch(oembedUrl, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
4588
4699
|
if (!response.ok) {
|
|
4589
4700
|
throw new Error(`oEmbed request failed: ${response.status}`);
|
|
4590
4701
|
}
|
|
@@ -4631,7 +4742,8 @@ var require_x_oembed = __commonJS({
|
|
|
4631
4742
|
const response = await this.fetch(apiUrl, {
|
|
4632
4743
|
headers: {
|
|
4633
4744
|
"User-Agent": "Mozilla/5.0 (compatible; Defuddle/1.0; +https://defuddle.md)"
|
|
4634
|
-
}
|
|
4745
|
+
},
|
|
4746
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
4635
4747
|
});
|
|
4636
4748
|
if (!response.ok) {
|
|
4637
4749
|
throw new Error(`FxTwitter API request failed: ${response.status}`);
|
|
@@ -4941,9 +5053,9 @@ var require_x_oembed = __commonJS({
|
|
|
4941
5053
|
}
|
|
4942
5054
|
});
|
|
4943
5055
|
|
|
4944
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5056
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/bbcode.js
|
|
4945
5057
|
var require_bbcode = __commonJS({
|
|
4946
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5058
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/bbcode.js"(exports) {
|
|
4947
5059
|
"use strict";
|
|
4948
5060
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4949
5061
|
exports.bbcodeToHtml = bbcodeToHtml;
|
|
@@ -4986,9 +5098,9 @@ var require_bbcode = __commonJS({
|
|
|
4986
5098
|
}
|
|
4987
5099
|
});
|
|
4988
5100
|
|
|
4989
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5101
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/bbcode-data.js
|
|
4990
5102
|
var require_bbcode_data = __commonJS({
|
|
4991
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5103
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/bbcode-data.js"(exports) {
|
|
4992
5104
|
"use strict";
|
|
4993
5105
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4994
5106
|
exports.BbcodeDataExtractor = void 0;
|
|
@@ -5047,15 +5159,16 @@ var require_bbcode_data = __commonJS({
|
|
|
5047
5159
|
}
|
|
5048
5160
|
});
|
|
5049
5161
|
|
|
5050
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5162
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/c2-wiki.js
|
|
5051
5163
|
var require_c2_wiki = __commonJS({
|
|
5052
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5164
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/c2-wiki.js"(exports) {
|
|
5053
5165
|
"use strict";
|
|
5054
5166
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5055
5167
|
exports.C2WikiExtractor = void 0;
|
|
5056
5168
|
var _base_1 = require_base();
|
|
5057
5169
|
var dom_1 = require_dom();
|
|
5058
5170
|
var C2_API = "https://c2.com/wiki/remodel/pages/";
|
|
5171
|
+
var FETCH_TIMEOUT_MS = 4e3;
|
|
5059
5172
|
var C2WikiExtractor = class extends _base_1.BaseExtractor {
|
|
5060
5173
|
canExtract() {
|
|
5061
5174
|
return false;
|
|
@@ -5073,7 +5186,7 @@ var require_c2_wiki = __commonJS({
|
|
|
5073
5186
|
const title = this.getPageTitle();
|
|
5074
5187
|
if (!title)
|
|
5075
5188
|
return { content: "", contentHtml: "" };
|
|
5076
|
-
const json = await this.fetch(C2_API + title).then((res) => res.json());
|
|
5189
|
+
const json = await this.fetch(C2_API + title, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) }).then((res) => res.json());
|
|
5077
5190
|
if (!json || !json.text)
|
|
5078
5191
|
return { content: "", contentHtml: "" };
|
|
5079
5192
|
const words = title.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
@@ -5127,8 +5240,10 @@ var require_c2_wiki = __commonJS({
|
|
|
5127
5240
|
prefix += `</${newOpenTags.pop()}>`;
|
|
5128
5241
|
}
|
|
5129
5242
|
if (tag && newOpenTags.length < depth) {
|
|
5130
|
-
|
|
5131
|
-
|
|
5243
|
+
while (newOpenTags.length < depth) {
|
|
5244
|
+
prefix += `<${tag}>`;
|
|
5245
|
+
newOpenTags.push(tag);
|
|
5246
|
+
}
|
|
5132
5247
|
} else if (tag && newOpenTags.length === depth && newOpenTags[depth - 1] !== tag) {
|
|
5133
5248
|
prefix += `</${newOpenTags.pop()}><${tag}>`;
|
|
5134
5249
|
newOpenTags.push(tag);
|
|
@@ -5190,9 +5305,9 @@ var require_c2_wiki = __commonJS({
|
|
|
5190
5305
|
}
|
|
5191
5306
|
});
|
|
5192
5307
|
|
|
5193
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5308
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/substack.js
|
|
5194
5309
|
var require_substack = __commonJS({
|
|
5195
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5310
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/substack.js"(exports) {
|
|
5196
5311
|
"use strict";
|
|
5197
5312
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5198
5313
|
exports.SubstackExtractor = void 0;
|
|
@@ -5206,6 +5321,7 @@ var require_substack = __commonJS({
|
|
|
5206
5321
|
this.noteImage = null;
|
|
5207
5322
|
this.postData = null;
|
|
5208
5323
|
this.postContentSelector = null;
|
|
5324
|
+
this.injectedHtml = "";
|
|
5209
5325
|
if (document2.querySelector("div.body.markup")) {
|
|
5210
5326
|
this.postData = this.extractPreloadData();
|
|
5211
5327
|
this.postContentSelector = "div.body.markup";
|
|
@@ -5213,13 +5329,7 @@ var require_substack = __commonJS({
|
|
|
5213
5329
|
}
|
|
5214
5330
|
this.postData = this.extractPreloadData();
|
|
5215
5331
|
if (this.postData?.body_html) {
|
|
5216
|
-
|
|
5217
|
-
if (!existing) {
|
|
5218
|
-
const wrapper = document2.createElement("div");
|
|
5219
|
-
wrapper.setAttribute(INJECTED_ATTR, "");
|
|
5220
|
-
wrapper.appendChild((0, dom_1.parseHTML)(document2, this.postData.body_html));
|
|
5221
|
-
document2.body.appendChild(wrapper);
|
|
5222
|
-
}
|
|
5332
|
+
this.injectedHtml = this.postData.body_html;
|
|
5223
5333
|
this.postContentSelector = `[${INJECTED_ATTR}]`;
|
|
5224
5334
|
return;
|
|
5225
5335
|
}
|
|
@@ -5241,6 +5351,9 @@ var require_substack = __commonJS({
|
|
|
5241
5351
|
canExtract() {
|
|
5242
5352
|
return this.postContentSelector !== null || this.noteText !== null;
|
|
5243
5353
|
}
|
|
5354
|
+
prepareDocument(doc) {
|
|
5355
|
+
this.appendWrapper(doc, INJECTED_ATTR, this.injectedHtml);
|
|
5356
|
+
}
|
|
5244
5357
|
extract() {
|
|
5245
5358
|
if (this.postContentSelector) {
|
|
5246
5359
|
return this.extractPost();
|
|
@@ -5313,6 +5426,16 @@ ${imageHtml}` : textHtml;
|
|
|
5313
5426
|
return "";
|
|
5314
5427
|
}
|
|
5315
5428
|
extractPreloadData() {
|
|
5429
|
+
const preloadsJsonScript = this.document.querySelector("script#preloads-json");
|
|
5430
|
+
if (preloadsJsonScript?.textContent) {
|
|
5431
|
+
try {
|
|
5432
|
+
const data = JSON.parse(preloadsJsonScript.textContent);
|
|
5433
|
+
const post = data?.post ?? data?.feedData?.initialPost?.post;
|
|
5434
|
+
if (post?.body_html)
|
|
5435
|
+
return post;
|
|
5436
|
+
} catch {
|
|
5437
|
+
}
|
|
5438
|
+
}
|
|
5316
5439
|
const scripts = Array.from(this.document.querySelectorAll("script"));
|
|
5317
5440
|
for (const script of scripts) {
|
|
5318
5441
|
const text = script.textContent || "";
|
|
@@ -5385,31 +5508,25 @@ ${imageHtml}` : textHtml;
|
|
|
5385
5508
|
}
|
|
5386
5509
|
});
|
|
5387
5510
|
|
|
5388
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5511
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/nytimes.js
|
|
5389
5512
|
var require_nytimes = __commonJS({
|
|
5390
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5513
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/nytimes.js"(exports) {
|
|
5391
5514
|
"use strict";
|
|
5392
5515
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5393
5516
|
exports.NytimesExtractor = void 0;
|
|
5394
5517
|
var _base_1 = require_base();
|
|
5395
|
-
var dom_1 = require_dom();
|
|
5396
5518
|
var INJECTED_ATTR = "data-defuddle-nyt";
|
|
5397
5519
|
var NytimesExtractor = class extends _base_1.BaseExtractor {
|
|
5398
5520
|
constructor(document2, url, schemaOrgData, options) {
|
|
5399
5521
|
super(document2, url, schemaOrgData, options);
|
|
5400
5522
|
this.preloadedData = null;
|
|
5401
5523
|
this.contentSelector = null;
|
|
5524
|
+
this.renderedHtml = "";
|
|
5402
5525
|
this.preloadedData = this.extractPreloadData();
|
|
5403
5526
|
if (this.preloadedData) {
|
|
5404
5527
|
const body = this.preloadedData.sprinkledBody || this.preloadedData.body;
|
|
5405
5528
|
if (body?.content?.length) {
|
|
5406
|
-
|
|
5407
|
-
if (!existing) {
|
|
5408
|
-
const wrapper = document2.createElement("div");
|
|
5409
|
-
wrapper.setAttribute(INJECTED_ATTR, "");
|
|
5410
|
-
wrapper.appendChild((0, dom_1.parseHTML)(document2, this.renderBlocks(body.content)));
|
|
5411
|
-
document2.body.appendChild(wrapper);
|
|
5412
|
-
}
|
|
5529
|
+
this.renderedHtml = this.renderBlocks(body.content);
|
|
5413
5530
|
this.contentSelector = `[${INJECTED_ATTR}]`;
|
|
5414
5531
|
}
|
|
5415
5532
|
}
|
|
@@ -5417,6 +5534,9 @@ var require_nytimes = __commonJS({
|
|
|
5417
5534
|
canExtract() {
|
|
5418
5535
|
return this.contentSelector !== null;
|
|
5419
5536
|
}
|
|
5537
|
+
prepareDocument(doc) {
|
|
5538
|
+
this.appendWrapper(doc, INJECTED_ATTR, this.renderedHtml);
|
|
5539
|
+
}
|
|
5420
5540
|
extract() {
|
|
5421
5541
|
const article = this.preloadedData;
|
|
5422
5542
|
const title = article.headline?.default || "";
|
|
@@ -5558,9 +5678,9 @@ var require_nytimes = __commonJS({
|
|
|
5558
5678
|
}
|
|
5559
5679
|
});
|
|
5560
5680
|
|
|
5561
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5681
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/wikipedia.js
|
|
5562
5682
|
var require_wikipedia = __commonJS({
|
|
5563
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5683
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/wikipedia.js"(exports) {
|
|
5564
5684
|
"use strict";
|
|
5565
5685
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5566
5686
|
exports.WikipediaExtractor = void 0;
|
|
@@ -5588,9 +5708,9 @@ var require_wikipedia = __commonJS({
|
|
|
5588
5708
|
}
|
|
5589
5709
|
});
|
|
5590
5710
|
|
|
5591
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5711
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/linkedin.js
|
|
5592
5712
|
var require_linkedin = __commonJS({
|
|
5593
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5713
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/linkedin.js"(exports) {
|
|
5594
5714
|
"use strict";
|
|
5595
5715
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5596
5716
|
exports.LinkedInExtractor = void 0;
|
|
@@ -5793,9 +5913,9 @@ ${quotedPost}`;
|
|
|
5793
5913
|
}
|
|
5794
5914
|
});
|
|
5795
5915
|
|
|
5796
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
5916
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/threads.js
|
|
5797
5917
|
var require_threads = __commonJS({
|
|
5798
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
5918
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/threads.js"(exports) {
|
|
5799
5919
|
"use strict";
|
|
5800
5920
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5801
5921
|
exports.ThreadsExtractor = void 0;
|
|
@@ -6237,9 +6357,9 @@ var require_threads = __commonJS({
|
|
|
6237
6357
|
}
|
|
6238
6358
|
});
|
|
6239
6359
|
|
|
6240
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
6360
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/bluesky.js
|
|
6241
6361
|
var require_bluesky = __commonJS({
|
|
6242
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
6362
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/bluesky.js"(exports) {
|
|
6243
6363
|
"use strict";
|
|
6244
6364
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6245
6365
|
exports.BlueskyExtractor = void 0;
|
|
@@ -6503,9 +6623,9 @@ var require_bluesky = __commonJS({
|
|
|
6503
6623
|
}
|
|
6504
6624
|
});
|
|
6505
6625
|
|
|
6506
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
6626
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/discourse.js
|
|
6507
6627
|
var require_discourse = __commonJS({
|
|
6508
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
6628
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/discourse.js"(exports) {
|
|
6509
6629
|
"use strict";
|
|
6510
6630
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6511
6631
|
exports.DiscourseExtractor = void 0;
|
|
@@ -6655,9 +6775,9 @@ var require_discourse = __commonJS({
|
|
|
6655
6775
|
}
|
|
6656
6776
|
});
|
|
6657
6777
|
|
|
6658
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
6778
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/medium.js
|
|
6659
6779
|
var require_medium = __commonJS({
|
|
6660
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
6780
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/medium.js"(exports) {
|
|
6661
6781
|
"use strict";
|
|
6662
6782
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6663
6783
|
exports.MediumExtractor = void 0;
|
|
@@ -6681,7 +6801,6 @@ var require_medium = __commonJS({
|
|
|
6681
6801
|
const subtitle = this.getSubtitle();
|
|
6682
6802
|
const author = this.getAuthor();
|
|
6683
6803
|
const publication = this.getPublication();
|
|
6684
|
-
this.cleanArticle();
|
|
6685
6804
|
const description = subtitle || this.getDescription();
|
|
6686
6805
|
return {
|
|
6687
6806
|
content: "",
|
|
@@ -6699,30 +6818,30 @@ var require_medium = __commonJS({
|
|
|
6699
6818
|
}
|
|
6700
6819
|
};
|
|
6701
6820
|
}
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6821
|
+
prepareDocument(doc) {
|
|
6822
|
+
const article = doc.querySelector("article.meteredContent") || doc.querySelector("article");
|
|
6823
|
+
if (article)
|
|
6824
|
+
this.cleanArticle(article);
|
|
6825
|
+
}
|
|
6826
|
+
/** Remove Medium UI elements before the standard pipeline reads the article. */
|
|
6827
|
+
cleanArticle(article) {
|
|
6828
|
+
article.querySelectorAll('figure [role="button"]').forEach((btn) => {
|
|
6710
6829
|
btn.replaceWith(...Array.from(btn.childNodes));
|
|
6711
6830
|
});
|
|
6712
|
-
|
|
6831
|
+
article.querySelectorAll('[role="tooltip"]').forEach((el) => {
|
|
6713
6832
|
el.removeAttribute("role");
|
|
6714
6833
|
});
|
|
6715
|
-
|
|
6834
|
+
article.querySelectorAll('a[href*="medium.com/plans"]').forEach((link) => {
|
|
6716
6835
|
const wrapper = link.closest("div");
|
|
6717
|
-
if (wrapper && wrapper !==
|
|
6836
|
+
if (wrapper && wrapper !== article) {
|
|
6718
6837
|
wrapper.remove();
|
|
6719
6838
|
} else {
|
|
6720
6839
|
link.remove();
|
|
6721
6840
|
}
|
|
6722
6841
|
});
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6842
|
+
article.querySelectorAll('[data-testid="post-preview"]').forEach((el) => el.remove());
|
|
6843
|
+
article.querySelectorAll('[data-testid*="Clap"], [data-testid*="Bookmark"], [data-testid*="Share"], [data-testid*="Response"]').forEach((el) => el.remove());
|
|
6844
|
+
article.querySelectorAll('[data-testid="authorPhoto"], [data-testid="authorName"], [data-testid="storyReadTime"]').forEach((el) => el.remove());
|
|
6726
6845
|
const UI_TEXT = /* @__PURE__ */ new Set([
|
|
6727
6846
|
"Member-only story",
|
|
6728
6847
|
"Listen",
|
|
@@ -6731,7 +6850,7 @@ var require_medium = __commonJS({
|
|
|
6731
6850
|
"\xB7",
|
|
6732
6851
|
"Press enter or click to view image in full size"
|
|
6733
6852
|
]);
|
|
6734
|
-
|
|
6853
|
+
article.querySelectorAll("p, span, div").forEach((el) => {
|
|
6735
6854
|
const text = el.textContent?.trim() || "";
|
|
6736
6855
|
if (!text)
|
|
6737
6856
|
return;
|
|
@@ -6778,7 +6897,9 @@ var require_medium = __commonJS({
|
|
|
6778
6897
|
getDescription() {
|
|
6779
6898
|
if (!this.article)
|
|
6780
6899
|
return "";
|
|
6781
|
-
const
|
|
6900
|
+
const article = this.article.cloneNode(true);
|
|
6901
|
+
this.cleanArticle(article);
|
|
6902
|
+
const paragraphs = article.querySelectorAll("p");
|
|
6782
6903
|
for (const p of Array.from(paragraphs)) {
|
|
6783
6904
|
const text = p.textContent?.trim() || "";
|
|
6784
6905
|
if (text.length < 3 || /^[\d\W]+$/.test(text))
|
|
@@ -6792,9 +6913,9 @@ var require_medium = __commonJS({
|
|
|
6792
6913
|
}
|
|
6793
6914
|
});
|
|
6794
6915
|
|
|
6795
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
6916
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/leetcode.js
|
|
6796
6917
|
var require_leetcode = __commonJS({
|
|
6797
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
6918
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/leetcode.js"(exports) {
|
|
6798
6919
|
"use strict";
|
|
6799
6920
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6800
6921
|
exports.LeetCodeExtractor = void 0;
|
|
@@ -6821,9 +6942,9 @@ var require_leetcode = __commonJS({
|
|
|
6821
6942
|
}
|
|
6822
6943
|
});
|
|
6823
6944
|
|
|
6824
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
6945
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/lwn.js
|
|
6825
6946
|
var require_lwn = __commonJS({
|
|
6826
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
6947
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/lwn.js"(exports) {
|
|
6827
6948
|
"use strict";
|
|
6828
6949
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6829
6950
|
exports.LwnExtractor = void 0;
|
|
@@ -6947,9 +7068,9 @@ var require_lwn = __commonJS({
|
|
|
6947
7068
|
}
|
|
6948
7069
|
});
|
|
6949
7070
|
|
|
6950
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
7071
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/mastodon.js
|
|
6951
7072
|
var require_mastodon = __commonJS({
|
|
6952
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
7073
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/mastodon.js"(exports) {
|
|
6953
7074
|
"use strict";
|
|
6954
7075
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6955
7076
|
exports.MastodonExtractor = void 0;
|
|
@@ -6990,7 +7111,7 @@ var require_mastodon = __commonJS({
|
|
|
6990
7111
|
let threadEnded = false;
|
|
6991
7112
|
for (const status of this.replyStatuses) {
|
|
6992
7113
|
const handle = this.getFullHandle(status).split("@")[0];
|
|
6993
|
-
if (!threadEnded && handle === mainHandle) {
|
|
7114
|
+
if (!threadEnded && mainHandle && handle === mainHandle) {
|
|
6994
7115
|
threadItems.push(status);
|
|
6995
7116
|
} else {
|
|
6996
7117
|
threadEnded = true;
|
|
@@ -7198,9 +7319,9 @@ var require_mastodon = __commonJS({
|
|
|
7198
7319
|
}
|
|
7199
7320
|
});
|
|
7200
7321
|
|
|
7201
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
7322
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/constants.js
|
|
7202
7323
|
var require_constants = __commonJS({
|
|
7203
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
7324
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/constants.js"(exports) {
|
|
7204
7325
|
"use strict";
|
|
7205
7326
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7206
7327
|
exports.TW_ARBITRARY_RE = exports.TW_SPECIAL_CLASS_RE = exports.TW_COLOR_CLASS_RE = exports.TAILWIND_SPECIAL = exports.TAILWIND_COLORS = exports.ALLOWED_ATTRIBUTES_DEBUG = exports.ALLOWED_ATTRIBUTES = exports.ALLOWED_EMPTY_ELEMENTS = exports.FOOTNOTE_LIST_SELECTORS = exports.FOOTNOTE_INLINE_REFERENCES = exports.TEST_ATTRIBUTES_SELECTOR = exports.PARTIAL_SELECTORS_ANCHORED_REGEX = exports.PARTIAL_SELECTORS_REGEX = exports.PARTIAL_SELECTORS = exports.TEST_ATTRIBUTES = exports.EXACT_SELECTORS_JOINED = exports.EXACT_SELECTORS = exports.HIDDEN_EXACT_SKIP_SELECTOR = exports.HIDDEN_EXACT_SELECTOR = exports.CONTENT_ELEMENT_SELECTOR = exports.INLINE_ELEMENTS = exports.PRESERVE_ELEMENTS = exports.BLOCK_LEVEL_ELEMENTS = exports.BLOCK_ELEMENTS_SET = exports.BLOCK_ELEMENTS_SELECTOR = exports.BLOCK_ELEMENTS = exports.MOBILE_WIDTH = exports.ENTRY_POINT_ELEMENTS = void 0;
|
|
@@ -7355,7 +7476,8 @@ var require_constants = __commonJS({
|
|
|
7355
7476
|
// ads
|
|
7356
7477
|
'.ad:not([class*="gradient"])',
|
|
7357
7478
|
'[class^="ad-" i]',
|
|
7358
|
-
'[class$="-ad" i]',
|
|
7479
|
+
'[class$="-ad" i]:not([class~="with-ad" i])',
|
|
7480
|
+
// mixed article/ad wrappers (Puck)
|
|
7359
7481
|
"[data-ad-wrapper]",
|
|
7360
7482
|
'[id^="ad-" i]',
|
|
7361
7483
|
'[id$="-ad" i]',
|
|
@@ -7412,7 +7534,6 @@ var require_constants = __commonJS({
|
|
|
7412
7534
|
".contributor",
|
|
7413
7535
|
".date",
|
|
7414
7536
|
"#date",
|
|
7415
|
-
"[data-date]",
|
|
7416
7537
|
".entry-meta",
|
|
7417
7538
|
".meta",
|
|
7418
7539
|
".tags",
|
|
@@ -7507,6 +7628,8 @@ var require_constants = __commonJS({
|
|
|
7507
7628
|
'[data-component-name="SubscribeWidgetToDOM"]',
|
|
7508
7629
|
'[class*="digestPostEmbed"]',
|
|
7509
7630
|
// class has hash suffix in browser-rendered DOM
|
|
7631
|
+
'[aria-label="Voiceover player"]',
|
|
7632
|
+
// sits outside the post body on custom domains
|
|
7510
7633
|
// hidden for print
|
|
7511
7634
|
".noprint",
|
|
7512
7635
|
'[data-print-layout="hide" i]',
|
|
@@ -7515,7 +7638,7 @@ var require_constants = __commonJS({
|
|
|
7515
7638
|
'[class*="clickable-icon" i]',
|
|
7516
7639
|
'li span[class*="ltx_tag" i][class*="ltx_tag_item" i]',
|
|
7517
7640
|
'a[href^="#"][class*="anchor" i]',
|
|
7518
|
-
'a[href^="#"][class*="ref" i]:not(.ltx_ref):not(.footnote-backref)',
|
|
7641
|
+
'a[href^="#"][class*="ref" i]:not(.ltx_ref):not(.footnote-backref):not(.reference)',
|
|
7519
7642
|
// link lists
|
|
7520
7643
|
'[data-container*="most-viewed" i]',
|
|
7521
7644
|
// sidebar
|
|
@@ -7844,7 +7967,8 @@ var require_constants = __commonJS({
|
|
|
7844
7967
|
"jswarning",
|
|
7845
7968
|
"js-warning",
|
|
7846
7969
|
"jumplink",
|
|
7847
|
-
"jumpto",
|
|
7970
|
+
"(?<![a-z0-9])jumpto(?![a-z0-9])",
|
|
7971
|
+
// avoid APA PsycNet's ftJumpToAnchor article sections
|
|
7848
7972
|
"jump-to-",
|
|
7849
7973
|
"js-skip-to-content",
|
|
7850
7974
|
"keepreading",
|
|
@@ -8188,8 +8312,13 @@ var require_constants = __commonJS({
|
|
|
8188
8312
|
"w-form-done",
|
|
8189
8313
|
"w-form-fail"
|
|
8190
8314
|
];
|
|
8191
|
-
|
|
8192
|
-
|
|
8315
|
+
function compileAlternation(patterns, wrap = (source) => source) {
|
|
8316
|
+
const hasLookbehind = (pattern) => /\(\?<[=!]/.test(pattern);
|
|
8317
|
+
const regexes = [patterns.filter((p) => !hasLookbehind(p)), patterns.filter(hasLookbehind)].filter((group) => group.length > 0).map((group) => new RegExp(wrap(group.join("|")), "i"));
|
|
8318
|
+
return { test: (value) => regexes.some((regex) => regex.test(value)) };
|
|
8319
|
+
}
|
|
8320
|
+
exports.PARTIAL_SELECTORS_REGEX = compileAlternation(exports.PARTIAL_SELECTORS);
|
|
8321
|
+
exports.PARTIAL_SELECTORS_ANCHORED_REGEX = compileAlternation(exports.PARTIAL_SELECTORS, (source) => "^(?:" + source + ")$");
|
|
8193
8322
|
exports.TEST_ATTRIBUTES_SELECTOR = exports.TEST_ATTRIBUTES.map((attr) => `[${attr}]`).join(",");
|
|
8194
8323
|
exports.FOOTNOTE_INLINE_REFERENCES = [
|
|
8195
8324
|
"sup.reference",
|
|
@@ -8412,9 +8541,9 @@ var require_constants = __commonJS({
|
|
|
8412
8541
|
}
|
|
8413
8542
|
});
|
|
8414
8543
|
|
|
8415
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
8544
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/gmail.js
|
|
8416
8545
|
var require_gmail = __commonJS({
|
|
8417
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
8546
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractors/gmail.js"(exports) {
|
|
8418
8547
|
"use strict";
|
|
8419
8548
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8420
8549
|
exports.GmailExtractor = void 0;
|
|
@@ -8619,9 +8748,9 @@ var require_gmail = __commonJS({
|
|
|
8619
8748
|
}
|
|
8620
8749
|
});
|
|
8621
8750
|
|
|
8622
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
8751
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractor-registry.js
|
|
8623
8752
|
var require_extractor_registry = __commonJS({
|
|
8624
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
8753
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/extractor-registry.js"(exports) {
|
|
8625
8754
|
"use strict";
|
|
8626
8755
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8627
8756
|
exports.ExtractorRegistry = void 0;
|
|
@@ -8863,9 +8992,9 @@ var require_extractor_registry = __commonJS({
|
|
|
8863
8992
|
}
|
|
8864
8993
|
});
|
|
8865
8994
|
|
|
8866
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
8995
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/math.base.js
|
|
8867
8996
|
var require_math_base = __commonJS({
|
|
8868
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
8997
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/math.base.js"(exports) {
|
|
8869
8998
|
"use strict";
|
|
8870
8999
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8871
9000
|
exports.createMathRules = exports.createMathElement = exports.LOOKS_LIKE_LATEX_RE = exports.mathSelectors = exports.mathFastCheck = exports.isBlockDisplay = exports.getBasicLatexFromElement = exports.getMathMLFromElement = exports.reconstructMathMLFromMjx = void 0;
|
|
@@ -9407,9 +9536,9 @@ var require_math_base = __commonJS({
|
|
|
9407
9536
|
}
|
|
9408
9537
|
});
|
|
9409
9538
|
|
|
9410
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
9539
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/math.full.js
|
|
9411
9540
|
var require_math_full = __commonJS({
|
|
9412
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
9541
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/math.full.js"(exports) {
|
|
9413
9542
|
"use strict";
|
|
9414
9543
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9415
9544
|
exports.mathRules = exports.createCleanMathEl = exports.getLatexFromElement = void 0;
|
|
@@ -9451,9 +9580,9 @@ var require_math_full = __commonJS({
|
|
|
9451
9580
|
}
|
|
9452
9581
|
});
|
|
9453
9582
|
|
|
9454
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
9583
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/math.js
|
|
9455
9584
|
var require_math = __commonJS({
|
|
9456
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
9585
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/math.js"(exports) {
|
|
9457
9586
|
"use strict";
|
|
9458
9587
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9459
9588
|
exports.createCleanMathEl = exports.mathRules = void 0;
|
|
@@ -9467,9 +9596,9 @@ var require_math = __commonJS({
|
|
|
9467
9596
|
}
|
|
9468
9597
|
});
|
|
9469
9598
|
|
|
9470
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
9599
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/code.js
|
|
9471
9600
|
var require_code = __commonJS({
|
|
9472
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
9601
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/code.js"(exports) {
|
|
9473
9602
|
"use strict";
|
|
9474
9603
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9475
9604
|
exports.codeBlockRules = void 0;
|
|
@@ -9727,12 +9856,21 @@ var require_code = __commonJS({
|
|
|
9727
9856
|
}
|
|
9728
9857
|
return "";
|
|
9729
9858
|
};
|
|
9859
|
+
const parentHasLines = /* @__PURE__ */ new WeakMap();
|
|
9730
9860
|
const extractStructuredText = (element) => {
|
|
9731
9861
|
if ((0, utils_1.isTextNode)(element)) {
|
|
9732
|
-
|
|
9733
|
-
|
|
9862
|
+
const text2 = element.textContent || "";
|
|
9863
|
+
const parent = element.parentElement;
|
|
9864
|
+
if (!text2.trim() && parent) {
|
|
9865
|
+
let hasLines = parentHasLines.get(parent);
|
|
9866
|
+
if (hasLines === void 0) {
|
|
9867
|
+
hasLines = !!parent.querySelector("[data-line], .line");
|
|
9868
|
+
parentHasLines.set(parent, hasLines);
|
|
9869
|
+
}
|
|
9870
|
+
if (hasLines)
|
|
9871
|
+
return "";
|
|
9734
9872
|
}
|
|
9735
|
-
return
|
|
9873
|
+
return text2;
|
|
9736
9874
|
}
|
|
9737
9875
|
let text = "";
|
|
9738
9876
|
if ((0, utils_1.isElement)(element)) {
|
|
@@ -9864,15 +10002,17 @@ var require_code = __commonJS({
|
|
|
9864
10002
|
}
|
|
9865
10003
|
});
|
|
9866
10004
|
|
|
9867
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
10005
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/headings.js
|
|
9868
10006
|
var require_headings = __commonJS({
|
|
9869
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
10007
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/headings.js"(exports) {
|
|
9870
10008
|
"use strict";
|
|
9871
10009
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9872
10010
|
exports.headingRules = void 0;
|
|
9873
10011
|
exports.removePermalinkAnchors = removePermalinkAnchors;
|
|
9874
10012
|
exports.isPermalinkAnchor = isPermalinkAnchor;
|
|
9875
10013
|
var constants_1 = require_constants();
|
|
10014
|
+
var FOOTNOTE_REF_MARKER = 'sup[id^="fnref:"]';
|
|
10015
|
+
var FOOTNOTE_REF = `${FOOTNOTE_REF_MARKER} > a[href^="#fn:"]`;
|
|
9876
10016
|
function removePermalinkAnchors(element) {
|
|
9877
10017
|
Array.from(element.querySelectorAll("h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, a.permalink, a.anchor-link, a.heading-anchor")).forEach((link) => {
|
|
9878
10018
|
if (isPermalinkAnchor(link)) {
|
|
@@ -9883,6 +10023,8 @@ var require_headings = __commonJS({
|
|
|
9883
10023
|
function isPermalinkAnchor(node) {
|
|
9884
10024
|
if (node.tagName.toLowerCase() !== "a")
|
|
9885
10025
|
return false;
|
|
10026
|
+
if (node.matches(FOOTNOTE_REF))
|
|
10027
|
+
return false;
|
|
9886
10028
|
const href = node.getAttribute("href") || "";
|
|
9887
10029
|
const title = (node.getAttribute("title") || "").toLowerCase();
|
|
9888
10030
|
const className = (node.getAttribute("class") || "").toLowerCase();
|
|
@@ -9898,6 +10040,20 @@ var require_headings = __commonJS({
|
|
|
9898
10040
|
return true;
|
|
9899
10041
|
return false;
|
|
9900
10042
|
}
|
|
10043
|
+
function appendHeadingContent(source, target) {
|
|
10044
|
+
Array.from(source.childNodes).forEach((node) => {
|
|
10045
|
+
if (node.nodeType === 3) {
|
|
10046
|
+
target.appendChild(node);
|
|
10047
|
+
} else if (node.nodeType === 1) {
|
|
10048
|
+
const el = node;
|
|
10049
|
+
if (el.matches("math") || el.matches(FOOTNOTE_REF_MARKER)) {
|
|
10050
|
+
target.appendChild(el);
|
|
10051
|
+
} else {
|
|
10052
|
+
appendHeadingContent(el, target);
|
|
10053
|
+
}
|
|
10054
|
+
}
|
|
10055
|
+
});
|
|
10056
|
+
}
|
|
9901
10057
|
function isHeadingNavElement(node) {
|
|
9902
10058
|
const tag = node.tagName.toLowerCase();
|
|
9903
10059
|
if (tag === "button")
|
|
@@ -9932,24 +10088,25 @@ var require_headings = __commonJS({
|
|
|
9932
10088
|
return newHeading;
|
|
9933
10089
|
}
|
|
9934
10090
|
const clone = el.cloneNode(true);
|
|
9935
|
-
const
|
|
9936
|
-
const
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
toRemove.push(child);
|
|
9946
|
-
});
|
|
9947
|
-
toRemove.forEach((element) => element.remove());
|
|
9948
|
-
let textContent = clone.textContent?.trim() || "";
|
|
9949
|
-
if (!textContent && navigationText.size > 0) {
|
|
9950
|
-
textContent = Array.from(navigationText.values())[0];
|
|
10091
|
+
const toRemove = Array.from(clone.querySelectorAll("*")).filter(isHeadingNavElement);
|
|
10092
|
+
const fallback = toRemove[0]?.cloneNode(true);
|
|
10093
|
+
if (fallback) {
|
|
10094
|
+
const stripped = fallback.cloneNode(true);
|
|
10095
|
+
stripped.querySelectorAll("a").forEach((a) => {
|
|
10096
|
+
if (isPermalinkAnchor(a))
|
|
10097
|
+
a.remove();
|
|
10098
|
+
});
|
|
10099
|
+
if (stripped.textContent?.trim())
|
|
10100
|
+
fallback.replaceChildren(...Array.from(stripped.childNodes));
|
|
9951
10101
|
}
|
|
9952
|
-
|
|
10102
|
+
toRemove.forEach((element) => element.remove());
|
|
10103
|
+
const source = !clone.textContent?.trim() && fallback ? fallback : clone;
|
|
10104
|
+
appendHeadingContent(source, newHeading);
|
|
10105
|
+
const { firstChild, lastChild } = newHeading;
|
|
10106
|
+
if (firstChild?.nodeType === 3)
|
|
10107
|
+
firstChild.textContent = firstChild.textContent.trimStart();
|
|
10108
|
+
if (lastChild?.nodeType === 3)
|
|
10109
|
+
lastChild.textContent = lastChild.textContent.trimEnd();
|
|
9953
10110
|
return newHeading;
|
|
9954
10111
|
}
|
|
9955
10112
|
}
|
|
@@ -9957,13 +10114,14 @@ var require_headings = __commonJS({
|
|
|
9957
10114
|
}
|
|
9958
10115
|
});
|
|
9959
10116
|
|
|
9960
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
10117
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/images.js
|
|
9961
10118
|
var require_images = __commonJS({
|
|
9962
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
10119
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/images.js"(exports) {
|
|
9963
10120
|
"use strict";
|
|
9964
10121
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9965
10122
|
exports.imageRules = void 0;
|
|
9966
10123
|
exports.isBase64Placeholder = isBase64Placeholder;
|
|
10124
|
+
exports.extractLargestUrlFromSrcset = extractLargestUrlFromSrcset;
|
|
9967
10125
|
var utils_1 = require_utils();
|
|
9968
10126
|
var dom_1 = require_dom();
|
|
9969
10127
|
var constants_1 = require_constants();
|
|
@@ -9974,6 +10132,7 @@ var require_images = __commonJS({
|
|
|
9974
10132
|
var urlPattern = /^([^\s]+)/;
|
|
9975
10133
|
var filenamePattern = /^[\w\-\.\/\\]+\.(jpg|jpeg|png|gif|webp|svg)$/i;
|
|
9976
10134
|
var datePattern = /^\d{4}-\d{2}-\d{2}$/;
|
|
10135
|
+
var MIN_REPEATED_CAPTION_TEXT = 10;
|
|
9977
10136
|
var LAZY_IMAGE_ATTRIBUTES = [
|
|
9978
10137
|
["src", ["data-src", "data-original", "data-lazy-src"]],
|
|
9979
10138
|
["srcset", ["data-srcset", "data-lazy-srcset"]]
|
|
@@ -10006,7 +10165,7 @@ var require_images = __commonJS({
|
|
|
10006
10165
|
if (bestSource) {
|
|
10007
10166
|
bestSrcset = bestSource.getAttribute("srcset");
|
|
10008
10167
|
if (bestSrcset) {
|
|
10009
|
-
bestSrc =
|
|
10168
|
+
bestSrc = extractLargestUrlFromSrcset(bestSrcset);
|
|
10010
10169
|
}
|
|
10011
10170
|
}
|
|
10012
10171
|
}
|
|
@@ -10016,7 +10175,7 @@ var require_images = __commonJS({
|
|
|
10016
10175
|
if (bestSrc && isValidImageUrl(bestSrc)) {
|
|
10017
10176
|
imgElement.setAttribute("src", bestSrc);
|
|
10018
10177
|
} else if (!imgElement.hasAttribute("src") || !isValidImageUrl(imgElement.getAttribute("src") || "")) {
|
|
10019
|
-
const firstUrl =
|
|
10178
|
+
const firstUrl = extractLargestUrlFromSrcset(imgElement.getAttribute("srcset") || bestSrcset || "");
|
|
10020
10179
|
if (firstUrl && isValidImageUrl(firstUrl)) {
|
|
10021
10180
|
imgElement.setAttribute("src", firstUrl);
|
|
10022
10181
|
}
|
|
@@ -10116,21 +10275,20 @@ var require_images = __commonJS({
|
|
|
10116
10275
|
return el;
|
|
10117
10276
|
}
|
|
10118
10277
|
}
|
|
10119
|
-
const
|
|
10120
|
-
if (
|
|
10278
|
+
const images = findMainImages(el);
|
|
10279
|
+
if (images.length === 0) {
|
|
10121
10280
|
return el;
|
|
10122
10281
|
}
|
|
10123
10282
|
const caption = findCaption(el);
|
|
10124
|
-
const
|
|
10283
|
+
const processedImages = images.map((image) => keepImageLink(image, processImageElement(image, doc), el));
|
|
10125
10284
|
if (caption && hasMeaningfulCaption(caption)) {
|
|
10126
|
-
const figure = createFigureWithCaption(
|
|
10285
|
+
const figure = createFigureWithCaption(processedImages, caption, doc);
|
|
10127
10286
|
if (caption.parentNode) {
|
|
10128
10287
|
caption.parentNode.removeChild(caption);
|
|
10129
10288
|
}
|
|
10130
10289
|
return figure;
|
|
10131
|
-
} else {
|
|
10132
|
-
return processedImg;
|
|
10133
10290
|
}
|
|
10291
|
+
return processedImages.length === 1 ? processedImages[0] : el;
|
|
10134
10292
|
} catch (error) {
|
|
10135
10293
|
return el;
|
|
10136
10294
|
}
|
|
@@ -10142,36 +10300,34 @@ var require_images = __commonJS({
|
|
|
10142
10300
|
element: "figure",
|
|
10143
10301
|
transform: (el, doc) => {
|
|
10144
10302
|
try {
|
|
10145
|
-
|
|
10146
|
-
if (!hasImage) {
|
|
10147
|
-
return el;
|
|
10148
|
-
}
|
|
10149
|
-
const imgElement = findMainImage(el);
|
|
10150
|
-
if (!imgElement) {
|
|
10303
|
+
if (!containsImage(el) || el.querySelector("figure")) {
|
|
10151
10304
|
return el;
|
|
10152
10305
|
}
|
|
10306
|
+
const images = findMainImages(el);
|
|
10153
10307
|
const caption = findCaption(el);
|
|
10154
|
-
if (caption
|
|
10155
|
-
const currentImg = findMainImage(el);
|
|
10156
|
-
let imageToAdd;
|
|
10157
|
-
if (currentImg) {
|
|
10158
|
-
imageToAdd = currentImg;
|
|
10159
|
-
} else {
|
|
10160
|
-
imageToAdd = processImageElement(imgElement, doc);
|
|
10161
|
-
}
|
|
10162
|
-
return createFigureWithCaption(imageToAdd, caption, doc);
|
|
10163
|
-
} else {
|
|
10308
|
+
if (images.length === 0 || !caption || !hasMeaningfulCaption(caption)) {
|
|
10164
10309
|
return el;
|
|
10165
10310
|
}
|
|
10311
|
+
return createFigureWithCaption(images.map((image) => keepImageLink(image, image, el)), caption, doc);
|
|
10166
10312
|
} catch (error) {
|
|
10167
10313
|
return el;
|
|
10168
10314
|
}
|
|
10169
10315
|
}
|
|
10170
10316
|
}
|
|
10171
10317
|
];
|
|
10172
|
-
function
|
|
10318
|
+
function keepImageLink(original, image, container) {
|
|
10319
|
+
const link = original.closest("a");
|
|
10320
|
+
if (!link || link === container || !container.contains(link))
|
|
10321
|
+
return image;
|
|
10322
|
+
const copy = link.cloneNode(false);
|
|
10323
|
+
copy.appendChild(image.cloneNode(true));
|
|
10324
|
+
return copy;
|
|
10325
|
+
}
|
|
10326
|
+
function createFigureWithCaption(images, captionElement, doc) {
|
|
10173
10327
|
const figure = doc.createElement("figure");
|
|
10174
|
-
|
|
10328
|
+
for (const image of images) {
|
|
10329
|
+
figure.appendChild(image.cloneNode(true));
|
|
10330
|
+
}
|
|
10175
10331
|
const figcaption = doc.createElement("figcaption");
|
|
10176
10332
|
const uniqueCaptionContent = extractUniqueCaptionContent(captionElement);
|
|
10177
10333
|
figcaption.appendChild((0, dom_1.parseHTML)(doc, uniqueCaptionContent));
|
|
@@ -10180,7 +10336,7 @@ var require_images = __commonJS({
|
|
|
10180
10336
|
}
|
|
10181
10337
|
function applySrcsetToImage(srcset, img) {
|
|
10182
10338
|
img.setAttribute("srcset", srcset);
|
|
10183
|
-
const firstUrl =
|
|
10339
|
+
const firstUrl = extractLargestUrlFromSrcset(srcset);
|
|
10184
10340
|
if (firstUrl && isValidImageUrl(firstUrl)) {
|
|
10185
10341
|
img.setAttribute("src", firstUrl);
|
|
10186
10342
|
}
|
|
@@ -10228,47 +10384,20 @@ var require_images = __commonJS({
|
|
|
10228
10384
|
const tagName = element.tagName.toLowerCase();
|
|
10229
10385
|
return tagName === "img" || tagName === "video" || tagName === "picture" || tagName === "source";
|
|
10230
10386
|
}
|
|
10231
|
-
function
|
|
10387
|
+
function findMainImages(element) {
|
|
10232
10388
|
if (isImageElement(element)) {
|
|
10233
|
-
return element;
|
|
10234
|
-
}
|
|
10235
|
-
const pictureElements = element.querySelectorAll("picture");
|
|
10236
|
-
if (pictureElements.length > 0) {
|
|
10237
|
-
return pictureElements[0];
|
|
10238
|
-
}
|
|
10239
|
-
const imgElements = element.querySelectorAll("img");
|
|
10240
|
-
const filteredImgElements = [];
|
|
10241
|
-
for (let i = 0; i < imgElements.length; i++) {
|
|
10242
|
-
const img = imgElements[i];
|
|
10243
|
-
const src = img.getAttribute("src") || "";
|
|
10244
|
-
const alt = img.getAttribute("alt") || "";
|
|
10245
|
-
if (isSvgDataUrl(src)) {
|
|
10246
|
-
continue;
|
|
10247
|
-
}
|
|
10248
|
-
if (isBase64Placeholder(src)) {
|
|
10249
|
-
continue;
|
|
10250
|
-
}
|
|
10251
|
-
if (!alt.trim() && imgElements.length > 1) {
|
|
10252
|
-
continue;
|
|
10253
|
-
}
|
|
10254
|
-
filteredImgElements.push(img);
|
|
10255
|
-
}
|
|
10256
|
-
if (filteredImgElements.length > 0) {
|
|
10257
|
-
return filteredImgElements[0];
|
|
10258
|
-
}
|
|
10259
|
-
const videoElements = element.querySelectorAll("video");
|
|
10260
|
-
if (videoElements.length > 0) {
|
|
10261
|
-
return videoElements[0];
|
|
10389
|
+
return [element];
|
|
10262
10390
|
}
|
|
10263
|
-
const
|
|
10264
|
-
if (
|
|
10265
|
-
return
|
|
10266
|
-
}
|
|
10267
|
-
const allImages = element.querySelectorAll("img, picture, source, video");
|
|
10268
|
-
if (allImages.length > 0) {
|
|
10269
|
-
return allImages[0];
|
|
10391
|
+
const images = Array.from(element.querySelectorAll("picture, img")).filter((node) => node.tagName.toLowerCase() === "picture" || !node.closest("picture") && !isPlaceholderImage(node));
|
|
10392
|
+
if (images.length > 0) {
|
|
10393
|
+
return images;
|
|
10270
10394
|
}
|
|
10271
|
-
|
|
10395
|
+
const fallback = element.querySelector("video") || element.querySelector("source") || element.querySelector("img, picture, source, video");
|
|
10396
|
+
return fallback ? [fallback] : [];
|
|
10397
|
+
}
|
|
10398
|
+
function isPlaceholderImage(img) {
|
|
10399
|
+
const src = img.getAttribute("src") || "";
|
|
10400
|
+
return isSvgDataUrl(src) || isBase64Placeholder(src);
|
|
10272
10401
|
}
|
|
10273
10402
|
function findCaption(element) {
|
|
10274
10403
|
const figcaption = element.querySelector("figcaption");
|
|
@@ -10367,12 +10496,16 @@ var require_images = __commonJS({
|
|
|
10367
10496
|
function extractUniqueCaptionContent(caption) {
|
|
10368
10497
|
const textNodes = [];
|
|
10369
10498
|
const processedTexts = /* @__PURE__ */ new Set();
|
|
10499
|
+
let repeatsText = false;
|
|
10370
10500
|
const processNode = (node) => {
|
|
10371
10501
|
if ((0, utils_1.isTextNode)(node)) {
|
|
10372
10502
|
const text = node.textContent?.trim() || "";
|
|
10373
|
-
if (
|
|
10503
|
+
if (processedTexts.has(text)) {
|
|
10504
|
+
repeatsText = true;
|
|
10505
|
+
} else if (text) {
|
|
10374
10506
|
textNodes.push(text);
|
|
10375
|
-
|
|
10507
|
+
if (text.length >= MIN_REPEATED_CAPTION_TEXT)
|
|
10508
|
+
processedTexts.add(text);
|
|
10376
10509
|
}
|
|
10377
10510
|
} else if ((0, utils_1.isElement)(node)) {
|
|
10378
10511
|
const childNodes2 = node.childNodes;
|
|
@@ -10385,6 +10518,9 @@ var require_images = __commonJS({
|
|
|
10385
10518
|
for (let i = 0; i < childNodes.length; i++) {
|
|
10386
10519
|
processNode(childNodes[i]);
|
|
10387
10520
|
}
|
|
10521
|
+
if (!repeatsText && !caption.querySelector("img, picture, video, figure")) {
|
|
10522
|
+
return (0, dom_1.serializeHTML)(caption).trim();
|
|
10523
|
+
}
|
|
10388
10524
|
if (textNodes.length > 0) {
|
|
10389
10525
|
return textNodes.join(" ");
|
|
10390
10526
|
}
|
|
@@ -10482,13 +10618,15 @@ var require_images = __commonJS({
|
|
|
10482
10618
|
}
|
|
10483
10619
|
return newImg;
|
|
10484
10620
|
}
|
|
10485
|
-
function
|
|
10621
|
+
function extractLargestUrlFromSrcset(srcset) {
|
|
10486
10622
|
if (!srcset || !srcset.trim())
|
|
10487
10623
|
return null;
|
|
10488
10624
|
const trimmed = srcset.trim();
|
|
10489
|
-
const entryPattern = /(.+?)\s+(\d+(?:\.\d+)?[wx]
|
|
10625
|
+
const entryPattern = /(.+?)\s+(\d+(?:\.\d+)?)[wx]/g;
|
|
10490
10626
|
let match;
|
|
10491
10627
|
let lastIndex = 0;
|
|
10628
|
+
let bestUrl = null;
|
|
10629
|
+
let bestSize = -1;
|
|
10492
10630
|
while ((match = entryPattern.exec(trimmed)) !== null) {
|
|
10493
10631
|
let url = match[1].trim();
|
|
10494
10632
|
if (lastIndex > 0) {
|
|
@@ -10499,8 +10637,14 @@ var require_images = __commonJS({
|
|
|
10499
10637
|
continue;
|
|
10500
10638
|
if (isSvgDataUrl(url))
|
|
10501
10639
|
continue;
|
|
10502
|
-
|
|
10640
|
+
const size = parseFloat(match[2]);
|
|
10641
|
+
if (size > bestSize) {
|
|
10642
|
+
bestSize = size;
|
|
10643
|
+
bestUrl = url;
|
|
10644
|
+
}
|
|
10503
10645
|
}
|
|
10646
|
+
if (bestUrl)
|
|
10647
|
+
return bestUrl;
|
|
10504
10648
|
const urlMatch = trimmed.match(urlPattern);
|
|
10505
10649
|
if (urlMatch && urlMatch[1] && !isSvgDataUrl(urlMatch[1])) {
|
|
10506
10650
|
return urlMatch[1];
|
|
@@ -10546,9 +10690,9 @@ var require_images = __commonJS({
|
|
|
10546
10690
|
}
|
|
10547
10691
|
});
|
|
10548
10692
|
|
|
10549
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
10693
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/standardize.js
|
|
10550
10694
|
var require_standardize = __commonJS({
|
|
10551
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
10695
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/standardize.js"(exports) {
|
|
10552
10696
|
"use strict";
|
|
10553
10697
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10554
10698
|
exports.standardizeExtractorOutput = standardizeExtractorOutput;
|
|
@@ -10714,7 +10858,7 @@ var require_standardize = __commonJS({
|
|
|
10714
10858
|
step("flattenWrapperElements[2]", () => flattenWrapperElements(element, doc));
|
|
10715
10859
|
step("removeOrphanedDividers[2]", () => removeOrphanedDividers(element));
|
|
10716
10860
|
step("stripExtraBrElements", () => stripExtraBrElements(element));
|
|
10717
|
-
step("removeEmptyLines", () => removeEmptyLines(element, doc));
|
|
10861
|
+
step("removeEmptyLines", () => removeEmptyLines(element, doc, keepsSpaceBeforeHighPunctuation(metadata.language)));
|
|
10718
10862
|
} else {
|
|
10719
10863
|
step("stripUnwantedAttributes", () => stripUnwantedAttributes(element, debug));
|
|
10720
10864
|
step("removeTrailingHeadings", () => removeTrailingHeadings(element));
|
|
@@ -10728,13 +10872,19 @@ var require_standardize = __commonJS({
|
|
|
10728
10872
|
if (code.closest("pre"))
|
|
10729
10873
|
continue;
|
|
10730
10874
|
const style = code.getAttribute("style") || "";
|
|
10731
|
-
if (!/white-space\s*:\s*pre/.test(style))
|
|
10875
|
+
if (!/white-space\s*:\s*pre/.test(style) && !isLineBrokenCodeBlock(code))
|
|
10732
10876
|
continue;
|
|
10733
10877
|
const pre = doc.createElement("pre");
|
|
10734
10878
|
code.parentNode?.insertBefore(pre, code);
|
|
10735
10879
|
pre.appendChild(code);
|
|
10736
10880
|
}
|
|
10737
10881
|
}
|
|
10882
|
+
function isLineBrokenCodeBlock(code) {
|
|
10883
|
+
if (!code.querySelector("br") || code.closest("td, th"))
|
|
10884
|
+
return false;
|
|
10885
|
+
const parent = code.parentElement;
|
|
10886
|
+
return !!parent && (parent.textContent || "").trim() === (code.textContent || "").trim();
|
|
10887
|
+
}
|
|
10738
10888
|
function standardizeSpaces(element) {
|
|
10739
10889
|
const processNode = (node) => {
|
|
10740
10890
|
if ((0, utils_1.isElement)(node)) {
|
|
@@ -10902,7 +11052,8 @@ var require_standardize = __commonJS({
|
|
|
10902
11052
|
attrValue.startsWith("fn:") || // Footnote content
|
|
10903
11053
|
attrValue === "footnotes") || // Preserve code block language classes, footnote backref class, and callout classes
|
|
10904
11054
|
attrName === "class" && (tag === "code" && attrValue.startsWith("language-") || attrValue === "footnote-backref" || /^callout(?:-|$)/.test(attrValue)) || // Marks the extractor output wrapper (emitted by buildContentHtml).
|
|
10905
|
-
extractorOutput && attrName === "data-defuddle"
|
|
11055
|
+
extractorOutput && attrName === "data-defuddle" || // Transcript start times (emitted by buildTranscript).
|
|
11056
|
+
extractorOutput && attrName === "data-timestamp" && el.classList.contains("timestamp")
|
|
10906
11057
|
) {
|
|
10907
11058
|
return;
|
|
10908
11059
|
}
|
|
@@ -11275,6 +11426,10 @@ var require_standardize = __commonJS({
|
|
|
11275
11426
|
const isEmptyElement = (el) => {
|
|
11276
11427
|
if (constants_1.ALLOWED_EMPTY_ELEMENTS.has(el.tagName.toLowerCase()))
|
|
11277
11428
|
return false;
|
|
11429
|
+
if (el.parentElement?.closest("math"))
|
|
11430
|
+
return false;
|
|
11431
|
+
if (el.tagName.toLowerCase() === "math" && el.getAttribute("data-latex")?.trim())
|
|
11432
|
+
return false;
|
|
11278
11433
|
if (el.tagName === "DIV") {
|
|
11279
11434
|
const children = el.children;
|
|
11280
11435
|
if (children.length > 0) {
|
|
@@ -11424,7 +11579,11 @@ var require_standardize = __commonJS({
|
|
|
11424
11579
|
function isTightInline(node) {
|
|
11425
11580
|
return (0, utils_1.isElement)(node) && TIGHT_INLINE.has(node.tagName.toLowerCase()) && !isFootnoteRef(node);
|
|
11426
11581
|
}
|
|
11427
|
-
function
|
|
11582
|
+
function keepsSpaceBeforeHighPunctuation(language) {
|
|
11583
|
+
return /^fr(?:-|_|$)/i.test((language || "").trim());
|
|
11584
|
+
}
|
|
11585
|
+
function removeEmptyLines(element, doc, keepSpaceBeforeHighPunctuation = false) {
|
|
11586
|
+
const spaceBeforePunctuation = keepSpaceBeforeHighPunctuation ? /\s+([,.])/g : /\s+([,.!?:;])/g;
|
|
11428
11587
|
let removedCount = 0;
|
|
11429
11588
|
const startTime = Date.now();
|
|
11430
11589
|
const removeEmptyTextNodes = (node) => {
|
|
@@ -11442,7 +11601,7 @@ var require_standardize = __commonJS({
|
|
|
11442
11601
|
node.parentNode?.removeChild(node);
|
|
11443
11602
|
removedCount++;
|
|
11444
11603
|
} else {
|
|
11445
|
-
const newText = text.replace(/[\n\r]+/g, " ").replace(/\t+/g, " ").replace(/ {2,}/g, " ").replace(/^[ ]+$/, " ").replace(
|
|
11604
|
+
const newText = text.replace(/[\n\r]+/g, " ").replace(/\t+/g, " ").replace(/ {2,}/g, " ").replace(/^[ ]+$/, " ").replace(spaceBeforePunctuation, "$1").replace(/[\u200B\u200D\u200E\u200F\uFEFF]+/g, "").replace(/(?:\xA0){2,}/g, "\xA0");
|
|
11446
11605
|
if (newText !== text) {
|
|
11447
11606
|
node.textContent = newText;
|
|
11448
11607
|
removedCount += text.length - newText.length;
|
|
@@ -11485,8 +11644,8 @@ var require_standardize = __commonJS({
|
|
|
11485
11644
|
const nextContent = next.textContent || "";
|
|
11486
11645
|
const currentContent = current.textContent || "";
|
|
11487
11646
|
const nextIsFootnoteRef = isFootnoteRef(next);
|
|
11488
|
-
const nextStartsWithPunctuation = nextContent.match(/^[,.!?:;)\]
|
|
11489
|
-
const currentEndsWithPunctuation = currentContent.match(/[,.!?:;(\[
|
|
11647
|
+
const nextStartsWithPunctuation = nextContent.match(/^[,.!?:;)\]”’'—–]/);
|
|
11648
|
+
const currentEndsWithPunctuation = currentContent.match(/[,.!?:;(\[“‘'—–]\s*$/);
|
|
11490
11649
|
const hasSpace = (0, utils_1.isTextNode)(current) && (current.textContent || "").endsWith(" ") || (0, utils_1.isTextNode)(next) && (next.textContent || "").startsWith(" ");
|
|
11491
11650
|
if (!nextIsFootnoteRef && !nextStartsWithPunctuation && !currentEndsWithPunctuation && !hasSpace) {
|
|
11492
11651
|
const space = doc.createTextNode(" ");
|
|
@@ -11907,9 +12066,9 @@ var require_standardize = __commonJS({
|
|
|
11907
12066
|
}
|
|
11908
12067
|
});
|
|
11909
12068
|
|
|
11910
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
12069
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/footnotes.js
|
|
11911
12070
|
var require_footnotes = __commonJS({
|
|
11912
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
12071
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/footnotes.js"(exports) {
|
|
11913
12072
|
"use strict";
|
|
11914
12073
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11915
12074
|
exports.FOOTNOTE_SECTION_RE = void 0;
|
|
@@ -11926,6 +12085,9 @@ var require_footnotes = __commonJS({
|
|
|
11926
12085
|
const href = anchor?.getAttribute("href") || "";
|
|
11927
12086
|
return href.split("#").pop()?.toLowerCase() || "";
|
|
11928
12087
|
}
|
|
12088
|
+
function nextFootnoteNumber(...collections) {
|
|
12089
|
+
return Math.max(0, ...collections.flatMap((collection) => Object.keys(collection).map(Number))) + 1;
|
|
12090
|
+
}
|
|
11929
12091
|
var INLINE_REF_EXTRACTORS = [
|
|
11930
12092
|
{
|
|
11931
12093
|
selector: "sup.footnoteref",
|
|
@@ -11995,16 +12157,25 @@ var require_footnotes = __commonJS({
|
|
|
11995
12157
|
var FootnoteHandler = class {
|
|
11996
12158
|
constructor(doc) {
|
|
11997
12159
|
this.pendingRemovals = [];
|
|
12160
|
+
this.createdRefs = /* @__PURE__ */ new Set();
|
|
11998
12161
|
this.doc = doc;
|
|
11999
12162
|
}
|
|
12000
12163
|
makeRefId(footnoteNumber, refsLength) {
|
|
12001
12164
|
return refsLength > 0 ? `fnref:${footnoteNumber}-${refsLength + 1}` : `fnref:${footnoteNumber}`;
|
|
12002
12165
|
}
|
|
12003
|
-
|
|
12166
|
+
// Each collector numbers from 1, so a footnote whose number is taken moves to the end.
|
|
12167
|
+
// One already collected under the same id is a duplicate.
|
|
12168
|
+
mergeFootnotes(target, source, reserved) {
|
|
12169
|
+
const ids = new Set(Object.values(target).map((data) => data.originalId.toLowerCase()));
|
|
12004
12170
|
for (const [num, data] of Object.entries(source)) {
|
|
12005
|
-
const
|
|
12006
|
-
if (
|
|
12007
|
-
|
|
12171
|
+
const id = data.originalId.toLowerCase();
|
|
12172
|
+
if (ids.has(id))
|
|
12173
|
+
continue;
|
|
12174
|
+
let n = parseInt(num);
|
|
12175
|
+
if (target[n] || reserved[n])
|
|
12176
|
+
n = nextFootnoteNumber(target, reserved);
|
|
12177
|
+
target[n] = data;
|
|
12178
|
+
ids.add(id);
|
|
12008
12179
|
}
|
|
12009
12180
|
}
|
|
12010
12181
|
// Record a footnote if id is non-empty and unseen. Without explicitNum, assigns
|
|
@@ -12801,6 +12972,7 @@ var require_footnotes = __commonJS({
|
|
|
12801
12972
|
}
|
|
12802
12973
|
createFootnoteReference(footnoteNumber, refId) {
|
|
12803
12974
|
const sup = this.doc.createElement("sup");
|
|
12975
|
+
this.createdRefs.add(sup);
|
|
12804
12976
|
sup.id = refId;
|
|
12805
12977
|
const link = this.doc.createElement("a");
|
|
12806
12978
|
link.href = `#fn:${footnoteNumber}`;
|
|
@@ -12953,7 +13125,7 @@ var require_footnotes = __commonJS({
|
|
|
12953
13125
|
// Hidden aside footnotes linked by data-definition attribute
|
|
12954
13126
|
// Pattern: <span data-definition="id"><a href="#">*</a></span>
|
|
12955
13127
|
// <aside style="display:none" id="id">content</aside>
|
|
12956
|
-
collectHiddenAsideFootnotes(element) {
|
|
13128
|
+
collectHiddenAsideFootnotes(element, firstNumber) {
|
|
12957
13129
|
const footnotes = {};
|
|
12958
13130
|
const refs = Array.from(element.querySelectorAll("span[data-definition]"));
|
|
12959
13131
|
if (refs.length === 0)
|
|
@@ -12962,7 +13134,7 @@ var require_footnotes = __commonJS({
|
|
|
12962
13134
|
element.querySelectorAll("aside[id]").forEach((aside) => {
|
|
12963
13135
|
asideMap.set(aside.id, aside);
|
|
12964
13136
|
});
|
|
12965
|
-
let footnoteCount =
|
|
13137
|
+
let footnoteCount = firstNumber;
|
|
12966
13138
|
refs.forEach((ref) => {
|
|
12967
13139
|
const defId = ref.getAttribute("data-definition");
|
|
12968
13140
|
if (!defId)
|
|
@@ -12985,12 +13157,43 @@ var require_footnotes = __commonJS({
|
|
|
12985
13157
|
});
|
|
12986
13158
|
return footnotes;
|
|
12987
13159
|
}
|
|
13160
|
+
// LaTeXML (arXiv) keeps each footnote body in a hidden span.ltx_note_outer
|
|
13161
|
+
// next to its marker. Replace each note with a reference to its body.
|
|
13162
|
+
collectLatexmlFootnotes(element, footnotes) {
|
|
13163
|
+
let footnoteCount = nextFootnoteNumber(footnotes);
|
|
13164
|
+
const seen = /* @__PURE__ */ new Map();
|
|
13165
|
+
element.querySelectorAll("span.ltx_note.ltx_role_footnote").forEach((note) => {
|
|
13166
|
+
const content = note.querySelector(".ltx_note_content")?.cloneNode(true);
|
|
13167
|
+
if (!content)
|
|
13168
|
+
return;
|
|
13169
|
+
content.querySelectorAll(".ltx_note_mark, .ltx_tag_note").forEach((label) => label.remove());
|
|
13170
|
+
this.trimLeadingWhitespace(content);
|
|
13171
|
+
const mark = note.querySelector(".ltx_note_mark")?.textContent?.trim() || "";
|
|
13172
|
+
const key = `${mark}
|
|
13173
|
+
${content.textContent?.trim()}`;
|
|
13174
|
+
const existing = seen.get(key);
|
|
13175
|
+
if (existing !== void 0) {
|
|
13176
|
+
const refId = this.makeRefId(String(existing), footnotes[existing].refs.length);
|
|
13177
|
+
footnotes[existing].refs.push(refId);
|
|
13178
|
+
note.replaceWith(this.createFootnoteReference(String(existing), refId));
|
|
13179
|
+
return;
|
|
13180
|
+
}
|
|
13181
|
+
seen.set(key, footnoteCount);
|
|
13182
|
+
footnotes[footnoteCount] = {
|
|
13183
|
+
content,
|
|
13184
|
+
originalId: note.id,
|
|
13185
|
+
refs: [`fnref:${footnoteCount}`]
|
|
13186
|
+
};
|
|
13187
|
+
note.replaceWith(this.createFootnoteReference(String(footnoteCount), `fnref:${footnoteCount}`));
|
|
13188
|
+
footnoteCount++;
|
|
13189
|
+
});
|
|
13190
|
+
}
|
|
12988
13191
|
standardizeFootnotes(element) {
|
|
12989
13192
|
const sidenotes = this.collectInlineSidenotes(element);
|
|
12990
|
-
const footnotes = this.collectHiddenAsideFootnotes(element);
|
|
12991
|
-
this.mergeFootnotes(footnotes, this.collectFootnotes(element));
|
|
12992
|
-
this.mergeFootnotes(footnotes, this.collectSidenotesColumn(element));
|
|
12993
|
-
this.mergeFootnotes(footnotes, this.collectAsideFootnotes(element));
|
|
13193
|
+
const footnotes = this.collectHiddenAsideFootnotes(element, nextFootnoteNumber(sidenotes));
|
|
13194
|
+
this.mergeFootnotes(footnotes, this.collectFootnotes(element), sidenotes);
|
|
13195
|
+
this.mergeFootnotes(footnotes, this.collectSidenotesColumn(element), sidenotes);
|
|
13196
|
+
this.mergeFootnotes(footnotes, this.collectAsideFootnotes(element), sidenotes);
|
|
12994
13197
|
const footnoteInlineReferences = element.querySelectorAll(constants_1.FOOTNOTE_INLINE_REFERENCES);
|
|
12995
13198
|
const supGroups = /* @__PURE__ */ new Map();
|
|
12996
13199
|
const footnotesByOriginalId = /* @__PURE__ */ new Map();
|
|
@@ -13000,6 +13203,8 @@ var require_footnotes = __commonJS({
|
|
|
13000
13203
|
footnoteInlineReferences.forEach((el) => {
|
|
13001
13204
|
if (!el || !el.parentNode)
|
|
13002
13205
|
return;
|
|
13206
|
+
if (this.createdRefs.has(el.closest("sup")))
|
|
13207
|
+
return;
|
|
13003
13208
|
if (!el.textContent?.trim())
|
|
13004
13209
|
return;
|
|
13005
13210
|
if (el.matches("cite.ltx_cite")) {
|
|
@@ -13120,6 +13325,7 @@ var require_footnotes = __commonJS({
|
|
|
13120
13325
|
newList.id = "footnotes";
|
|
13121
13326
|
const orderedList = this.doc.createElement("ol");
|
|
13122
13327
|
const allFootnotes = { ...sidenotes, ...footnotes };
|
|
13328
|
+
this.collectLatexmlFootnotes(element, allFootnotes);
|
|
13123
13329
|
Object.entries(allFootnotes).forEach(([number, data]) => {
|
|
13124
13330
|
orderedList.appendChild(this.createFootnoteItem(parseInt(number), data.content, data.refs));
|
|
13125
13331
|
});
|
|
@@ -13146,9 +13352,9 @@ var require_footnotes = __commonJS({
|
|
|
13146
13352
|
}
|
|
13147
13353
|
});
|
|
13148
13354
|
|
|
13149
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
13355
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/callouts.js
|
|
13150
13356
|
var require_callouts = __commonJS({
|
|
13151
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
13357
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/elements/callouts.js"(exports) {
|
|
13152
13358
|
"use strict";
|
|
13153
13359
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13154
13360
|
exports.standardizeCallouts = standardizeCallouts;
|
|
@@ -13245,9 +13451,9 @@ var require_callouts = __commonJS({
|
|
|
13245
13451
|
}
|
|
13246
13452
|
});
|
|
13247
13453
|
|
|
13248
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
13454
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/scoring.js
|
|
13249
13455
|
var require_scoring = __commonJS({
|
|
13250
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
13456
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/scoring.js"(exports) {
|
|
13251
13457
|
"use strict";
|
|
13252
13458
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13253
13459
|
exports.ContentScorer = void 0;
|
|
@@ -13502,13 +13708,18 @@ var require_scoring = __commonJS({
|
|
|
13502
13708
|
if (words < 1e3) {
|
|
13503
13709
|
const headings = element.querySelectorAll("h1, h2, h3, h4, h5, h6");
|
|
13504
13710
|
let hasNavigationHeading = false;
|
|
13711
|
+
let hasTitleHeading = false;
|
|
13505
13712
|
for (let i = 0; i < headings.length; i++) {
|
|
13506
13713
|
const headingText = (headings[i].textContent || "").toLowerCase().trim();
|
|
13507
13714
|
if (navigationHeadingPattern.test(headingText)) {
|
|
13508
13715
|
hasNavigationHeading = true;
|
|
13509
|
-
|
|
13716
|
+
} else if (headingText && headings[i].tagName.toLowerCase() === "h1") {
|
|
13717
|
+
hasTitleHeading = true;
|
|
13510
13718
|
}
|
|
13511
13719
|
}
|
|
13720
|
+
if (hasTitleHeading) {
|
|
13721
|
+
hasNavigationHeading = false;
|
|
13722
|
+
}
|
|
13512
13723
|
if (hasNavigationHeading) {
|
|
13513
13724
|
if (words < 200) {
|
|
13514
13725
|
return false;
|
|
@@ -13652,9 +13863,9 @@ var require_scoring = __commonJS({
|
|
|
13652
13863
|
}
|
|
13653
13864
|
});
|
|
13654
13865
|
|
|
13655
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
13866
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/small-images.js
|
|
13656
13867
|
var require_small_images = __commonJS({
|
|
13657
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
13868
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/small-images.js"(exports) {
|
|
13658
13869
|
"use strict";
|
|
13659
13870
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13660
13871
|
exports.getElementIdentifier = getElementIdentifier;
|
|
@@ -13800,9 +14011,9 @@ var require_small_images = __commonJS({
|
|
|
13800
14011
|
}
|
|
13801
14012
|
});
|
|
13802
14013
|
|
|
13803
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
14014
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/hidden.js
|
|
13804
14015
|
var require_hidden = __commonJS({
|
|
13805
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
14016
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/hidden.js"(exports) {
|
|
13806
14017
|
"use strict";
|
|
13807
14018
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13808
14019
|
exports.removeHiddenElements = removeHiddenElements;
|
|
@@ -13850,6 +14061,8 @@ var require_hidden = __commonJS({
|
|
|
13850
14061
|
if ((0, dom_1.hasResponsiveShowClass)(className))
|
|
13851
14062
|
continue;
|
|
13852
14063
|
for (const token of tokens) {
|
|
14064
|
+
if (token.endsWith(":hidden") && token.split(":").includes("empty") && !element.matches(":empty"))
|
|
14065
|
+
continue;
|
|
13853
14066
|
const isExact = token === "hidden" || token === "invisible";
|
|
13854
14067
|
const isVariant = !token.includes("[") && (token.endsWith(":hidden") || token.endsWith(":invisible"));
|
|
13855
14068
|
if (isExact || isVariant) {
|
|
@@ -13875,9 +14088,9 @@ var require_hidden = __commonJS({
|
|
|
13875
14088
|
}
|
|
13876
14089
|
});
|
|
13877
14090
|
|
|
13878
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
14091
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/selectors.js
|
|
13879
14092
|
var require_selectors = __commonJS({
|
|
13880
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
14093
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/selectors.js"(exports) {
|
|
13881
14094
|
"use strict";
|
|
13882
14095
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13883
14096
|
exports.removeBySelector = removeBySelector;
|
|
@@ -13886,6 +14099,32 @@ var require_selectors = __commonJS({
|
|
|
13886
14099
|
var dom_1 = require_dom();
|
|
13887
14100
|
var SCREEN_READER_LINK_TEXT_SELECTOR = ["sr-only", "visually-hidden", "screen-reader-text"].map((name) => `a [class*="${name}"]`).join(", ");
|
|
13888
14101
|
var LINK_ANNOTATION_REGEX = /^[\s,(–-]*(?:(?:link )?opens in (?:a )?new (?:window|tab)|new (?:window|tab)|external(?: link| site| website)?)[\s).]*$/i;
|
|
14102
|
+
function isTableCellOrRow(el) {
|
|
14103
|
+
const tag = el.tagName;
|
|
14104
|
+
if (tag !== "TR" && tag !== "TD" && tag !== "TH")
|
|
14105
|
+
return false;
|
|
14106
|
+
return Boolean(el.closest("table")?.querySelector(":scope > caption, :scope > thead, :scope > tr > th, :scope > tbody > tr > th"));
|
|
14107
|
+
}
|
|
14108
|
+
function isInsideCodeTable(el) {
|
|
14109
|
+
return Boolean(el.closest("table")?.querySelector("pre"));
|
|
14110
|
+
}
|
|
14111
|
+
function isLevelSectionHeadingId(el, id) {
|
|
14112
|
+
if (el.tagName !== "SECTION" || !id) {
|
|
14113
|
+
return false;
|
|
14114
|
+
}
|
|
14115
|
+
if (!/\blevel\d+\b/i.test((0, dom_1.getClassName)(el))) {
|
|
14116
|
+
return false;
|
|
14117
|
+
}
|
|
14118
|
+
if (id.startsWith("sec-")) {
|
|
14119
|
+
return true;
|
|
14120
|
+
}
|
|
14121
|
+
const heading = el.querySelector("h1, h2, h3, h4, h5, h6");
|
|
14122
|
+
if (!heading) {
|
|
14123
|
+
return false;
|
|
14124
|
+
}
|
|
14125
|
+
const slug = (heading.textContent || "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "");
|
|
14126
|
+
return Boolean(slug) && (id === slug || slug.endsWith("-" + id));
|
|
14127
|
+
}
|
|
13889
14128
|
function removeBySelector(doc, debug, removeExact = true, removePartial = true, mainContent, debugRemovals, skipHiddenExactSelectors = false) {
|
|
13890
14129
|
const startTime = Date.now();
|
|
13891
14130
|
let exactSelectorCount = 0;
|
|
@@ -13905,6 +14144,9 @@ var require_selectors = __commonJS({
|
|
|
13905
14144
|
if (el.closest("pre, code")) {
|
|
13906
14145
|
return;
|
|
13907
14146
|
}
|
|
14147
|
+
if (isTableCellOrRow(el) && !el.matches(constants_1.HIDDEN_EXACT_SELECTOR) && !isInsideCodeTable(el)) {
|
|
14148
|
+
return;
|
|
14149
|
+
}
|
|
13908
14150
|
if (el.matches(constants_1.HIDDEN_EXACT_SELECTOR) && (0, dom_1.hasResponsiveShowClass)((0, dom_1.getClassName)(el))) {
|
|
13909
14151
|
return;
|
|
13910
14152
|
}
|
|
@@ -13929,9 +14171,15 @@ var require_selectors = __commonJS({
|
|
|
13929
14171
|
if (tag === "CODE" || tag === "PRE" || el.querySelector("pre") || el.closest("code, pre")) {
|
|
13930
14172
|
return;
|
|
13931
14173
|
}
|
|
14174
|
+
if (isTableCellOrRow(el) && !isInsideCodeTable(el)) {
|
|
14175
|
+
return;
|
|
14176
|
+
}
|
|
13932
14177
|
const isHeading = /^H[1-6]$/.test(tag);
|
|
13933
|
-
const
|
|
13934
|
-
const
|
|
14178
|
+
const className = (0, dom_1.getClassName)(el).replace(/\[[^\]]*\]/g, "");
|
|
14179
|
+
const attrs = (isHeading ? className : className + " " + (el.getAttribute("data-component") || "") + " " + (el.getAttribute("data-test") || "") + " " + (el.getAttribute("data-testid") || "") + " " + (el.getAttribute("data-test-id") || "") + " " + (el.getAttribute("data-qa") || "") + " " + (el.getAttribute("data-cy") || "")).toLowerCase();
|
|
14180
|
+
const skipId = isHeading || constants_1.INLINE_ELEMENTS.has(tag.toLowerCase()) && !!el.closest("p");
|
|
14181
|
+
const rawId = skipId ? "" : (el.id || "").toLowerCase();
|
|
14182
|
+
const id = isLevelSectionHeadingId(el, rawId) ? "" : rawId;
|
|
13935
14183
|
const hasAttrs = attrs.trim() !== "";
|
|
13936
14184
|
if (!hasAttrs && !id) {
|
|
13937
14185
|
return;
|
|
@@ -14018,9 +14266,9 @@ var require_selectors = __commonJS({
|
|
|
14018
14266
|
}
|
|
14019
14267
|
});
|
|
14020
14268
|
|
|
14021
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
14269
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/content-boundary.js
|
|
14022
14270
|
var require_content_boundary = __commonJS({
|
|
14023
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
14271
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/content-boundary.js"(exports) {
|
|
14024
14272
|
"use strict";
|
|
14025
14273
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14026
14274
|
exports.findContentStart = findContentStart;
|
|
@@ -14148,9 +14396,9 @@ var require_content_boundary = __commonJS({
|
|
|
14148
14396
|
}
|
|
14149
14397
|
});
|
|
14150
14398
|
|
|
14151
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
14399
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/content-patterns.js
|
|
14152
14400
|
var require_content_patterns = __commonJS({
|
|
14153
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
14401
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/content-patterns.js"(exports) {
|
|
14154
14402
|
"use strict";
|
|
14155
14403
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14156
14404
|
exports.removeEyebrowLabel = removeEyebrowLabel;
|
|
@@ -14171,7 +14419,7 @@ var require_content_patterns = __commonJS({
|
|
|
14171
14419
|
/^Originally (?:published|appeared) (?:in|on|at)\b/i,
|
|
14172
14420
|
/^Any re-?use permitted\b/i,
|
|
14173
14421
|
/^©\s*(?:Copyright\s+)?\d{4}/i,
|
|
14174
|
-
/^Comments
|
|
14422
|
+
/^Comments$/i,
|
|
14175
14423
|
/^Leave a (?:comment|reply)$/i,
|
|
14176
14424
|
/^Loading\.{3}$/,
|
|
14177
14425
|
/^Affiliate links\b.*\b(?:earn|commission)/i,
|
|
@@ -14760,6 +15008,10 @@ var require_content_patterns = __commonJS({
|
|
|
14760
15008
|
continue;
|
|
14761
15009
|
if (list.closest("#footnotes"))
|
|
14762
15010
|
continue;
|
|
15011
|
+
if (list.parentElement?.closest("li"))
|
|
15012
|
+
continue;
|
|
15013
|
+
if (list.closest("td, th"))
|
|
15014
|
+
continue;
|
|
14763
15015
|
const isDl = list.tagName === "DL";
|
|
14764
15016
|
if (list.tagName === "OL")
|
|
14765
15017
|
continue;
|
|
@@ -14836,10 +15088,14 @@ var require_content_patterns = __commonJS({
|
|
|
14836
15088
|
if (!link)
|
|
14837
15089
|
continue;
|
|
14838
15090
|
try {
|
|
14839
|
-
const
|
|
15091
|
+
const linkUrl = new URL(link.getAttribute("href") || "", url);
|
|
15092
|
+
if (linkUrl.hostname.replace(/^www\./, "") !== pageHost)
|
|
15093
|
+
continue;
|
|
15094
|
+
const linkPath = linkUrl.pathname;
|
|
14840
15095
|
const linkDir = linkPath.replace(/\/[^/]*$/, "/");
|
|
14841
15096
|
const isParentIndex = /^index\.(html?|php)$/i.test(linkPath.split("/").pop() || "") && urlPath.startsWith(linkDir);
|
|
14842
|
-
|
|
15097
|
+
const parentPrefix = linkPath.endsWith("/") ? linkPath : `${linkPath}/`;
|
|
15098
|
+
if (linkPath !== "/" && linkPath !== urlPath && (urlPath.startsWith(parentPrefix) || isParentIndex)) {
|
|
14843
15099
|
if (debug && debugRemovals) {
|
|
14844
15100
|
debugRemovals.push({
|
|
14845
15101
|
step: "removeByContentPattern",
|
|
@@ -15208,6 +15464,8 @@ var require_content_patterns = __commonJS({
|
|
|
15208
15464
|
const elText = el.textContent?.trim() || "";
|
|
15209
15465
|
if (!SHARE_AUTHOR_LABEL.test(elText))
|
|
15210
15466
|
continue;
|
|
15467
|
+
if (el.closest("pre, code") || el.querySelector("pre, code"))
|
|
15468
|
+
continue;
|
|
15211
15469
|
let container = el;
|
|
15212
15470
|
while (container.parentElement && container.parentElement !== mainContent) {
|
|
15213
15471
|
const parent = container.parentElement;
|
|
@@ -15228,6 +15486,8 @@ var require_content_patterns = __commonJS({
|
|
|
15228
15486
|
const text = el.textContent?.trim() || "";
|
|
15229
15487
|
if (!SOCIAL_COUNTER_PATTERN.test(text))
|
|
15230
15488
|
continue;
|
|
15489
|
+
if (el.closest("pre, code") || el.querySelector("pre, code"))
|
|
15490
|
+
continue;
|
|
15231
15491
|
if (el.tagName === "A" && el.getAttribute("href"))
|
|
15232
15492
|
continue;
|
|
15233
15493
|
if (el.tagName !== "A") {
|
|
@@ -15276,9 +15536,9 @@ var require_content_patterns = __commonJS({
|
|
|
15276
15536
|
}
|
|
15277
15537
|
});
|
|
15278
15538
|
|
|
15279
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
15539
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/metadata-block.js
|
|
15280
15540
|
var require_metadata_block = __commonJS({
|
|
15281
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
15541
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/removals/metadata-block.js"(exports) {
|
|
15282
15542
|
"use strict";
|
|
15283
15543
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15284
15544
|
exports.removeMetadataBlock = removeMetadataBlock;
|
|
@@ -15312,9 +15572,9 @@ var require_metadata_block = __commonJS({
|
|
|
15312
15572
|
}
|
|
15313
15573
|
});
|
|
15314
15574
|
|
|
15315
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
15575
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/defuddle.js
|
|
15316
15576
|
var require_defuddle = __commonJS({
|
|
15317
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
15577
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/defuddle.js"(exports) {
|
|
15318
15578
|
"use strict";
|
|
15319
15579
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15320
15580
|
exports.Defuddle = void 0;
|
|
@@ -15324,6 +15584,7 @@ var require_defuddle = __commonJS({
|
|
|
15324
15584
|
var standardize_1 = require_standardize();
|
|
15325
15585
|
var footnotes_1 = require_footnotes();
|
|
15326
15586
|
var callouts_1 = require_callouts();
|
|
15587
|
+
var images_1 = require_images();
|
|
15327
15588
|
var scoring_1 = require_scoring();
|
|
15328
15589
|
var small_images_1 = require_small_images();
|
|
15329
15590
|
var hidden_1 = require_hidden();
|
|
@@ -15333,6 +15594,18 @@ var require_defuddle = __commonJS({
|
|
|
15333
15594
|
var utils_1 = require_utils();
|
|
15334
15595
|
var dom_1 = require_dom();
|
|
15335
15596
|
var STANDARD_VARIABLE_KEYS = /* @__PURE__ */ new Set(["title", "author", "published", "site", "description", "image", "language"]);
|
|
15597
|
+
var IMAGE_SIZE_WORD = /^(?:large|medium|small|thumb|thumbnail|full|original|scaled|\d+x\d+|\d+x|[wh]\d+|\d+[wh])$/;
|
|
15598
|
+
function imageStem(src) {
|
|
15599
|
+
let path = src;
|
|
15600
|
+
try {
|
|
15601
|
+
const url = new URL(src, "https://example.invalid");
|
|
15602
|
+
const proxied = url.searchParams.get("url");
|
|
15603
|
+
path = proxied ? new URL(proxied, url).pathname : url.pathname;
|
|
15604
|
+
} catch {
|
|
15605
|
+
}
|
|
15606
|
+
const name = (path.split("/").pop() || "").toLowerCase().replace(/\.[a-z0-9]+$/, "");
|
|
15607
|
+
return name.split(/[-_.@]+/).filter((word) => word && !IMAGE_SIZE_WORD.test(word)).join("-");
|
|
15608
|
+
}
|
|
15336
15609
|
var Defuddle2 = class _Defuddle {
|
|
15337
15610
|
/**
|
|
15338
15611
|
* Create a new Defuddle instance
|
|
@@ -15343,7 +15616,7 @@ var require_defuddle = __commonJS({
|
|
|
15343
15616
|
this._parseErrors = /* @__PURE__ */ new Set();
|
|
15344
15617
|
this._schemaOrgData = void 0;
|
|
15345
15618
|
this._schemaOrgExtracted = false;
|
|
15346
|
-
this.
|
|
15619
|
+
this._pipelineExtractor = null;
|
|
15347
15620
|
this.doc = doc;
|
|
15348
15621
|
this.options = options;
|
|
15349
15622
|
this.debug = options.debug || false;
|
|
@@ -15377,12 +15650,9 @@ var require_defuddle = __commonJS({
|
|
|
15377
15650
|
}
|
|
15378
15651
|
_parseWithRetries() {
|
|
15379
15652
|
const startTime = Date.now();
|
|
15380
|
-
if (this.doc.body) {
|
|
15381
|
-
this._normalizeAttributes(this.doc.body);
|
|
15382
|
-
this._resolveNoscriptImages(this.doc.body);
|
|
15383
|
-
}
|
|
15384
15653
|
let result = this.parseInternal();
|
|
15385
|
-
|
|
15654
|
+
const fromExtractor = !!result?.extractorType;
|
|
15655
|
+
if (!fromExtractor && (result?.wordCount ?? 0) < 200) {
|
|
15386
15656
|
this._log("Initial parse returned very little content, trying again");
|
|
15387
15657
|
const retryResult = this.parseInternal({
|
|
15388
15658
|
removePartialSelectors: false
|
|
@@ -15392,7 +15662,7 @@ var require_defuddle = __commonJS({
|
|
|
15392
15662
|
result = retryResult;
|
|
15393
15663
|
}
|
|
15394
15664
|
}
|
|
15395
|
-
if ((result?.wordCount ?? 0) < 50) {
|
|
15665
|
+
if (!fromExtractor && (result?.wordCount ?? 0) < 50) {
|
|
15396
15666
|
this._log("Still very little content, retrying without hidden-element removal");
|
|
15397
15667
|
const hiddenRetry = this.parseInternal({
|
|
15398
15668
|
removeHiddenElements: false
|
|
@@ -15420,7 +15690,7 @@ var require_defuddle = __commonJS({
|
|
|
15420
15690
|
}
|
|
15421
15691
|
}
|
|
15422
15692
|
}
|
|
15423
|
-
if ((result?.wordCount ?? 0) < 50) {
|
|
15693
|
+
if (!fromExtractor && (result?.wordCount ?? 0) < 50) {
|
|
15424
15694
|
this._log("Still very little content, retrying without scoring/partial selectors (possible index page)");
|
|
15425
15695
|
const indexRetry = this.parseInternal({
|
|
15426
15696
|
removeLowScoring: false,
|
|
@@ -15438,13 +15708,14 @@ var require_defuddle = __commonJS({
|
|
|
15438
15708
|
try {
|
|
15439
15709
|
const safeDoc = liveDoc.cloneNode(true);
|
|
15440
15710
|
this._stripUnsafeElements(safeDoc.body);
|
|
15711
|
+
this._prepareImages(safeDoc.body);
|
|
15441
15712
|
this.doc = safeDoc;
|
|
15442
15713
|
const bestMatch = this._findElementBySchemaText(this.doc.body, schemaText);
|
|
15443
15714
|
if (bestMatch) {
|
|
15444
15715
|
const selector = this.getElementSelector(bestMatch);
|
|
15445
15716
|
this._log("Schema.org suggests a better content element, retrying with selector:", selector);
|
|
15446
15717
|
const schemaRetry = this.parseInternal({ contentSelector: selector });
|
|
15447
|
-
if (schemaRetry) {
|
|
15718
|
+
if (schemaRetry && (!result || schemaRetry.wordCount > result.wordCount)) {
|
|
15448
15719
|
result = schemaRetry;
|
|
15449
15720
|
}
|
|
15450
15721
|
} else {
|
|
@@ -15560,6 +15831,15 @@ var require_defuddle = __commonJS({
|
|
|
15560
15831
|
if (!this.doc.body)
|
|
15561
15832
|
return "";
|
|
15562
15833
|
const safeBody = this.doc.body.cloneNode(true);
|
|
15834
|
+
if (this.options.removeImages) {
|
|
15835
|
+
this.removeImages(safeBody);
|
|
15836
|
+
} else {
|
|
15837
|
+
try {
|
|
15838
|
+
this._prepareImages(safeBody);
|
|
15839
|
+
} catch (error) {
|
|
15840
|
+
this._recordError(error);
|
|
15841
|
+
}
|
|
15842
|
+
}
|
|
15563
15843
|
this._stripUnsafeElements(safeBody);
|
|
15564
15844
|
return this.resolveContentUrls((0, dom_1.serializeHTML)(safeBody));
|
|
15565
15845
|
}
|
|
@@ -15583,19 +15863,30 @@ var require_defuddle = __commonJS({
|
|
|
15583
15863
|
if (figImgs.length < 2)
|
|
15584
15864
|
continue;
|
|
15585
15865
|
const groups = /* @__PURE__ */ new Map();
|
|
15866
|
+
const unlabeled = /* @__PURE__ */ new Map();
|
|
15586
15867
|
for (const img of figImgs) {
|
|
15587
|
-
const src = img.getAttribute("src") || "";
|
|
15868
|
+
const src = img.getAttribute("src") || (0, images_1.extractLargestUrlFromSrcset)(img.getAttribute("srcset") || "") || "";
|
|
15588
15869
|
if (!src || src.startsWith("data:"))
|
|
15589
15870
|
continue;
|
|
15590
|
-
const
|
|
15591
|
-
const
|
|
15592
|
-
|
|
15593
|
-
|
|
15871
|
+
const alt = (img.getAttribute("alt") || "").trim();
|
|
15872
|
+
const stem = imageStem(src);
|
|
15873
|
+
const target = alt ? groups : unlabeled;
|
|
15874
|
+
const key = alt ? `${alt}
|
|
15875
|
+
${stem}` : stem;
|
|
15876
|
+
target.set(key, [...target.get(key) || [], img]);
|
|
15877
|
+
}
|
|
15878
|
+
for (const [stem, imgs2] of unlabeled) {
|
|
15879
|
+
const labeled = Array.from(groups.keys()).find((key) => key.endsWith(`
|
|
15880
|
+
${stem}`));
|
|
15881
|
+
if (labeled)
|
|
15882
|
+
groups.get(labeled).push(...imgs2);
|
|
15883
|
+
else
|
|
15884
|
+
groups.set(stem, imgs2);
|
|
15594
15885
|
}
|
|
15595
|
-
for (const
|
|
15886
|
+
for (const group of groups.values()) {
|
|
15596
15887
|
if (group.length < 2)
|
|
15597
15888
|
continue;
|
|
15598
|
-
if (
|
|
15889
|
+
if (group[0].getAttribute("alt")?.trim() && group.every((img) => img.getAttribute("src") === group[0].getAttribute("src")))
|
|
15599
15890
|
continue;
|
|
15600
15891
|
this._keepBestImage(group);
|
|
15601
15892
|
}
|
|
@@ -15654,7 +15945,13 @@ var require_defuddle = __commonJS({
|
|
|
15654
15945
|
let best = group[0];
|
|
15655
15946
|
for (let i = 1; i < group.length; i++) {
|
|
15656
15947
|
const winner = this._pickBestImage(best, group[i]);
|
|
15657
|
-
|
|
15948
|
+
const loser = winner === best ? group[i] : best;
|
|
15949
|
+
for (const attr of ["alt", "src"]) {
|
|
15950
|
+
const value = loser.getAttribute(attr)?.trim();
|
|
15951
|
+
if (value && !winner.getAttribute(attr)?.trim())
|
|
15952
|
+
winner.setAttribute(attr, value);
|
|
15953
|
+
}
|
|
15954
|
+
loser.remove();
|
|
15658
15955
|
best = winner;
|
|
15659
15956
|
}
|
|
15660
15957
|
}
|
|
@@ -15733,6 +16030,13 @@ var require_defuddle = __commonJS({
|
|
|
15733
16030
|
const m = src.match(_Defuddle._urlWidthPattern);
|
|
15734
16031
|
return m ? parseInt(m[1], 10) : 0;
|
|
15735
16032
|
}
|
|
16033
|
+
/** Runs on a copy: these fixes would reload images on the caller's live page. */
|
|
16034
|
+
_prepareImages(body) {
|
|
16035
|
+
if (!body)
|
|
16036
|
+
return;
|
|
16037
|
+
this._normalizeAttributes(body);
|
|
16038
|
+
this._resolveNoscriptImages(body);
|
|
16039
|
+
}
|
|
15736
16040
|
/**
|
|
15737
16041
|
* Rename non-standard HTML attributes to their canonical lowercase forms.
|
|
15738
16042
|
* React SSR outputs camelCase attributes like "srcSet" that some DOM
|
|
@@ -15762,7 +16066,7 @@ var require_defuddle = __commonJS({
|
|
|
15762
16066
|
}
|
|
15763
16067
|
if (!html.includes("<img"))
|
|
15764
16068
|
continue;
|
|
15765
|
-
const fragment = (0, dom_1.parseHTML)(
|
|
16069
|
+
const fragment = (0, dom_1.parseHTML)(body.ownerDocument, html);
|
|
15766
16070
|
noscriptImg = fragment.querySelector("img");
|
|
15767
16071
|
}
|
|
15768
16072
|
if (!noscriptImg)
|
|
@@ -15864,6 +16168,7 @@ var require_defuddle = __commonJS({
|
|
|
15864
16168
|
return void 0;
|
|
15865
16169
|
const doc = this.doc.cloneNode(true);
|
|
15866
16170
|
this.flattenShadowRoots(this.doc, doc);
|
|
16171
|
+
this._prepareImages(doc.body);
|
|
15867
16172
|
this.resolveStreamedContent(doc);
|
|
15868
16173
|
const body = doc.body;
|
|
15869
16174
|
if (!body)
|
|
@@ -16013,10 +16318,7 @@ var require_defuddle = __commonJS({
|
|
|
16013
16318
|
const schemaOrgData = this.getSchemaOrgData();
|
|
16014
16319
|
this._ensureMetadata();
|
|
16015
16320
|
const pageMetaTags = this._metaTags;
|
|
16016
|
-
const metadata = this._metadata;
|
|
16017
|
-
if (options.removeImages) {
|
|
16018
|
-
this.removeImages(this.doc);
|
|
16019
|
-
}
|
|
16321
|
+
const metadata = { ...this._metadata };
|
|
16020
16322
|
try {
|
|
16021
16323
|
const url = options.url || this.doc.URL;
|
|
16022
16324
|
const extractorOpts = {
|
|
@@ -16024,12 +16326,12 @@ var require_defuddle = __commonJS({
|
|
|
16024
16326
|
language: options.language,
|
|
16025
16327
|
fetch: options.fetch
|
|
16026
16328
|
};
|
|
16027
|
-
if (!this.
|
|
16329
|
+
if (!this._pipelineExtractor) {
|
|
16028
16330
|
const extractor = extractor_registry_1.ExtractorRegistry.findExtractor(this.doc, url, schemaOrgData, extractorOpts);
|
|
16029
16331
|
if (extractor && extractor.canExtract()) {
|
|
16030
16332
|
const extracted = extractor.extract();
|
|
16031
16333
|
if (extracted.contentSelector) {
|
|
16032
|
-
this.
|
|
16334
|
+
this._pipelineExtractor = extractor;
|
|
16033
16335
|
try {
|
|
16034
16336
|
const pipelineResult = this.parseInternal({
|
|
16035
16337
|
contentSelector: extracted.contentSelector,
|
|
@@ -16051,7 +16353,7 @@ var require_defuddle = __commonJS({
|
|
|
16051
16353
|
...variables ? { variables } : {}
|
|
16052
16354
|
};
|
|
16053
16355
|
} finally {
|
|
16054
|
-
this.
|
|
16356
|
+
this._pipelineExtractor = null;
|
|
16055
16357
|
}
|
|
16056
16358
|
}
|
|
16057
16359
|
return this.buildExtractorResponse(extracted, metadata, startTime, extractor, pageMetaTags);
|
|
@@ -16071,7 +16373,12 @@ var require_defuddle = __commonJS({
|
|
|
16071
16373
|
clone.body?.normalize();
|
|
16072
16374
|
});
|
|
16073
16375
|
profileStep("flattenShadowRoots", () => this.flattenShadowRoots(this.doc, clone));
|
|
16376
|
+
this._pipelineExtractor?.prepareDocument(clone);
|
|
16377
|
+
profileStep("prepareImages", () => this._prepareImages(clone.body));
|
|
16074
16378
|
profileStep("resolveStreamedContent", () => this.resolveStreamedContent(clone));
|
|
16379
|
+
if (options.removeImages) {
|
|
16380
|
+
this.removeImages(clone);
|
|
16381
|
+
}
|
|
16075
16382
|
profileStep("applyMobileStyles", () => this.applyMobileStyles(clone, mobileStyles));
|
|
16076
16383
|
const mainContent = profileStep("findMainContent", () => {
|
|
16077
16384
|
let found = null;
|
|
@@ -16272,11 +16579,8 @@ var require_defuddle = __commonJS({
|
|
|
16272
16579
|
}
|
|
16273
16580
|
});
|
|
16274
16581
|
}
|
|
16275
|
-
removeImages(
|
|
16276
|
-
|
|
16277
|
-
Array.from(images).forEach((image) => {
|
|
16278
|
-
image.remove();
|
|
16279
|
-
});
|
|
16582
|
+
removeImages(root) {
|
|
16583
|
+
root.querySelectorAll("img").forEach((image) => image.remove());
|
|
16280
16584
|
}
|
|
16281
16585
|
findMainContent(doc) {
|
|
16282
16586
|
const candidates = [];
|
|
@@ -16541,7 +16845,6 @@ var require_defuddle = __commonJS({
|
|
|
16541
16845
|
if (!cloneEl)
|
|
16542
16846
|
continue;
|
|
16543
16847
|
shadowData.push({ cloneEl, html: shadowHtml });
|
|
16544
|
-
origEl.removeAttribute("data-defuddle-shadow");
|
|
16545
16848
|
cloneEl.removeAttribute("data-defuddle-shadow");
|
|
16546
16849
|
}
|
|
16547
16850
|
for (const { cloneEl, html } of shadowData) {
|
|
@@ -16739,6 +17042,9 @@ var require_defuddle = __commonJS({
|
|
|
16739
17042
|
return html;
|
|
16740
17043
|
const container = this.doc.createElement("div");
|
|
16741
17044
|
container.appendChild((0, dom_1.parseHTML)(this.doc, html));
|
|
17045
|
+
if (this.options.removeImages) {
|
|
17046
|
+
this.removeImages(container);
|
|
17047
|
+
}
|
|
16742
17048
|
this._stripUnsafeElements(container);
|
|
16743
17049
|
this.resolveRelativeUrls(container);
|
|
16744
17050
|
(0, standardize_1.standardizeExtractorOutput)(container, this.debug);
|
|
@@ -16767,9 +17073,63 @@ var require_defuddle = __commonJS({
|
|
|
16767
17073
|
}
|
|
16768
17074
|
});
|
|
16769
17075
|
|
|
16770
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
17076
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/code-fences.js
|
|
17077
|
+
var require_code_fences = __commonJS({
|
|
17078
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/code-fences.js"(exports) {
|
|
17079
|
+
"use strict";
|
|
17080
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17081
|
+
exports.fencedLines = fencedLines;
|
|
17082
|
+
exports.transformOutsideCodeFences = transformOutsideCodeFences;
|
|
17083
|
+
var FENCE_LINE = /^(?:[ \t]*>)*[ \t]*(`{3,}|~{3,})(.*)$/;
|
|
17084
|
+
function fencedLines(lines) {
|
|
17085
|
+
let openFence = null;
|
|
17086
|
+
return lines.map((line) => {
|
|
17087
|
+
const match = line.match(FENCE_LINE);
|
|
17088
|
+
if (openFence === null) {
|
|
17089
|
+
if (match && !(match[1][0] === "`" && match[2].includes("`"))) {
|
|
17090
|
+
openFence = match[1];
|
|
17091
|
+
}
|
|
17092
|
+
return openFence !== null;
|
|
17093
|
+
}
|
|
17094
|
+
if (match && match[1][0] === openFence[0] && match[1].length >= openFence.length && !match[2].trim()) {
|
|
17095
|
+
openFence = null;
|
|
17096
|
+
}
|
|
17097
|
+
return true;
|
|
17098
|
+
});
|
|
17099
|
+
}
|
|
17100
|
+
function transformOutsideCodeFences(markdown, transform) {
|
|
17101
|
+
const lines = markdown.split("\n");
|
|
17102
|
+
const inFence = fencedLines(lines);
|
|
17103
|
+
if (!inFence.includes(true))
|
|
17104
|
+
return transform(markdown);
|
|
17105
|
+
let marker = "\uE000";
|
|
17106
|
+
while (markdown.includes(marker))
|
|
17107
|
+
marker += "\uE000";
|
|
17108
|
+
const blocks = [];
|
|
17109
|
+
const outside = [];
|
|
17110
|
+
for (let i = 0; i < lines.length; i++) {
|
|
17111
|
+
if (!inFence[i]) {
|
|
17112
|
+
outside.push(lines[i]);
|
|
17113
|
+
continue;
|
|
17114
|
+
}
|
|
17115
|
+
const start = i;
|
|
17116
|
+
while (i + 1 < lines.length && inFence[i + 1])
|
|
17117
|
+
i++;
|
|
17118
|
+
outside.push(`${marker}${blocks.length}${marker}`);
|
|
17119
|
+
blocks.push(lines.slice(start, i + 1).join("\n"));
|
|
17120
|
+
}
|
|
17121
|
+
const placeholder = new RegExp(`^${marker}(\\d+)${marker}$`);
|
|
17122
|
+
return transform(outside.join("\n")).split("\n").map((line) => {
|
|
17123
|
+
const match = line.match(placeholder);
|
|
17124
|
+
return match ? blocks[Number(match[1])] : line;
|
|
17125
|
+
}).join("\n");
|
|
17126
|
+
}
|
|
17127
|
+
}
|
|
17128
|
+
});
|
|
17129
|
+
|
|
17130
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/markdown.js
|
|
16771
17131
|
var require_markdown = __commonJS({
|
|
16772
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
17132
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/markdown.js"(exports) {
|
|
16773
17133
|
"use strict";
|
|
16774
17134
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
16775
17135
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
@@ -16782,12 +17142,31 @@ var require_markdown = __commonJS({
|
|
|
16782
17142
|
var turndown_1 = __importDefault(__require("turndown"));
|
|
16783
17143
|
var utils_1 = require_utils();
|
|
16784
17144
|
var dom_1 = require_dom();
|
|
17145
|
+
var code_fences_1 = require_code_fences();
|
|
16785
17146
|
function isGenericElement(node) {
|
|
16786
17147
|
return node !== null && typeof node === "object" && "getAttribute" in node;
|
|
16787
17148
|
}
|
|
16788
17149
|
function asGenericElement(node) {
|
|
16789
17150
|
return node;
|
|
16790
17151
|
}
|
|
17152
|
+
function getLeadingCheckbox(li) {
|
|
17153
|
+
let parent = li;
|
|
17154
|
+
for (let depth = 0; depth < 2; depth++) {
|
|
17155
|
+
const first = Array.from(parent.childNodes || []).find((child) => !((0, utils_1.isTextNode)(child) && !(child.textContent || "").trim()));
|
|
17156
|
+
if (!first || !(0, utils_1.isElement)(first))
|
|
17157
|
+
return null;
|
|
17158
|
+
const el = asGenericElement(first);
|
|
17159
|
+
if (el.nodeName === "INPUT") {
|
|
17160
|
+
return (el.getAttribute("type") || "").toLowerCase() === "checkbox" ? el : null;
|
|
17161
|
+
}
|
|
17162
|
+
if (el.nodeName !== "P")
|
|
17163
|
+
return null;
|
|
17164
|
+
parent = el;
|
|
17165
|
+
}
|
|
17166
|
+
return null;
|
|
17167
|
+
}
|
|
17168
|
+
var LIST_MARKER_RE = /^\s*(?:[-*+]|\d+[.)])\s/;
|
|
17169
|
+
var CELL_ONE_LINE_RE = /```[\s\S]*?```|\$\$[\s\S]*?\$\$|\$(?=\S)(?:[^$]*?\S)?\$(?!\d)/g;
|
|
16791
17170
|
var WIDTH_DESCRIPTOR_RE = /^(\d+)w,?$/;
|
|
16792
17171
|
var DENSITY_DESCRIPTOR_RE = /^\d+(?:\.\d+)?x,?$/;
|
|
16793
17172
|
var MATHML_NODE_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -16904,6 +17283,13 @@ $$
|
|
|
16904
17283
|
})
|
|
16905
17284
|
`;
|
|
16906
17285
|
}
|
|
17286
|
+
function getImageLinkHref(img, figure) {
|
|
17287
|
+
for (let parent = img.parentNode; parent && parent !== figure; parent = parent.parentNode) {
|
|
17288
|
+
if (parent.nodeName === "A")
|
|
17289
|
+
return parent.getAttribute("href") || "";
|
|
17290
|
+
}
|
|
17291
|
+
return "";
|
|
17292
|
+
}
|
|
16907
17293
|
function getBestImageSrc(node) {
|
|
16908
17294
|
const srcset = node.getAttribute("srcset");
|
|
16909
17295
|
if (srcset) {
|
|
@@ -17009,12 +17395,17 @@ $$
|
|
|
17009
17395
|
}
|
|
17010
17396
|
const hasNestedTables = Array.from(node.querySelectorAll("table")).some((t) => t !== node);
|
|
17011
17397
|
const directCells = Array.from(node.querySelectorAll("td, th")).filter((el) => (0, dom_1.isDirectTableChild)(el, node));
|
|
17398
|
+
const captionElement = Array.from(node.childNodes || []).find((child) => child.nodeName === "CAPTION");
|
|
17399
|
+
const caption = captionElement ? turndownService.turndown((0, dom_1.serializeHTML)(asGenericElement(captionElement))).trim() : "";
|
|
17400
|
+
const captionPrefix = caption ? `${caption}
|
|
17401
|
+
|
|
17402
|
+
` : "";
|
|
17012
17403
|
if (hasNestedTables || directCells.length <= 1) {
|
|
17013
17404
|
const directRows = Array.from(node.querySelectorAll("tr")).filter((el) => (0, dom_1.isDirectTableChild)(el, node));
|
|
17014
17405
|
const cellCounts = directRows.map((tr) => directCells.filter((cell) => cell.parentNode === tr).length);
|
|
17015
17406
|
const isSingleColumn = directRows.length > 0 && new Set(cellCounts).size === 1 && cellCounts[0] <= 1;
|
|
17016
17407
|
if (isSingleColumn || hasNestedTables) {
|
|
17017
|
-
return "\n\n" + turndownService.turndown(directCells.map((cell) => (0, dom_1.serializeHTML)(cell)).join("")) + "\n\n";
|
|
17408
|
+
return "\n\n" + captionPrefix + turndownService.turndown(directCells.map((cell) => (0, dom_1.serializeHTML)(cell)).join("")) + "\n\n";
|
|
17018
17409
|
}
|
|
17019
17410
|
}
|
|
17020
17411
|
const cells = Array.from(node.querySelectorAll("td, th"));
|
|
@@ -17028,7 +17419,7 @@ $$
|
|
|
17028
17419
|
const rows = rowElements.map((row) => {
|
|
17029
17420
|
const cellElements = row.cells && row.cells.length > 0 ? Array.from(row.cells) : Array.from(row.querySelectorAll("td, th")).filter((cell) => cell.parentNode === row);
|
|
17030
17421
|
return cellElements.map((cell) => {
|
|
17031
|
-
let cellContent = turndownService.turndown((0, dom_1.serializeHTML)(cell)).replace(/\n
|
|
17422
|
+
let cellContent = turndownService.turndown((0, dom_1.serializeHTML)(cell)).replace(CELL_ONE_LINE_RE, (segment) => segment.replace(/\s*\n\s*/g, " ")).split(/\n+/).map((line) => line.trim()).filter(Boolean).join("<br>");
|
|
17032
17423
|
cellContent = cellContent.replace(/\|/g, "\\|");
|
|
17033
17424
|
return cellContent;
|
|
17034
17425
|
});
|
|
@@ -17050,7 +17441,7 @@ $$
|
|
|
17050
17441
|
].join("\n");
|
|
17051
17442
|
return `
|
|
17052
17443
|
|
|
17053
|
-
${tableContent}
|
|
17444
|
+
${captionPrefix}${tableContent}
|
|
17054
17445
|
|
|
17055
17446
|
`;
|
|
17056
17447
|
}
|
|
@@ -17066,8 +17457,12 @@ ${tableContent}
|
|
|
17066
17457
|
replacement: function(content2, node) {
|
|
17067
17458
|
content2 = content2.trim();
|
|
17068
17459
|
const element = node;
|
|
17069
|
-
const
|
|
17070
|
-
|
|
17460
|
+
const parent = element.parentNode;
|
|
17461
|
+
const isMalformedNestedInList = !!parent && (parent.nodeName === "UL" || parent.nodeName === "OL");
|
|
17462
|
+
if (isMalformedNestedInList) {
|
|
17463
|
+
return content2.split("\n").map((line) => line && " " + line).join("\n") + "\n";
|
|
17464
|
+
}
|
|
17465
|
+
return "\n" + content2 + "\n";
|
|
17071
17466
|
}
|
|
17072
17467
|
});
|
|
17073
17468
|
turndownService.addRule("listItem", {
|
|
@@ -17075,28 +17470,23 @@ ${tableContent}
|
|
|
17075
17470
|
replacement: function(content2, node, options) {
|
|
17076
17471
|
if (!isGenericElement(node))
|
|
17077
17472
|
return content2;
|
|
17078
|
-
const
|
|
17079
|
-
const checkbox = node.querySelector('input[type="checkbox"]');
|
|
17473
|
+
const checkbox = getLeadingCheckbox(node);
|
|
17080
17474
|
let taskListMarker = "";
|
|
17081
|
-
if (
|
|
17475
|
+
if (checkbox) {
|
|
17082
17476
|
content2 = content2.replace(/<input[^>]*>/, "");
|
|
17083
|
-
taskListMarker = checkbox.
|
|
17084
|
-
}
|
|
17085
|
-
|
|
17477
|
+
taskListMarker = checkbox.hasAttribute("checked") ? "[x] " : "[ ] ";
|
|
17478
|
+
}
|
|
17479
|
+
const lines = content2.replace(/\n+$/, "").split("\n");
|
|
17480
|
+
const inFence = (0, code_fences_1.fencedLines)(lines);
|
|
17481
|
+
content2 = lines.map((line, i) => {
|
|
17482
|
+
if (line.length > 0 || inFence[i])
|
|
17483
|
+
return i === 0 ? line : " " + line;
|
|
17484
|
+
const next = lines.slice(i + 1).find((l) => l.length > 0);
|
|
17485
|
+
const separatesBlocks = lines[i - 1] && next && !LIST_MARKER_RE.test(next);
|
|
17486
|
+
return separatesBlocks ? "" : null;
|
|
17487
|
+
}).filter((line) => line !== null).join("\n");
|
|
17086
17488
|
let prefix = options.bulletListMarker + " ";
|
|
17087
17489
|
let parent = node.parentNode;
|
|
17088
|
-
let level = 0;
|
|
17089
|
-
let currentParent = node.parentNode;
|
|
17090
|
-
while (currentParent && isGenericElement(currentParent)) {
|
|
17091
|
-
if (currentParent.nodeName === "UL" || currentParent.nodeName === "OL") {
|
|
17092
|
-
level++;
|
|
17093
|
-
} else if (currentParent.nodeName !== "LI") {
|
|
17094
|
-
break;
|
|
17095
|
-
}
|
|
17096
|
-
currentParent = currentParent.parentNode;
|
|
17097
|
-
}
|
|
17098
|
-
const indentLevel = Math.max(0, level - 1);
|
|
17099
|
-
prefix = " ".repeat(indentLevel) + prefix;
|
|
17100
17490
|
if (parent && isGenericElement(parent) && parent.nodeName === "OL") {
|
|
17101
17491
|
let start = parent.getAttribute("start");
|
|
17102
17492
|
let index = 1;
|
|
@@ -17107,7 +17497,7 @@ ${tableContent}
|
|
|
17107
17497
|
break;
|
|
17108
17498
|
}
|
|
17109
17499
|
}
|
|
17110
|
-
prefix =
|
|
17500
|
+
prefix = (start ? Number(start) + index - 1 : index) + ". ";
|
|
17111
17501
|
}
|
|
17112
17502
|
return prefix + taskListMarker + content2.trim() + (node.nextSibling && !/\n$/.test(content2) ? "\n" : "");
|
|
17113
17503
|
}
|
|
@@ -17117,9 +17507,11 @@ ${tableContent}
|
|
|
17117
17507
|
replacement: function(content2, node) {
|
|
17118
17508
|
if (!isGenericElement(node))
|
|
17119
17509
|
return content2;
|
|
17120
|
-
|
|
17510
|
+
if (node.querySelector("figure"))
|
|
17511
|
+
return content2;
|
|
17512
|
+
const images = Array.from(node.querySelectorAll("img")).map(asGenericElement);
|
|
17121
17513
|
const figcaption = node.querySelector("figcaption");
|
|
17122
|
-
if (
|
|
17514
|
+
if (images.length === 0)
|
|
17123
17515
|
return content2;
|
|
17124
17516
|
const hasParagraphsOutsideFigcaption = Array.from(node.querySelectorAll("p")).some((p) => {
|
|
17125
17517
|
let ancestor = asGenericElement(p).parentNode;
|
|
@@ -17132,8 +17524,14 @@ ${tableContent}
|
|
|
17132
17524
|
});
|
|
17133
17525
|
if (hasParagraphsOutsideFigcaption)
|
|
17134
17526
|
return content2;
|
|
17135
|
-
const
|
|
17136
|
-
|
|
17527
|
+
const imageMarkdown = images.map((img) => {
|
|
17528
|
+
const alt = escapeInlineText(img.getAttribute("alt") || "");
|
|
17529
|
+
const src = formatMarkdownLinkDestination(getBestImageSrc(img));
|
|
17530
|
+
if (!src)
|
|
17531
|
+
return alt;
|
|
17532
|
+
const href = getImageLinkHref(img, node);
|
|
17533
|
+
return href ? `[](${formatMarkdownLinkDestination(href)})` : ``;
|
|
17534
|
+
}).filter(Boolean).join("\n\n");
|
|
17137
17535
|
let caption = "";
|
|
17138
17536
|
if (figcaption && isGenericElement(figcaption)) {
|
|
17139
17537
|
const tagSpan = figcaption.querySelector(".ltx_tag_figure");
|
|
@@ -17141,7 +17539,7 @@ ${tableContent}
|
|
|
17141
17539
|
const captionMarkdown = turndownService.turndown((0, dom_1.serializeHTML)(figcaption));
|
|
17142
17540
|
caption = `${escapeInlineText(tagText || "")} ${captionMarkdown}`.trim();
|
|
17143
17541
|
}
|
|
17144
|
-
return `${
|
|
17542
|
+
return `${imageMarkdown}
|
|
17145
17543
|
|
|
17146
17544
|
${caption}
|
|
17147
17545
|
|
|
@@ -17562,10 +17960,7 @@ ${latex}
|
|
|
17562
17960
|
if (titleMatch) {
|
|
17563
17961
|
markdown = markdown.slice(titleMatch[0].length);
|
|
17564
17962
|
}
|
|
17565
|
-
markdown = markdown.replace(
|
|
17566
|
-
markdown = markdown.replace(/!(?=!\[|\[!\[)/g, "! ");
|
|
17567
|
-
markdown = markdown.replace(/\n{3,}/g, "\n\n");
|
|
17568
|
-
markdown = markdown.replace(BLANK_QUOTE_LINE_RUN, "$1");
|
|
17963
|
+
markdown = (0, code_fences_1.transformOutsideCodeFences)(markdown, (text) => text.replace(/^[ \t]*(?<!!)\[]\([^)]+\)[ \t]*\n/gm, "").replace(/(?<!!)\[]\([^)]+\)/g, "").replace(/!(?=!\[|\[!\[)/g, "! ").replace(/\n{3,}/g, "\n\n").replace(BLANK_QUOTE_LINE_RUN, "$1"));
|
|
17569
17964
|
return markdown.trim();
|
|
17570
17965
|
} catch (error) {
|
|
17571
17966
|
console.error("Error converting HTML to Markdown:", error);
|
|
@@ -17588,9 +17983,9 @@ ${fence}`;
|
|
|
17588
17983
|
}
|
|
17589
17984
|
});
|
|
17590
17985
|
|
|
17591
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
17986
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/linkedom-compat.js
|
|
17592
17987
|
var require_linkedom_compat = __commonJS({
|
|
17593
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
17988
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/utils/linkedom-compat.js"(exports) {
|
|
17594
17989
|
"use strict";
|
|
17595
17990
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17596
17991
|
exports.parseLinkedomHTML = parseLinkedomHTML;
|
|
@@ -17610,9 +18005,9 @@ var require_linkedom_compat = __commonJS({
|
|
|
17610
18005
|
}
|
|
17611
18006
|
});
|
|
17612
18007
|
|
|
17613
|
-
// ../../node_modules/.pnpm/defuddle@0.19.
|
|
18008
|
+
// ../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/node.js
|
|
17614
18009
|
var require_node = __commonJS({
|
|
17615
|
-
"../../node_modules/.pnpm/defuddle@0.19.
|
|
18010
|
+
"../../node_modules/.pnpm/defuddle@0.19.13_patch_hash=7715105642bea628d8fd98cbb9bf22ef69e85e5e17d0d6dcefb0c0cc95fb762f/node_modules/defuddle/dist/node.js"(exports) {
|
|
17616
18011
|
"use strict";
|
|
17617
18012
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
17618
18013
|
if (k2 === void 0) k2 = k;
|
|
@@ -18245,7 +18640,7 @@ import { pipeline } from "node:stream/promises";
|
|
|
18245
18640
|
var VIDEO_EXT = /\.(mp4|m4v|mov|webm)$/i;
|
|
18246
18641
|
var AUDIO_EXT = /\.(mp3|m4a|aac|wav|ogg|oga|opus|flac)$/i;
|
|
18247
18642
|
var FILE_EXT = /\.(png|jpe?g|gif|webp|avif|bmp|svg|pdf|zip|rar|7z|gz|apk|dmg|exe|m3u8)$/i;
|
|
18248
|
-
var MEDIA_CDN_HOST = /(^|\.)([a-z0-9-]+-video|sns-video[a-z0-9-]*)\.xhscdn\.com$/i;
|
|
18643
|
+
var MEDIA_CDN_HOST = /(^|\.)(?:(?:[a-z0-9-]+-video|sns-video[a-z0-9-]*)\.xhscdn\.com|toutiaovod\.com)$/i;
|
|
18249
18644
|
var DIRECT_MEDIA_HEADER_TIMEOUT_MS = 15e3;
|
|
18250
18645
|
var DIRECT_MEDIA_STALL_TIMEOUT_MS = 3e4;
|
|
18251
18646
|
function detectDirectLink(url) {
|
|
@@ -18260,9 +18655,15 @@ function detectDirectLink(url) {
|
|
|
18260
18655
|
if (VIDEO_EXT.test(path)) return "video";
|
|
18261
18656
|
if (AUDIO_EXT.test(path) || /\/redirect\.mp3\//i.test(path)) return "audio";
|
|
18262
18657
|
if (FILE_EXT.test(path)) return "file";
|
|
18263
|
-
if (MEDIA_CDN_HOST.test(parsed.hostname))
|
|
18658
|
+
if (isVideoMimeQuery(parsed) || /\/video\/tos\//i.test(path) || MEDIA_CDN_HOST.test(parsed.hostname)) {
|
|
18659
|
+
return "video";
|
|
18660
|
+
}
|
|
18264
18661
|
return null;
|
|
18265
18662
|
}
|
|
18663
|
+
function isVideoMimeQuery(url) {
|
|
18664
|
+
const mime = url.searchParams.get("mime_type") ?? url.searchParams.get("mimeType") ?? "";
|
|
18665
|
+
return /^(?:video[/_]|video$)/i.test(mime);
|
|
18666
|
+
}
|
|
18266
18667
|
async function fetchDirectMedia(input) {
|
|
18267
18668
|
const fetcher = input.fetcher ?? fetch;
|
|
18268
18669
|
const headerTimeoutMs = input.headerTimeoutMs ?? DIRECT_MEDIA_HEADER_TIMEOUT_MS;
|
|
@@ -20023,6 +20424,7 @@ function applyWebSiteFixups(metadata, input) {
|
|
|
20023
20424
|
if (/^(?:www\.|m\.)?douban\.com$/i.test(host) && /^\/topic\/\d+/.test(path)) return fixDoubanTopicPost(metadata, bodyMarkdown);
|
|
20024
20425
|
if (/^ima\.qq\.com$/i.test(host) && path.startsWith("/share")) return { bodyMarkdown: stripImaShareChrome(bodyMarkdown), metadata };
|
|
20025
20426
|
if (/^share\.dinox\.info$/i.test(host) && /^\/s\//.test(path)) return { bodyMarkdown: stripDinoxShareChrome(bodyMarkdown), metadata };
|
|
20427
|
+
if (/(^|\.)peopleapp\.com$/i.test(host)) return { bodyMarkdown: stripPeopleappChrome(bodyMarkdown), metadata };
|
|
20026
20428
|
return { bodyMarkdown, metadata };
|
|
20027
20429
|
}
|
|
20028
20430
|
var REDDIT_HEADER_RE = /^(?:\[(?:转到|Go to)\s*[“"]?(?:r\/)?[\w-]+[”"]?\]\(https?:\/\/(?:www\.)?reddit\.com\/r\/[^)\s]+\)|\[r\/[\w-]+\]\(https?:\/\/(?:www\.)?reddit\.com\/r\/[^)\s]+\)|\[u\/[\w-]+\]\(https?:\/\/(?:www\.)?reddit\.com\/user\/[^)\s]+\)|(?:\d+\s*(?:秒|分钟|小时|天|周|个月|年)前|\d+\s*(?:sec|min|hr|day|mo|yr)s?\.?\s*ago|just now|刚刚))$/i;
|
|
@@ -20332,6 +20734,29 @@ function stripSmzdmTrailer(bodyMarkdown) {
|
|
|
20332
20734
|
}
|
|
20333
20735
|
return changed ? paragraphs.join("\n\n") : bodyMarkdown;
|
|
20334
20736
|
}
|
|
20737
|
+
var PEOPLEAPP_VIEW_ORIGINAL_RE = /^点击查看原图$/;
|
|
20738
|
+
var PEOPLEAPP_VIEW_ORIGINAL_PREFIX_RE = /^点击查看原图\s+(?=!\[[^\]]*\]\()/;
|
|
20739
|
+
var PEOPLEAPP_COMMENT_CTA_RE = /^打开客户端发表评论$/;
|
|
20740
|
+
function stripPeopleappChrome(bodyMarkdown) {
|
|
20741
|
+
const paragraphs = splitParagraphs(bodyMarkdown);
|
|
20742
|
+
const kept = [];
|
|
20743
|
+
let changed = false;
|
|
20744
|
+
for (const paragraph of paragraphs) {
|
|
20745
|
+
const text = paragraph.trim();
|
|
20746
|
+
if (PEOPLEAPP_VIEW_ORIGINAL_RE.test(text) || PEOPLEAPP_COMMENT_CTA_RE.test(text)) {
|
|
20747
|
+
changed = true;
|
|
20748
|
+
continue;
|
|
20749
|
+
}
|
|
20750
|
+
const stripped = text.replace(PEOPLEAPP_VIEW_ORIGINAL_PREFIX_RE, "");
|
|
20751
|
+
if (stripped !== text) {
|
|
20752
|
+
changed = true;
|
|
20753
|
+
if (stripped) kept.push(stripped);
|
|
20754
|
+
continue;
|
|
20755
|
+
}
|
|
20756
|
+
kept.push(paragraph);
|
|
20757
|
+
}
|
|
20758
|
+
return changed ? kept.join("\n\n") : bodyMarkdown;
|
|
20759
|
+
}
|
|
20335
20760
|
function splitParagraphs(markdown) {
|
|
20336
20761
|
return markdown.trim().split(/\n[ \t]*\n+/).filter((paragraph) => paragraph.trim());
|
|
20337
20762
|
}
|