@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.
Files changed (2) hide show
  1. package/lib/index.js +12 -6
  2. 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
- for (; ; ) {
464
+ while (out.length > 0) {
465
465
  const next = out.replace(TRIM_RIGHT, "");
466
- const last = next[next.length - 1];
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
- if (next === out) return next;
472
- out = next;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a9i5k4/dsh-literature",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "DSH Literature 文献侧窗:在 DeepSeek Harness 侧边栏识别 DOI/arXiv/标题、抓取元数据与全文、写入本地文献库或导出目录,并提供内置 PDF 阅读器(缩放/翻页/目录/搜索/高亮/笔记)。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",