GNU General Public License v3.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度解析 GitHub 项目 “lucasrla/remarks”

项目背景与痛点

在数字化时代,个人与团队之间的知识交流越来越多地依赖于电子文档。推动知识的高效传播与管理,需要一种便捷的工具来处理多格式的注释。针对这一痛点,一位资深开发者发布了 GitHub 项目 “lucasrla/remarks”,它从 reMarkable 笔记本等设备中提取标注和批注,并支持多种格式的输出,如 Markdown、PDF、PNG 和 SVG。这项工具在内容管理和知识场景应用中具有重要意义,能够显著提升文档处理效率,避免大量的手动操作。

核心技术揭秘

“lucasrla/remarks” 项目的核心在于能够跨平台高效地解析不同格式的文档并提取出注释信息。项目主要采用了 Python 进行开发,巧妙融合了多个第三方库来处理文件读写与格式转换。

graph TD A[用户上传文件] --> B[文件类型识别] B -->|"reMarkable PDF|EPUB" | C[注释提取] B -->|"其他格式"| D[不支持处理] C --> E{"格式选择"} E -->|"Markdown"| F[Markdown导出] E -->|"PDF"| G[PDF导出] E -->|"PNG"| H[PNG导出] E -->|"SVG"| I[SVG导出]

项目包含的主要模块有文件上传接口、文档解析器和格式导出器。首先,用户上传文档后,系统通过文件类型识别来确定后续处理逻辑。对于 reMarkable 设备支持的 PDF 和 EPUB 格式,系统会调用注释提取模块,识别并提取文本内的注释信息。接下来,用户可以选择导出格式,系统将注释信息转换为对应的输出格式。

本文提到的技术栈涵盖了 Python 的文件处理库(如 PyPDF2、BeautifulSoup 等),以及针对特定格式的专业库,如处理 PDF、EPUB 格式的专用库,保证了高效率和稳定性。

功能亮点与差异

与其他专注于单一输出格式的工具相比,“lucasrla/remarks” 的最大亮点在于其高度的灵活性与兼容性。用户可以自由选择将注释信息导出为不同类型支持的文件格式,满足不同场景的使用需求。此外,项目良好的模块化设计,使得未来拓展新格式变得更加简易。

与此同时,得益于对于处理不同设备和文件类型的兼容能力,它在特定场景下具备了强有力的竞争优势。例如,教育工作者能够通过文件批注功能促进师生之间的互动,而研究人员则可以利用此工具快速整理笔记数据。

应用场景与落地建议

“lucasrla/remarks” 项目适配于多类知识密集型场景。针对教育领域,它可实现高效的内容批注与交互。而在学术研究中,科研院所研究员可以利用该工具整理和分享研究笔记,提升协作效率。另外,企业培训或技术文档管理等场景也是其大展身手之处。

在实际使用中,用户需注意文件类型与支持格式间的对应关系,并根据具体情况选择合理的导出格式,以获得最佳体验。对于开发者,则应持续关注第三方库的更新,保持对新文件格式的兼容支持。

综合评价

“lucasrla/remarks” 项目凭借其灵活性和高效性,在多类型文档注释处理方面表现出色。其可扩展的架构设计以及优秀的格式兼容能力,使它成为众多复杂知识场景的理想选择。然而,项目目前仍需获得更多实际案例的支持,以验证其在长期运行中的稳定性和性能。对开发者而言,保持更新与优化至关重要。而对于使用者来说,在遵循指导规范的同时,将能彻底释放此工具在不同专业场景中的强大潜力。

关于

GitHub 原始描述(英文)

Extract annotations (highlights and scribbles) from PDF, EPUB, and notebooks marked with reMarkable tablets. Export to Markdown, PDF, PNG, SVG

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Python

README

remarks

⚠️ remarks does NOT work with annotations created by reMarkable sofware >= 3.0 yet. Follow issue #58 for updates ⚠️

Extract annotations (text highlights and scribbles) and convert them to Markdown, PDF, PNG, and SVG.

remarks works with documents annotated on reMarkable™ paper tablets — both 1st and 2nd generation — up to software version 2.15.0.1067.

Note that remarks not only is highly experimental, it is very likely to break after you update the software of your tablet. I might find some spare time to continue to maintain it, but I make no promises.

remarks code is fairly straightforward but not elegant at all. It has been put together in a couple of hours. You are free to fork and run with it though ;)

Most of the actual heavy lifting has been done by the open source community and PyMuPDF. See Credits and Acknowledgements.

Some use cases

  • In: PDF highlighted on reMarkable → Out: PDF with parseable highlights
    Someone who highlights lots of PDFs (e.g., researchers, academics, etc) can export their highlights for processing with a reference management tool, like Zotero (e.g., issue #2).

  • Extract highlighted text from PDF to Markdown
    Infovores of the world can export highlighted text to Markdown and insert them into their preferred “tool for networked thought”, like Obsidian or Roam Research.

  • Export annotated PDF pages to full-page images
    Sometimes having just the textual content is not enough, sometimes you need the actual (visual) context around your annotation. To help you in such situations, remarks can export each annotated PDF page to a PNG image file. Images can be easily uploaded or embedded anywhere, from personal websites to “tools for networked thought”.

A visual example

Highlight and annotate PDFs with your Marker on your reMarkable tablet:

IMG_0642-low.jpg

And then use remarks to export annotated pages to Markdown, PDF, PNG, or SVG on your computer:

demo-remarks-png.png

WHAT IS LIFE?

Based on lectures delivered under the auspices of the Dublin Institute for Advanced Studies at Trinity College, Dublin, in February 1943

To the memory of My Parents

Compatibility and dependencies

Because remarks depends only on PyMuPDF and Shapely, there is no need to install imagemagick, opencv, or any additional image library. Both PyMuPDF and Shapely have pre-built wheels for several platforms (macOS, Linux, Windows) and recent Python 3 versions, so installing them should be smooth and easy for most people.

I currently use remarks with reMarkable 1 and reMarkable 2 tablets running software versions 2.14.3.1047 and 2.15.0.1067 on macOS Ventura (13.2.1) with CPython 3.10.9. I don’t have other equipment to test it thoroughly, but I expect remarks to work just fine in all common setups.

Incidentally, help the community keeping track of remarks compatibility across different setups:

If OCRmyPDF is available on your computer, remarks may (optionally) use it to OCR PDFs before extracting their highlighted text.

Setup

To get remarks up and running on your local machine, follow the instructions below:

1. Copy reMarkable’s “raw” document files to your computer

In order to reconstruct your highlights and annotations, remarks relies on specific files that are created by the reMarkable device as you use it. Because these specific files are internal to the reMarkable device, first we need to transfer them to your computer.

There are several options for getting them to your computer. Find below some suggestions. Choose whatever fits you:

  • Use rsync (i)
    Check out the repository @lucasrla/remarkable-utils for the SSH & rsync setup I use (which includes automatic backups based on cron).

  • Use scp (i)
    On your reMarkable tablet, go to Menu > Settings > Help, then under About tap on Copyrights and licenses. In General information, right after the section titled “GPLv3 Compliance”, there will be the username (root), password and IP address needed for SSHing into it. Using these credentials, scp the contents of /home/root/.local/share/remarkable/xochitl from your reMarkable to a directory on your computer. (Copying may take a while depending on the size of your document collection and the quality of your WiFi network.) To prevent any unintented interruptions, you can (optionally) switch off the Auto sleep feature in Menu > Settings > Battery before transferring your files.

  • Use @juruen/rmapi or @subutux/rmapy
    Both are free and open source software that allow you to access your reMarkable tablet files through reMarkable’s cloud service.

  • Copy from reMarkable’s official desktop application
    If you have a reMarkable’s official desktop app installed, most of the files we need are already easily available on your computer. For macOS users, the files are located at ~/Library/Application\ Support/remarkable/desktop. To avoid interfering with reMarkable’s official app, copy and paste all the contents of ~/Library/Application\ Support/remarkable/desktop to another directory (one that you can safely interact with – say, ~/Documents/remarkable/docs). Please note that this method won’t allow you to use remarks’ EPUB functionality. That’s because this directory doesn’t seem to include the PDF files that reMarkable auto converts your EPUBs to.

2. Clone this repository and install the dependencies

### 2.1 Clone
git clone https://github.com/lucasrla/remarks.git && cd remarks


### 2.2 Create and activate a virtual environment

# If you're using poetry, a new virtual env should be created automatically (as set forth in our `poetry.toml`)
# But feel free to manage your virtual env needs with any of the alternatives (e.g. virtualenv, virtualenvwrapper, etc)


### 2.3 Install the dependencies

# Install dependencies with:
poetry install

Usage and Demo

Run remarks and check out what arguments are available:

python -m remarks --help

Next, for a quick hands-on experience of remarks, run the demo:

# Alan Turing's 1936 foundational paper (with a few highlights and scribbles)

# Original PDF file downloaded from:
# "On Computable Numbers, with an Application to the Entscheidungsproblem"
# https://londmathsoc.onlinelibrary.wiley.com/doi/abs/10.1112/plms/s2-42.1.230

python -m remarks demo/on-computable-numbers/xochitl remarks-example/ --per_page_targets png md pdf --modified_pdf

A few other examples:

# Assuming your `xochitl` files are at `~/backups/remarkable/xochitl/`

python -m remarks ~/backups/remarkable/xochitl/ example_1/ --ann_type highlights --per_page_targets md

python -m remarks ~/backups/remarkable/xochitl/ example_2/ --per_page_targets png

Tests

Run pytest in the root directory of the project after installing the dependencies using poetry. This will create files in the tests/out directory. The contents of this directory can safely be deleted.

Example:

python -m pytest -q remarks/test_initial.py
..                                         [100%]
2 passed in 2.51s

ls tests/out
  1936 On Computable Numbers, with an Application to the Entscheidungsproblem - A. M. Turing _highlights.md  
  Gosper _remarks.pdf
  1936 On Computable Numbers, with an Application to the Entscheidungsproblem - A. M. Turing _remarks.pdf

Credits and Acknowledgements

For more reMarkable resources, check out awesome-reMarkable and remarkablewiki.com.

License

remarks is Free Software distributed under the GNU General Public License v3.0.

Disclaimers

This is a hobby project of an enthusiastic reMarkable user. There is no warranty whatsoever. Use it at your own risk.

The author(s) and contributor(s) are not associated with reMarkable AS, Norway. reMarkable is a registered trademark of reMarkable AS in some countries. Please see https://remarkable.com for their products.

评论

暂无评论