dongzhigang13305312738-art/paper-skills / complete-example
complete-example
Verified当用户明确要求"填充示例内容""生成示例""补充 LaTeX 示例"时使用。AI 增强版 LaTeX 示例智能生成器,实现 AI 与硬编码的有机融合:AI 做"语义理解"(分析章节主题、推理资源相关性、生成连贯叙述),硬编码做"结构保护"(格式验证、哈希校验、访问控制)。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.1 KB |
| config.yaml | config | 16.6 KB |
| references/README.md | markdown | 962 B |
| scripts/__init__.py | script | 503 B |
| scripts/advanced_usage.py | script | 5.4 KB |
| scripts/ai_content_generator.py | script | 19.6 KB |
| scripts/basic_usage.py | script | 1.3 KB |
| scripts/bibtex_parser.py | script | 5.6 KB |
| scripts/file_utils.py | script | 4.8 KB |
| scripts/format_guard.py | script | 15.5 KB |
| scripts/formula_generator.py | script | 2.1 KB |
| scripts/latex_parser.py | script | 6.2 KB |
| scripts/llm_client.py | script | 6.3 KB |
| scripts/placeholder_parser.py | script | 3.1 KB |
| scripts/resource_allocator.py | script | 10.3 KB |
| scripts/resource_scanner.py | script | 6.5 KB |
| scripts/security_manager.py | script | 17.4 KB |
| scripts/semantic_analyzer.py | script | 8.3 KB |
| scripts/skill_controller.py | script | 22.5 KB |
| scripts/table_generator.py | script | 5.8 KB |
| scripts/template_renderer.py | script | 994 B |
scripts/placeholder_parser.py
View on GitHub"""
Placeholder parsing utilities for complete-example.
We keep this logic hard-coded and deterministic: AI outputs placeholders, and
the code replaces them with safe LaTeX blocks.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Iterable, Optional
import re
@dataclass(frozen=True)
class Placeholder:
"""A parsed placeholder with its span in the original text."""
kind: str # "resource" | "table" | "inline_math" | "display_math" | "equation" | "align"
start: int
end: int
raw: str
# Resource
resource_id: Optional[str] = None
# Table
description: Optional[str] = None
complexity: Optional[str] = None # simple|moderate|complex
# Formula
formula: Optional[str] = None
label: Optional[str] = None
_RESOURCE_RE = re.compile(r"\{\{PLACEHOLDER:(.+?)\}\}")
_TABLE_RE = re.compile(r"\{\{TABLE:(.+?)\|(simple|moderate|complex)\}\}")
_INLINE_MATH_RE = re.compile(r"\{\{INLINE_MATH:(.+?)\}\}")
_DISPLAY_MATH_RE = re.compile(r"\{\{DISPLAY_MATH:(.+?)\}\}")
_EQUATION_RE = re.compile(r"\{\{EQUATION:(.+?)\|(.+?)\}\}")
_ALIGN_RE = re.compile(r"\{\{ALIGN:(.+?)\}\}")
def iter_placeholders(text: str) -> Iterable[Placeholder]:
"""Yield placeholders in appearance order (non-overlapping, based on regex finds)."""
patterns = [
("resource", _RESOURCE_RE),
("table", _TABLE_RE),
("inline_math", _INLINE_MATH_RE),
("display_math", _DISPLAY_MATH_RE),
("equation", _EQUATION_RE),
("align", _ALIGN_RE),
]
matches = []
for kind, rx in patterns:
for m in rx.finditer(text):
matches.append((m.start(), m.end(), kind, m))
matches.sort(key=lambda x: x[0])
for start, end, kind, m in matches:
raw = m.group(0)
if kind == "resource":
yield Placeholder(kind=kind, start=start, end=end, raw=raw, resource_id=m.group(1).strip())
elif kind == "table":
yield Placeholder(
kind=kind,
start=start,
end=end,
raw=raw,
description=m.group(1).strip(),
complexity=m.group(2).strip(),
)
elif kind == "inline_math":
yield Placeholder(kind=kind, start=start, end=end, raw=raw, formula=m.group(1).strip())
elif kind == "display_math":
yield Placeholder(kind=kind, start=start, end=end, raw=raw, formula=m.group(1).strip())
elif kind == "equation":
yield Placeholder(
kind=kind,
start=start,
end=end,
raw=raw,
formula=m.group(1).strip(),
label=m.group(2).strip(),
)
elif kind == "align":
yield Placeholder(kind=kind, start=start, end=end, raw=raw, formula=m.group(1).strip())
def replace_spans(text: str, replacements: list[tuple[int, int, str]]) -> str:
"""Replace multiple spans in a single pass, from back to front."""
out = text
for start, end, rep in sorted(replacements, key=lambda x: x[0], reverse=True):
out = out[:start] + rep + out[end:]
return out
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |