Repository navigation
fix(pdf): 伪空格切碎修复 + 扫描件 PDF_NO_TEXT_RUNS 警告 - #224
Conversation
…view gradient buttons Landing: - bump hero eyebrow v2.3 -> v2.4 to match package version - tighten hero vertical rhythm; split subtitle into nowrap phrases to drop the single-character orphan line - gate .reveal-on-scroll behind a .reveal-armed class so content stays visible when JS/observer/print contexts never trigger intersection - hover feedback for feature cards, format rows, workflow steps; CTA section gets a brand gradient bar Workbench (styles.css only): - dashed centered empty states, tab active indicator, focus-visible rings - gradient progress bar with tabular-nums percentage - stronger pane elevation, press feedback on ghost/mini/menu buttons Preview (preview.css): - explicit brand-gradient primary button rules for dark topbar context (fixes unified-button-test baseline failure: token now used 3x) Chore: add npm run dev script alongside existing start script Tests: design-token, ui-accessibility, ui-button-consistency (12/12), unified-button, smoke (60 groups), browser-smoke, ui-conversion-e2e, server-hardening all pass.
- item 拼接层空格阈值从 0.12em 提到 0.22em(近似真实空格宽度 0.25em),加字距 排版字形间隙不再被当成词间空格("E x p a n d e d" 式碎词) - pdf.js addFakeSpaces 伪空格的收拢:连续 ≥3 个单字 CJK 链去空格("加 字 距 版" →"加字距版"),多字词间对齐空格保留;拉丁碎词词边界在 pdf.js 合并 item 时已 丢失,保留原样并注明上游限制 - 回归断言:加字距字形链不拆词、CJK 伪空格收拢、多字词空格保留 Refs #216
When pdf.js parses pages successfully but extracts zero text runs, the document is almost certainly a scanned/image-only PDF. Previously this fell into the generic PDF_NO_CREDIBLE_TEXT path, misleading users into thinking the file was unreadable binary noise. - add pdfJsParsedButTextless detection in readPdf fallback branch - emit PDF_NO_TEXT_RUNS (severity: unsupported) with pageCount, pagesWithoutText and ocrRecommended: true in details - mark metadata.pdf.extraction as "pdfjs-no-text" and fill pagesWithoutText with all page numbers (also fixes unresolvedPdfPages under-reporting when OCR partially fails on full-scan documents) - encrypted / GID-noise / binary-noise paths unchanged Verified with real-world scanned homework PDF (2 pages, no text layer): warning fires correctly and OCR conversion produces usable text.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d942437b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export function collapseCjkFakeSpaces(text) { | ||
| const run = new RegExp(`(?:[${CJK_CHAR_CLASS}] ){2,}[${CJK_CHAR_CLASS}]`, "g"); | ||
| return String(text).replace(run, (match) => match.replaceAll(" ", "")); |
There was a problem hiding this comment.
Preserve intentional spaces in CJK text runs
collapseCjkFakeSpaces is applied to every PDF.js text item, but item.str can contain literal spaces from the document as well as spaces synthesized by PDF.js. Consequently, intentionally spaced content such as 我 爱 中 国 or spaced names/headings is silently rewritten to 我爱中国 during every PDF-to-text conversion. The collapse needs evidence that the spaces were synthesized (for example, glyph-position/width analysis) rather than treating every run of three single CJK characters as fake spacing.
Useful? React with 👍 / 👎.
概述
两个 PDF 文本抽取修复:
fix: stop fake spaces from shredding letter-spaced PDF text(已有提交)——收拢 PDF 中的伪空格,修复加字距拉丁文本被切碎的问题fix(pdf): distinguish scanned PDFs with PDF_NO_TEXT_RUNS warning——pdf.js 成功解析页面但零文本 run 时(典型扫描件/图片型 PDF),不再落入笼统的PDF_NO_CREDIBLE_TEXT("二进制噪声"文案对扫描件是误导),改为:pdfJsParsedButTextless判定PDF_NO_TEXT_RUNSwarning(severity: unsupported),details 携带{ pageCount, pagesWithoutText, ocrRecommended: true }metadata.pdf.extraction标记为"pdfjs-no-text",pagesWithoutText填入全部页号(顺带修正全扫描件 OCR 部分失败时unresolvedPdfPages漏报)验证
关联
UI 侧对
PDF_NO_TEXT_RUNS的展示接线在 #223 的 app.js 中(缺本分支时优雅降级为原通用提示)。