一键导入
safe-markdown-auto-fix
Auto-fix Markdown prose without corrupting code blocks, inline code, URLs, or HTML.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Auto-fix Markdown prose without corrupting code blocks, inline code, URLs, or HTML.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
A TRefCountPtr/TSharedPtr member in a UE class needs the pointee's full definition, not a forward decl.
When WSL's mirrored networking fails and falls back to "None", plus /etc/wsl.conf has generateResolvConf=false, the distro has no DNS; fix both layers.
When a Windows shell (PowerShell/cmd) feeds a bash script into WSL, CRLF line endings can corrupt the first shell builtin; force LF or pipe via a temp file.
Before "fixing" a recurring error, check git log to see if it was already fixed upstream — the working tree may just be stale.
Always add a space after URL brackets in Markdown to prevent 404 errors with special characters.
Plan a Python 3 modernization sweep (f-strings, super(), type hints) as a series of mechanical PRs, not one mega-PR.
| name | safe-markdown-auto-fix |
| description | Auto-fix Markdown prose without corrupting code blocks, inline code, URLs, or HTML. |
| tags | ["markdown","regex","tooling"] |
You're writing (or reviewing) a regex-based fixer for Markdown —
spacing rules, typography, terminology normalization. Applies to any
lint-and-fix tool, including the cndocstyle package shipped with
cn-doc-style-guide.
A naive re.sub over the whole file will cheerfully mangle:
): inserting "helpful" spaces in
the middle of a Python string breaks the program.`foo_bar`): adding space around _ ruins
identifiers.[text](https://…)): even reading URLs as prose
produces false positives like "space between CJK and ASCII" inside
a percent-encoded path.<img alt="你好World"> is prose inside HTML,
but the tag itself must stay intact.Always tokenize the file into "protected" and "prose" regions before applying any substitution. A minimal protection list:
PROTECT = [
# fenced code blocks, greedy across lines
re.compile(r"```[\s\S]*?```", re.MULTILINE),
# indented code blocks (4+ leading spaces at start of line)
re.compile(r"(?:^|\n)(?: {4,}|\t).+", re.MULTILINE),
# inline code
re.compile(r"`[^`\n]+`"),
# link / image URLs — keep the URL, allow fixing the text
re.compile(r"\]\([^)\n]+\)"),
# raw HTML tags and comments
re.compile(r"<!--[\s\S]*?-->"),
re.compile(r"<[a-zA-Z/][^>]*>"),
]
Then:
placeholder
(e.g. \x00PROTECT_N\x00) and storing the original.For a fixer it's also important to:
--apply to
write.Wrong — direct substitution corrupts code:
# inserts a space between CJK and ASCII everywhere
new = re.sub(r"([\u4e00-\u9fff])([A-Za-z0-9])", r"\1 \2", text)
# => a Python string literal "你好World" inside a ``` block
# becomes "你好 World", breaking the code
Right — protect first, then substitute:
protected, restore = protect(text, PROTECT)
protected = re.sub(r"([\u4e00-\u9fff])([A-Za-z0-9])", r"\1 \2", protected)
new = restore(protected)
``` rather than "start of line".\`) are rare
but real — include a unit test.