@a9i5k4/dsh-literature 0.3.2 → 0.3.3
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/lib/index.js +12 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -461,16 +461,21 @@ var init_sse = __esm({
|
|
|
461
461
|
// src/node/extract/identifiers.js
|
|
462
462
|
function trimRight(s) {
|
|
463
463
|
let out = s;
|
|
464
|
-
|
|
464
|
+
while (out.length > 0) {
|
|
465
465
|
const next = out.replace(TRIM_RIGHT, "");
|
|
466
|
-
|
|
467
|
-
if ((last === ")" || last === "]" || last === "}" || last === "\uFF09" || last === "\u3011") && !next.slice(0, -1).includes(last === ")" ? "(" : last === "]" ? "[" : last === "}" ? "{" : last === "\uFF09" ? "\uFF08" : "\u3010")) {
|
|
466
|
+
if (next !== out) {
|
|
468
467
|
out = next;
|
|
469
468
|
continue;
|
|
470
469
|
}
|
|
471
|
-
|
|
472
|
-
|
|
470
|
+
const last = out[out.length - 1];
|
|
471
|
+
const openFor = CLOSE_TO_OPEN[last];
|
|
472
|
+
if (openFor && !out.slice(0, -1).includes(openFor)) {
|
|
473
|
+
out = out.slice(0, -1);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
return out;
|
|
473
477
|
}
|
|
478
|
+
return out;
|
|
474
479
|
}
|
|
475
480
|
function push(list, seen, entry) {
|
|
476
481
|
const dedupeKey = `${entry.kind}:${entry.value.toLowerCase()}`;
|
|
@@ -582,11 +587,12 @@ function extractIdentifiers(text, options = {}) {
|
|
|
582
587
|
}
|
|
583
588
|
return out.sort((a, b) => a.index - b.index);
|
|
584
589
|
}
|
|
585
|
-
var TRIM_RIGHT, CJK_PUNCT, DOI_TAIL, DOI_CORE, DOI_HINT, DOI_LABEL, ARXIV_NEW, ARXIV_OLD, URL_RE, ARXIV_URL, PMID, ISBN, QUOTED, QUOTED_FALLBACK;
|
|
590
|
+
var TRIM_RIGHT, CJK_PUNCT, CLOSE_TO_OPEN, DOI_TAIL, DOI_CORE, DOI_HINT, DOI_LABEL, ARXIV_NEW, ARXIV_OLD, URL_RE, ARXIV_URL, PMID, ISBN, QUOTED, QUOTED_FALLBACK;
|
|
586
591
|
var init_identifiers = __esm({
|
|
587
592
|
"src/node/extract/identifiers.js"() {
|
|
588
593
|
TRIM_RIGHT = /[.,;:!?。、,;:!?…—>'">)》\]]+$/;
|
|
589
594
|
CJK_PUNCT = "\u3002\u3001\uFF0C\uFF1B\uFF1A\uFF01\uFF1F\uFF08\uFF09\u3010\u3011\u300A\u300B\u3008\u3009\u2026\u2014\uFF5E\xB7";
|
|
595
|
+
CLOSE_TO_OPEN = { ")": "(", "]": "[", "}": "{", "\uFF09": "\uFF08", "\u3011": "\u3010" };
|
|
590
596
|
DOI_TAIL = `[^\\s"'<>\`|${CJK_PUNCT}]+`;
|
|
591
597
|
DOI_CORE = new RegExp(`10\\.\\d{4,9}\\/${DOI_TAIL}`, "gi");
|
|
592
598
|
DOI_HINT = new RegExp(`(?:https?:\\/\\/)?(?:dx\\.)?doi\\.org\\/(10\\.\\d{4,9}\\/${DOI_TAIL})`, "gi");
|
package/package.json
CHANGED