Explorer

html.node-to-string

description
Serialize a node. raw_text is true for the children of a raw text element (script, style, ...), whose text is not escaped. A void element is written without children and end tag
type
Fn(node: @html.node, raw_text: Boolean) -> String
expression
fn(node$0, raw_text$1) =>
  match $0 {
    #element(element$2) =>
      match @html.is-void-element(name: $2.name) {
        true =>
          @core.string-join(items: ["<", $2.name, @html.attributes-to-string(attributes: $2.attributes), ">"], separator: ""),
        false =>
          @core.string-join(
            items: [
              "<",
              $2.name,
              @html.attributes-to-string(attributes: $2.attributes),
              ">",
              @html.nodes-to-string-in(nodes: $2.children, raw_text: @html.is-raw-text-element(name: $2.name)),
              "</",
              $2.name,
              ">"
            ],
            separator: ""
          )
      },
    #text(text$3) =>
      match $1 {
        true =>
          $3,
        false =>
          @html.escape-text(text: $3)
      }
  }
visibility
public
html.node-to-string (project html, branch main, snapshot hd1kHQmQUtgayk-Y5Eo_pcQPlqiL8dHKKndnKtdm-KI)
id: 4RYN_KYJFiVrpW6rqsE82mZzbn6Tsg00sIqK_yXxSxc
content hash: P19x1GUAy_g1mb6map5qwh9kStuvNtWNzk6XTX3nQ08