law-to-markdown
律师助理与法律助手在处理繁杂法条时,当需要将 PDF/Word/TXT 格式的法律规范文件转为结构化 Markdown 时适用。自动完成 OCR 解析、法律层级识别与三阶段保真校验,一键生成排版完美的法条 Markdown 文档及审核报告,让法律文本数字化工作事半功倍。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- law-to-markdown
- description
- 律师助理与法律助手在处理繁杂法条时,当需要将 PDF/Word/TXT 格式的法律规范文件转为结构化 Markdown 时适用。自动完成 OCR 解析、法律层级识别与三阶段保真校验,一键生成排版完美的法条 Markdown 文档及审核报告,让法律文本数字化工作事半功倍。
02 资源文件 9
- 其他.gitignore19 B
- 参考文档agents/openai.yaml178 B
- 其他law-to-markdown/.gitignore37 B
- 许可证LICENSE.txt11.1 KB
- 参考文档README.md2.1 KB
- 脚本scripts/cn_law_normalizer.py9.6 KB
- 脚本scripts/law_to_markdown.py30.7 KB
- 脚本scripts/requirements.txt38 B
- 脚本scripts/stage3_checker.py15.1 KB
03 SKILL.md 正文
Law To Markdown
处理规则
- 输入为
.txt:直接转存为.md。 - 输入为
.pdf/.docx:- 先检查是否已安装
mineru-ocrskill。 - 未安装:提示先安装
mineru-ocr,安装地址:https://github.com/cat-xierluo/legal-skills/tree/main/skills/mineru-ocr - 已安装:优先调用
mineru-ocr处理。 - 调用失败:先提示检查
mineru-ocr配置/Token。 - 仅当用户明确同意时,才使用本地回退(
python-docx/pdfplumber)。
- 先检查是否已安装
- 第一阶段完成后默认执行第二阶段格式调整(仅格式,不改原文字符):
- 由调用该 skill 的大模型先判断“法律/非法律”,并把结果传给脚本。
- 若调用方未传结果,则脚本使用硬规则自动识别(
--law-decision auto)。 - 法律名称
# - 编/分编
## - 章
### - 节
#### - 条
#####(仅“第X条”为标题;第X条【条标】整行为标题不拆) - 款/项/目无标题
- 项、目按标记换行
- 清理多余空格:去行尾空格、去行首 ASCII 空格、去正文行首全角缩进、规范标题后的空格
- 若识别为明显非法律文本(如 GB/标准类文档),第二阶段明确拒绝:
Stage2: rejected (non-law-document)。 - 若第二阶段未识别法律结构或保真校验失败,则自动 no-op,不改文本。
- 默认执行第三阶段检查(双子阶段,硬门槛):
- Stage3-A:校验
stage2相对stage1的文字内容准确性(去标题符号与空白后字符流必须一致) - Stage3-B:校验结构效果(结构层级、条标题规则、非法律策略、空格规范、项/目换行)
- 任一失败触发自动重走,最多 2 次;仍失败默认报错退出
- Stage3-A:校验
二阶段识别参数
--law-decision law:调用方已判定为法律文本,直接按法律结构优化。--law-decision non-law:调用方已判定为非法律文本,阶段二直接拒绝。--law-decision auto:不传判定时的默认模式,使用脚本内硬规则。
三阶段参数
--skip-stage3-check:跳过第三阶段检查(默认不跳过)。--stage3-max-retries:失败后自动重走次数,默认2。--stage3-strict/--no-stage3-strict:- 默认严格模式(失败即报错退出)
- 非严格模式仅输出报告,不阻断流程
--artifact-level minimal|standard|debug:minimal(默认):面向交付,输出最少standard:保留过程文件(stage1/stage2/stage3-check)便于排查debug:保留全部过程产物(包含调试信息)
输出规则
- 默认输出到输入文件同目录的
markdown/子目录,并按输入文件名创建独立目录:markdown/<文件名>/
- 默认(
--artifact-level minimal)输出:<原文件名>+审核报告.md(详细过程和结论)<原文件名>+最终成果.md(仅法律文本且审核通过时生成)
- 非法律文档(如 GB/标准类):
- 结论为“拒绝处理”
- 仅输出
<原文件名>+审核报告.md - 不输出
<原文件名>+最终成果.md
- 审核未通过时会自动保留过程文件用于排查:
<文件名>.stage1.md<文件名>.stage2.md<文件名>.stage3-check.md
- 若需更多产物可切换:
--artifact-level standard:保留stage1/stage2/stage3-check--artifact-level debug:保留全部调试产物
- 可通过命令参数指定
--out或--out-dir。
常用命令
python3 law-to-markdown/scripts/law_to_markdown.py "input.txt"
python3 law-to-markdown/scripts/law_to_markdown.py "input.docx"
python3 law-to-markdown/scripts/law_to_markdown.py "input.pdf"
用户明确同意回退时:
python3 law-to-markdown/scripts/law_to_markdown.py "input.docx" --allow-fallback
python3 law-to-markdown/scripts/law_to_markdown.py "input.pdf" --allow-fallback
04 同仓库更多 Skills
writing-dna-skill
从至少 20 篇完整文章中蒸馏可复用的写作 DNA,分析语言、文章结构、选题逻辑、素材策略、认知框架和视觉风格,并生成 Writing-DNA.md;按该 DNA 写作时会读取全部蒸馏产物和 5 篇相关原文。用于中英文作者、账号、品牌或出版物的风格分析与一致性写作。 Distill reusable Writing DNA from at least 20 complete articles for Chinese or English authors, publications, brands, and accounts; use for language, structure, topic logic, source strategy, cognitive-frame, and visual-style analysis.
ub-quality-gates
Uncle Bob 编程纪律与确定性质量门工具链。写代码或改代码时使用:先让它能跑,再让它正确,最后守纪律。 当用户要求 /ub-mode、需要代码质量门禁、CRAP 评分、重复代码检测、变异测试、 或抱怨代码难懂/难测/有重复时触发。覆盖 Clojure/Java/Go/TypeScript/Rust/Python。
tweet-composer
Score and optimize tweets based on X's real open-source ranking algorithm. Analyzes draft tweets against the actual ranking code — not generic tips. Use when: composing tweets, optimizing drafts for reach, planning threads, analyzing why a tweet performed well/poorly, or asking for posting strategy advice.
short-video-scripter
Use when the user asks to "script this short video", "write a TikTok / Reels / Shorts script", "给这条抖音或视频号视频写脚本", or "fix the hook — viewers drop off in the first seconds"; produces timestamped beat-sheet scripts on the retention-gate model (0-2s hook / 2-5s confirmation / 5-15s payoff / loop-or-CTA) with per-scene script lines, on-screen text for muted viewing, asset keywords, and 9:16 format-param rows per platform norm card for TikTok, Reels, Shorts, 抖音, and 视频号 — plus 2-3 hook options from named hook families and an AI-content disclosure line by default on realistic synthetic media. Spec-only: rendering, TTS, and publishing stay with the user's own tools — no pipelines, no upload automation. Not for creator video briefs — use brief-generator; long-form video SEO belongs to content-writer. 短视频脚本/抖音分镜/开头钩子/竖屏9:16
remotion-video-master
Remotion 视频编程大师 — 用 React 组件以编程方式创建 MP4 视频。支持动画、字幕、音乐可视化、 AI 配音(TTS)与场景自动配时。触发词:用代码做视频、编程视频、React 视频、Remotion、 /remotion-video。适用场景:程序化视频(批量生成、数据驱动如年度总结、音乐可视化、自动字幕)、 教程讲解视频(技术概念可视化如 CNN 与算法、分层递进讲解、AI 配音教程)、 3D 视频(产品展示与模型动画、卡通角色讲解、3D 数据可视化、Logo 动画)。
short-videos
Produce 90-second universal short-video scripts (HeyGen / Instagram Reels / LinkedIn Video / YouTube Shorts) and standalone LinkedIn posts using native Hermes tools. No Claude Code dependency.