marianoguerra/html/write does not have a README file

    Style

    pub(all) enum Style {
    Pretty
    Compact
    Minified
    } derive(Eq)

    How much whitespace to spend.

    Whitespace

    pub(all) enum Whitespace {
    Css
    Strict
    Ignore
    } derive(Eq)

    How much whitespace is allowed to move.

    Prettier's option, and its three values. Css consults the default display of each element; Strict treats every space as significant and reformats nothing; Ignore treats none of them as significant and lays out freely, which is right for generated markup and wrong for a page a person wrote.

    document

    fn document(doc :
    Document
    , style? : Style, whitespace? : Whitespace) -> String

    Render a document.

    document_checked

    Render a document, and say what could not be printed faithfully.

    There is exactly one thing in that category and it is not a formatting nicety: a script or style body containing the element's own end tag, or a comment body containing -->. Raw text ends at the first </name and nothing escapes it, so a printer's only honest answers are to refuse or to silently change the text -- and silently changing the text of a script is how a formatter becomes a security bug. This refuses: the bytes go out unchanged, and the caller is told the tree cannot be printed.

    element

    fn element(e :
    Element
    , style? : Style, whitespace? : Whitespace) -> String

    Render one element.

    escape_attr

    fn escape_attr(s : String) -> String

    An attribute value, as it may appear between double quotes.

    < and > are left alone: they cannot end a quoted value, and escaping them would make every srcdoc and every inline SVG data URI unreadable.

    escape_text

    fn escape_text(s : String) -> String

    Character data, as it may appear between tags.

    < and & must be escaped; > need not be, and is anyway, because a bare > after a ]] is a CDATA-end sequence in foreign content and because a reader scanning for tags should not find a shape that is not one.

    may_go_unquoted

    fn may_go_unquoted(v : String) -> Bool

    Whether an attribute value may be written without quotes.

    Only Minified asks. The trailing-slash case is the one that is easy to miss and impossible to see: <a href=/x/> is a link to /x/ in the source and a self-closing tag with href=/x to a parser, so a value ending in / keeps its quotes however short it is.

    node

    fn node(n :
    Node
    , style? : Style, whitespace? : Whitespace) -> String

    Render one node, for a test or for a diagnostic that quotes one.

    raw_text_is_printable

    fn raw_text_is_printable(body : String, tag : String) -> Bool

    Whether a raw-text body can be printed at all.

    It cannot if it contains the element's own end tag, because raw text ends at the first </name and nothing escapes it -- not a backslash, not a reference, nothing. A printer's only honest answers are to refuse or to change the text, and changing the text of a script is how a formatter becomes a security bug. So this returns false, write reports UnprintableRawText, and the bytes go out unchanged so that at least nothing was invented.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io