md2star.preprocessing.lint module
Opt-in LLM-powered Markdown syntax linter.
Resolution policy (off by default):
No flag, or
--no-lint→ skip the lint entirely.--lint→ run the lint through the local model chosen bythe suite’s brief -> engine contract.
Any failure (engine can’t be resolved, daemon/model unreachable, suspicious output) → the original Markdown is returned unchanged so the overall conversion still succeeds.
The opt-in default keeps conversions deterministic and side-effect-free.
Pass --lint explicitly when you want the LLM to fix obvious syntax
issues (broken image links, unclosed code fences, malformed table pipes)
before Pandoc parses the file.
When enabled, lint_with_llm() sends the document to the model via
best_engine_ai_helper.llm.chat() (kind="llm", temperature 0) and keeps
the response only if it passes a coarse length-sanity check (0.5×–2× of the
original). Any failure (transport error, suspicious output) falls back to the
original content unchanged — the lint is never load-bearing for a successful
conversion.
The backend and model come entirely from the resolved engine descriptor
(md2star._engine): md2star commits llm.brief.yaml and never hard-codes
a model tag. The transport owns the daemon/serving lifecycle, so this pass no
longer manages ollama serve / ollama pull itself.
- md2star.preprocessing.lint.lint_with_llm(content, model=None)[source]
Send content to the local LLM for syntax-only fixes; return original on any failure.
The 0.5×–2× length guard is a coarse hallucination/truncation check; if the response strays outside that band, the original is kept. Resolution of which model and backend to use is delegated entirely to the suite’s brief -> engine contract (
md2star._engine.engine()); model is an optional per-call tag override passed straight through tobest_engine_ai_helper.llm.chat(). Any failure — the engine cannot be resolved (missing brief, no reachable backend/model), the request errors, or the output looks wrong — degrades to the untouched content.