Run2 pdf calendar parsing
Extract calendar events from PDF by mapping colored rectangles to a 15-min grid using PyMuPDF.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill run2_pdf-calendar-parsingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.6 KB, 493 tokens by cl100k_base, as published. Nobody here has run it
PDF Calendar Parsing with PyMuPDF
Installation
pip install pymupdf
Approach
- Use
page.get_drawings()to extract all drawn shapes. - Identify the 15-min grid: horizontal lines with
width > 100andheight < 3. Sort by y-position. The first line is time 0 (12:00 AM), each subsequent line is +15 min. - Identify event blocks: filled rectangles with
height > 5andwidth > 100. - Map each block's top/bottom y to the nearest grid line:
slot = round((y - grid[0]) / spacing), time =slot * 15minutes from midnight. - Blue blocks: check if
fill[2] > 0.6andfill[0] < 0.55(blue-dominant). These are low-priority and overwritable.
Grid line to time mapping
lines = sorted([d["rect"].y0 for d in drawings if d["rect"].width > 100 and d["rect"].height < 3])
spacing = lines[1] - lines[0] # ~7.5 px
def y_to_slot(y):
return round((y - lines[0]) / spacing)
def slot_to_time(slot):
total_min = slot * 15
h, m = divmod(total_min, 60)
return h, m # 24-hour format
Block padding
Blocks have ~1px padding on each side, so round() to nearest slot gives correct results. Always verify by checking that durations are multiples of 15 minutes.
Identifying block colors
- Gray (out of office):
fill ≈ (0.38, 0.38, 0.38) - Red/Pink (meetings):
fill ≈ (0.90, 0.49, 0.45) - Blue (low-priority):
fill ≈ (0.47, 0.53, 0.80)— OVERWRITABLE - Yellow/Green (labels):
fill ≈ (0.75, 0.79, 0.20)— these are small label squares inside blocks, ignore
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.