Skip to main content

Crate toml_repair

Crate toml_repair 

Source
Expand description

§toml-repair

Repair messy TOML emitted by LLMs into something a real TOML parser will accept.

Fixes applied:

  1. Strip toml / fences and surrounding prose.
  2. Normalize CRLF and CR line endings to LF.
  3. Trim trailing whitespace.
  4. Convert smart quotes (“ ”) on string values to ASCII ".
  5. Strip trailing commas inside inline tables / arrays (TOML permits them in arrays only; we play it safe by leaving valid ones alone).

§Example

use toml_repair::repair;
let raw = "```toml\nname = “Claude”\nversion = \"4.5\"\n```";
let fixed = repair(raw);
assert!(fixed.contains("name = \"Claude\""));

Functions§

repair
Clean raw and return TOML-parser-ready text.