SKILLS/leetcode-daily-card/SKILL.md

2.2 KiB

name description metadata
leetcode-daily-card A Python script that automatically fetches the daily LeetCode challenge and renders it as a PNG card or Markdown document.
clawdbot
emoji os
📋
linux
darwin
win32

LeetCode Daily Card Generator

A Python script that automatically fetches the daily LeetCode challenge and renders it as a PNG card or Markdown document.

Features

  • Automatic Daily Fetch: Retrieves the current daily LeetCode problem via GraphQL API
  • Two-Step Rendering: HTML → Markdown → PNG for optimal text rendering
  • CJK Support: Uses system CJK fonts (Microsoft YaHei, SimHei, etc.) for Chinese characters
  • Multiple Output Formats: Supports .png for image cards and .md for Markdown documents
  • Clean Unicode Handling: Removes zero-width spaces and other invisible Unicode characters

Installation

pip install Pillow html2text

Dependencies

  • Pillow: For PNG/JPG image rendering
  • html2text: For converting HTML content to Markdown

Usage

# Generate PNG card
python scripts/run.py output.png

# Generate Markdown document
python scripts/run.py output.md

Output Formats

PNG Card

  • Blue gradient header
  • White card body with rounded corners
  • Dark gradient background
  • Displays: title, question ID, difficulty, acceptance rate, tags, description

Markdown Document

  • Clean Markdown formatting
  • Question metadata in Info section
  • Full problem description
  • Example test cases
  • Link to problem page

Supported Platforms

  • Windows: Uses msyh.ttc (Microsoft YaHei), simhei.ttf, etc.
  • macOS: Uses PingFang.ttc, STHeiti Light.ttc
  • Linux: Uses NotoSansCJK, DejaVuSans.ttf, wqy-microhei.ttc

Workflow

LeetCode API (HTML) 
    ↓
html2text (Markdown)
    ↓
Markdown → Plain Text (cleanup)
    ↓
Pillow (PNG Image)

Example

python scripts/run.py daily.png
# Output: daily.png with the daily LeetCode challenge card

python scripts/run.py daily.md
# Output: daily.md with formatted Markdown content

Notes

  • The script requires internet access to fetch from LeetCode API
  • Formula rendering is not supported (plain text only)
  • Chinese fonts must be installed on the system for CJK character display