autofixMarkup() deterministically repairs the unambiguous subset of dotgui mistakes — CSS-habit renames, no-op attrs, boolean="false", color formats — leaving judgment calls to lint.

/autofix

repairdeterministic repair

Deterministic auto-repair for dotgui markup. Models make the same mechanical mistakes — CSS habits, invented attributes, boolean="false", bad color formats — and each is an unambiguous string rewrite, so autofix fixes them in place instead of bouncing back to the author.

Anything needing design judgment (missing sizes, undefined tokens, empty spacers) is deliberately not fixed — it stays a /lint error. lint finds; autofix fixes the unambiguous subset.

Signature

autofixMarkup(xml: string): AutofixResult

interface AutofixResult {
  xml: string        // rewritten markup (unchanged if nothing to fix)
  fixes: string[]    // description of each applied fix
  error?: string     // set only if the markup couldn't be parsed
}

What it repairs

  • CSS-habit renames — width→w, height→h, spacing→gap.
  • Padding shorthands — py→pt/pb, px→pl/pr.
  • Drops no-op attrs — margin, mt/mb/ml/mr, justify, align-items, flex.
  • Booleans — removes attr="false" (presence-based).
  • Alignment — text-align→align; invented align values remapped to the nearest valid one.
  • Colors — #abc→#aabbcc, rgb()/rgba()→hex. Content — em-dashes in copy → hyphens.

Use cases

  • gui lint --fix in the CLI.
  • gui-app — repair on paste or save.
  • Any agent pipeline that wants mechanical mistakes fixed without a round-trip.

Repair markup and log the fixes

import { autofixMarkup } from '@dotgui/kit/autofix'

const { xml, fixes } = autofixMarkup(markup)
for (const f of fixes) console.log('·', f)
// xml is the cleaned markup — write it back