Sign in

    moonrockz/gleam-parser/format does not have a README file

    FormatError

    Why format gives no text.

    format

    fn format(text : String, config? :
    Config
    ) -> String raise FormatError

    Format Gleam source as gleam format (1.19.2) does: 80 columns, two spaces of indentation, no options. Comments and empty lines are kept where the compiler keeps them; the output is idempotent and parses again where the compiler's is (see "Format Parity" in AGENTS.md for the known differences). Raises ParseFailed when the text has a syntax error, OutOfFuel when config.fuel runs out.

    test {
    inspect(
    @format.format("pub fn main(){\n io.println( \"hi\" )\n}\n"),
    content="pub fn main() {\n io.println(\"hi\")\n}\n",
    )
    }

    format_parsed

    Format a parse result, as format formats text. The source is rebuilt from the CST (byte for byte), so the comments keep their text. Raises ParseFailed when the result has an error diagnostic.

    test {
    let r = @parser.parse_text("//// m\n// c\n")
    inspect(@format.format_parsed(r), content="//// m\n\n// c\n")
    }

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io