diff --git a/wizard-work/quill/md_inspect.py b/wizard-work/quill/md_inspect.py new file mode 100644 index 0000000..43b2026 --- /dev/null +++ b/wizard-work/quill/md_inspect.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +"""Draft artifact: md_inspect.py — lightweight Markdown structure inspector.""" +import re +import sys +from pathlib import Path + + +def inspect(path: str) -> dict: + text = Path(path).read_text(encoding="utf-8") + lines = text.splitlines() + headings = [ln for ln in lines if re.match(r"^#{1,6}\s", ln)] + words = len(text.split()) + links = re.findall(r"\[[^\]]+\]\([^\)]+\)", text) + return { + "file": path, + "lines": len(lines), + "headings": len(headings), + "words": words, + "links": len(links), + } + + +def main() -> int: + if len(sys.argv) < 2: + print("usage: md_inspect.py ", file=sys.stderr) + return 2 + data = inspect(sys.argv[1]) + for k, v in data.items(): + print(f"{k}={v}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/wizard-work/quill/sample.md b/wizard-work/quill/sample.md new file mode 100644 index 0000000..27e3fc6 --- /dev/null +++ b/wizard-work/quill/sample.md @@ -0,0 +1,8 @@ +# Heading One +Some text here. + +## Heading Two +More text with a [link](https://example.com) and [another](https://example.org). + +### Heading Three +Even more text.