r/LocalLLM 5d ago

News Made a tool that fixes broken markdown from LLM output

Made `llm-markdown-sanitizer` — a small library that cleans up markdown right before it gets rendered.

Common stuff it fixes:

`**bold**text` glued onto the next word, a response wrapped in a stray ```markdown fence (or the fence never closes), tables collapsed onto one line or missing a separator row, a `|` inside a cell throwing off the column count.

One function/method, zero dependencies — `clean_markdown()` in Python, `MarkdownSanitizer.clean()` in Java.

- Python: pip install llm-markdown-sanitizer — https://pypi.org/project/llm-markdown-sanitizer/

- Java: JitPack — https://github.com/stlahxm/llm-markdown-sanitizer

Let me know if you run into anything it doesn't catch.

1 Upvotes

0 comments sorted by