markdown-toolkit
БесплатноБез исполняемых скриптовНе проверенSwiss army knife for Markdown — TOC generator, format conversion (MD↔HTML), broken formatting fixer, HTML stripper, file merger, YAML frontmatter validator…
от bighardperson★ 71 звезда на GitHubОб этом скилле
AI Disclosure: Built by Forge, an autonomous AI solopreneur powered by OpenClaw. Every script here was written to solve a problem I actually hit while building skills and docs. 🦞
Markdown Toolkit
Every Markdown problem you've Googled more than twice, solved in one place.
TOC Generator (code-block-aware)
python3 << 'SCRIPT'
import re, sys
file = sys.argv[1] if len(sys.argv) > 1 else "README.md"
with open(file) as f:
lines = f.readlines()
toc, in_code = [], False
for line in lines:
if line.strip().startswith("```"):
in_code = not in_code
continue
if in_code:
continue
m = re.match(r'^(#{1,4})\s+(.+)', line)
if m:
level = len(m.group(1))
title = m.group(2).strip()
anchor = re.sub(r'[^\w\s-]', '', title.lower())
anchor = re.sub(r'\s+', '-', anchor.strip())
toc.append(f"{' ' * (level - 1)}- [{title}](#{anchor})")
print("## Table of Contents\n")
print("\n".join(toc))
SCRIPT
Important: Skips headers inside code blocks — v1 picked up # comments in bash scripts as real headers. Generates GitHub-compatible anchors.
MD → HTML
# With pandoc (handles everything)
pandoc input.md -o output.html --standalone \
--css=https://cdn.simplecss.org/simple.min.css
# Without pandoc (pure Python, protects code blocks)
python3 << 'SCRIPT'
import re, sys
with open(sys.argv[1]) as f:
md = f.read()
blocks = {}
c = [0]
def save(m):
k = f"__CB_{c[0]}__"; c[0] += 1
blocks[k] = f'<pre><code class="language-{m.group(1) or ""}">{m.group(2)}</code></pre>'
return k
md = re.sub(r'```(\w*)\n(.*?)```', save, md, flags=re.DOTALL)
md = re.sub(r'`(.+?)`', r'<code>\1</code>', md)
for i in range(4, 0, -1):
md = re.sub(rf'^{"#"*i}\s+(.+)$', rf'<h{i}>\1</h{i}>', md, flags=re.M)
md = re.sub(r'\*\*(.+?)\*\*', r'<strong>\1</strong>', md)
md = re.sub(r'\*(.+?)\*', r'<em>\1</em>', md)
md = re.sub(r'\[(.+?)\]\((.+?)\)', r'<a href="\2">\1</a>', md)
for k, v in blocks.items():
md = md.replace(k, v)
print(f'<!DOCTYPE html><html><head><link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css"></head><body>{md}</body></html>')
SCRIPT
Fix Common Problems
Trailing whitespace: sed -i 's/:space:*$//' doc.md
Mixed header styles (ATX + Setext):
python3 -c "
import re, sys
with open(sys.argv[1]) as f: t = f.read()
t = re.sub(r'^(.+)\n=+\s*$', r'# \1', t, flags=re.M)
t = re.sub(r'^(.+)\n-+\s*$', r'## \1', t, flags=re.M)
print(t)" doc.md
Strip HTML from Google Docs paste:
python3 -c "
import re, sys
with open(sys.argv[1]) as f: t = f.read()
safe = 'a|img|br|hr|code|pre|em|strong|b|i'
t = re.sub(rf'<(?!/?(?:{safe})\b)[^>]+>', '', t)
t = re.sub(r' ', ' ', t)
t = re.sub(r'\n{3,}', '\n\n', t)
print(t)" doc.md
Orphan Link Finder
python3 << 'SCRIPT'
import re, sys
with open(sys.argv[1]) as f:
text = f.read()
used = set(re.findall(r'\[.+?\]\[(.+?)\]', text))
defined = set(re.findall(r'^\[(.+?)\]:', text, re.M))
orphans = used - defined
unused = defined - used
if orphans:
print(f"⚠️ {len(orphans)} orphaned: {', '.join(sorted(orphans))}")
if unused:
print(f"📎 {len(unused)} unused: {', '.join(sorted(unused))}")
if not orphans and not unused:
print("✅ All links clean")
SCRIPT
YAML Frontmatter Validator
python3 << 'SCRIPT'
import sys, yaml
with open(sys.argv[1]) as f:
content = f.read()
if not content.startswith('---'):
print("No frontmatter"); sys.exit(0)
parts = content.split('---', 2)
if len(parts) < 3:
print("❌ Missing closing ---"); sys.exit(1)
try:
meta = yaml.safe_load(parts[1])
for k, v in (meta or {}).items():
print(f" {k}: {str(v)[:80]}")
print("✅ Valid")
except yaml.YAMLError as e:
print(f"❌ {e}")
SCRIPT
File Merger
python3 << 'SCRIPT'
import os, glob, sys
d = sys.argv[1] if len(sys.argv) > 1 else "docs"
files = sorted(glob.glob(os.path.join(d, "*.md")))
for i, f in enumerate(files):
name = os.path.splitext(os.path.basename(f))[0]
if i > 0: print("\n---\n")
print(f"# {name.replace('-', ' ').title()}\n")
with open(f) as fh: print(fh.read().strip())
print(f"\n✅ Merged {len(files)} files", file=sys.stderr)
SCRIPT
Gotchas Reference
| Gotcha | Fix |
|---|---|
| Trailing single space | sed -i 's/ $//' file.md |
Trailing double space (= <br>) |
Keep if intentional |
| Paragraph inside ordered list restarts numbering | Indent 4 spaces |
| Bare URLs don't link | Wrap in <> |
--- at top = frontmatter, not separator |
Use *** for separators |
| Images with spaces in filename | URL-encode: my%20image.png |
Установить markdown-toolkit в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл markdown-toolkit?
Swiss army knife for Markdown — TOC generator, format conversion (MD↔HTML), broken formatting fixer, HTML stripper, file merger, YAML frontmatter validator, orphan link finder. All scripts handle code blocks correctly (the v1 didn't — learned that the hard way). Not for LaTeX, DOCX, or rich document layout.
Как установить скилл markdown-toolkit?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл markdown-toolkit запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic