Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WYCleaner — macOS PDF Text Cleaner / 剪贴板文本清理工具

A lightweight macOS menu bar tool that cleans messy text copied from PDFs. Select any text, press ⌥C, and it automatically copies → cleans → writes back to the clipboard — removing citation marks, fixing broken line breaks, normalizing full-width/half-width punctuation, and more.

一个轻量的 macOS 菜单栏小工具:选中任意文字后按 ⌥C,自动完成「复制 → 清理 → 写回剪贴板」,专治从 PDF 复制中文文字时的各种乱码和格式问题。

Version Platform License

Keywords: macOS menu bar app · PDF copy cleanup · Chinese text cleaning · clipboard text processing · full-width/half-width normalization · OCR punctuation fix · Swift · 剪贴板清理 · PDF 复制乱码 · 中文排版清理

它解决什么问题

从 PDF 复制文字到别处时,常见这些坑:

  • 引用角标 [1]、[4-7] 混在正文里
  • 断行把一句话切得七零八落,中英文间多出莫名空格
  • 数字被空格拆开:138 0013 8000
  • 全角/半角标点混杂,<<书名>> 被 OCR 成尖括号
  • 英文标点没转中文标点

WYCleaner 在后台常驻,按一下 ⌥C 就把这些全部清理干净,然后直接 ⌘V 粘贴即可。

清理规则

按顺序执行以下 11 步(详见 Sources/TextCleaningService.swift):

  1. 删除引用角标([1]、[4-7]、(1,2)、上标数字等)
  2. 全角字母/数字 → 半角
  3. 换行符 → 空格
  4. 多余空格合并
  5. OCR 符号修正(<< >> → 《 》)
  6. 全量标点中文化(小数点 3.14、URL https://、千位分隔符 1,000 自动豁免)
  7. 括号内外侧空格清理
  8. 非英文字符间空格删除
  9. 数字与数字间空格删除
  10. 文字与数字间空格删除
  11. 最终微调(全角标点前后去空格)

系统要求

  • macOS 13.0(Ventura)或更高版本
  • Apple Silicon(arm64)
  • 辅助功能权限(用于模拟 ⌘C 按键)

安装使用

方式一:从源码构建

git clone https://github.com/Baitlo/WYCleaner.git
cd WYCleaner
bash scripts/build_installer.sh

构建完成后会在 build/ 目录生成 WYCleaner-1.1.0.pkg,双击按向导安装即可(会装入「应用程序」文件夹)。

首次启动授权

App 需要辅助功能权限才能模拟复制按键。首次启动会弹出系统提示,前往:

系统设置 → 隐私与安全性 → 辅助功能 → 打开 WYCleaner 开关

授权后退出并重新打开 App,状态栏出现 🔍 图标即就绪。

使用

  1. 在任意 App 中选中文字
  2. 按 ⌥C(Option + C)
  3. 状态栏提示 ✅ 后,⌘V 粘贴清理后的文字

点击状态栏图标可查看当前状态、前往授权或退出。

技术实现

纯 Swift Package Manager 项目,不需要 Xcode,只依赖 Command Line Tools:

  • swift build 编译出可执行文件
  • 脚本手工组装 .app bundle(Info.plist / 图标 / PkgInfo)
  • codesign --sign - 临时签名
  • pkgbuild 打包成 .pkg 安装器

核心组件:

文件 职责
Sources/HotkeyManager.swift Carbon 全局热键注册(⌥C)、CGEvent 模拟 ⌘C、权限轮询
Sources/TextCleaningService.swift 11 步文本清理管道
Sources/StatusBarController.swift 状态栏图标与菜单
Sources/AppDelegate.swift 生命周期、单实例保护、权限请求

License

Personal Use Only / 仅供个人使用。 本软件仅授权个人非商业用途使用,禁止商用或公司/组织使用,禁止修改,禁止分发。详见 LICENSE。

相关工具 / Related Tools

  • WY-t2s-Converter — 把繁体中文 PDF 一键转成简体并保留原始排版 / Convert Traditional Chinese PDFs to Simplified in-place.

About

macOS menu bar tool to clean messy text copied from PDFs — remove citation marks, fix line breaks, normalize punctuation. 一键清理从 PDF 复制的中文乱码与格式。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages