agentleFS
DBQDSSDBQDSS/aimath-translations-skill/skills/math-pdf-bookmark/SKILL.md

math-pdf-bookmark

Skill5 starsChanged 56 days agoMITView on GitHub

Add precise clickable bookmarks to AI or mathematics PDFs, individually or in a folder. Use text-span geometry for PDFs with usable text; use OCR only where needed for scans. Verify that each bookmark lands on its actual heading rather than an assumed page.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use when the user requests PDF bookmarks or a navigable table of contents.

    line 8
  2. Very specific:

    Use the sibling pdf-scanned-ocr-bookmark instructions if OCR is required.

    line 19
  3. Distinctive:

    Read detached page columns, full-width parentheses, and page ranges carefully.

    line 33
  4. Distinctive:

    If a TOC lacks page numbers, locate headings sequentially in the body using a forward cursor, not the first occurrence of the title in the …

    line 34
  5. Distinctive:

    Use a trustworthy page mapping to choose the page.

    line 42
  6. Distinctive:

    If the mapping is unavailable, search within the interval bounded by verified neighboring entries.

    line 44
  7. Distinctive:

    Use the installed PDF library's supported destination format.

    line 55
  8. Distinctive:

    Check hierarchy, page bounds, live destinations, title/heading correspondence, and intended reading order.

    line 64
  9. Distinctive:

    Do not claim full coverage when some targets were omitted or require OCR review.

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Precise PDF Bookmarks

Use when the user requests PDF bookmarks or a navigable table of contents. Preserve the PDF content and map every bookmark to a verified page and heading position. Work on output copies before replacing originals within the requested scope.

Inventory And Classify

  • Identify existing usable bookmarks; keep them unless the user requests changes.
  • Sample body pages throughout the book, not just the final page. A scan with metadata text on one page must not be mistaken for a text-layer book.
  • Distinguish usable text, pure scans, and hybrid books whose TOC alone is scanned. OCR only the affected pages of a hybrid book when the body already has good text.
  • Use the sibling pdf-scanned-ocr-bookmark instructions if OCR is required. Select concurrency based on measured memory and CPU capacity, not a fixed worker count inherited from another machine.

Reconstruct The TOC

  1. Locate actual TOC pages; distinguish them from a numbered bibliography or a list of other volumes. Check title/page correspondence in the body.
  2. For text-layer TOCs, cluster spans by vertical position, then sort by x to reconstruct number/title/page rows. A line may be split across several spans.
  3. Deduplicate repeated text spans. Require multiple leader characters when stripping dot leaders so the period in 1. Title survives.
  4. Parse chapter, section, appendix, and part hierarchy from numbering and indentation. Calibrate clustering tolerances for the actual layout.
  5. Read detached page columns, full-width parentheses, and page ranges carefully. If a TOC lacks page numbers, locate headings sequentially in the body using a forward cursor, not the first occurrence of the title in the entire PDF.

Resolve Every Heading

  • Determine the printed-to-physical page mapping from multiple verified anchors. Roman front matter, inserted plates, and restarted page numbering may require separate segments rather than a single offset.
  • Use a trustworthy page mapping to choose the page; search that page for the heading's vertical position. Search neighboring pages only when evidence supports it.
  • If the mapping is unavailable, search within the interval bounded by verified neighboring entries. Compare title tokens while preserving word boundaries; deleting spaces before tokenization destroys English word overlap.
  • Exclude TOC pages, running heads, folios, and mentions inside body prose from heading matches. Respect chapter-local section numbering.
  • Record unresolved entries for review. Never invent a target using the last cursor page, clamp a wrong page into range, or force a nonmonotonic destination to match its neighbor.

Write Destinations And Verify

Use the installed PDF library's supported destination format. For PyMuPDF, simple TOC entries use 1-based page numbers; a fourth numeric value can specify heading height in points. Do not pass an arbitrary unvalidated dictionary as a destination. Read back get_toc(simple=False) to verify the resulting links.

OCR geometry is in pixels and must be converted with 72 / actual_render_dpi. Text-span geometry is already in page coordinates; do not apply an OCR scale to it. Account for page rotation and the library's coordinate convention when necessary.

Check hierarchy, page bounds, live destinations, title/heading correspondence, and intended reading order. Inspect bookmarks on headings below the page top. Reject collapsed destination sets and report any intentional nonmonotonic order. Confirm the output opens, retains page count/content, and is no longer being written before copying it back. A process log alone does not prove saved bookmarks exist.

Tool Availability And Delivery

Historical project helpers such as tlbmk.py, build_t1.py, diag.py, verify.py, and recover_empties.py are not bundled with this skill. Use them only if the current project supplies them; otherwise implement the required focused processing with the available library. Do not assume private paths, logs, worklist indices, or root variables belong to the current corpus.

Report input/output files, PDFs processed, bookmarks written and verified, skipped existing bookmarks, unresolved entries, and books without a usable TOC. Do not claim full coverage when some targets were omitted or require OCR review.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.