Explorer

markdown.line-outside-code

description
Read one line of markdown.to-html outside a fenced code block: a blank line ends the block, ``` starts a code block, # starts a heading
type
Fn(state: @markdown.state, line: String, doc_prefix: String) -> @markdown.state
expression
fn(state$0, line$1, doc_prefix$2) =>
  let trimmed$3 = @definy.string-trim(value: $1);
  match @core.equal(left: $3, right: "") {
    true =>
      @markdown.flush(state: $0, doc_prefix: $2),
    false =>
      match @std.string-starts-with(value: $3, prefix: "```") {
        true =>
          {blocks: @markdown.flush(state: $0, doc_prefix: $2).blocks, block: #code<@markdown.block>([])},
        false =>
          let level$4 = @markdown.heading-level(line: $1);
          match @core.less-than(left: 0, right: $4) {
            true =>
              {
                blocks: @core.list-append(
                  list: @markdown.flush(state: $0, doc_prefix: $2).blocks,
                  item: @html.element(
                    name: @core.string-concat(left: "h", right: @std.number-to-string(value: $4)),
                    attributes: [],
                    children: @markdown.inline(
                      text: @core.string-slice(value: $1, start: @core.plus(left: $4, right: 1), end: @core.string-length(value: $1)),
                      doc_prefix: $2
                    )
                  )
                ),
                block: #none<@markdown.block>
              },
            false =>
              @markdown.line-text(state: $0, line: $1, trimmed: $3, doc_prefix: $2)
          }
      }
  }
visibility
public
markdown.line-outside-code (project markdown, branch main, snapshot A_DQB42norQipCLzT0TSP-ZbZiC-EXHKoYK6tAFWTC0)
id: yaA7uR6tbB8fHo7TJX-d3rIU85KhTdWQVrxUKaczXfg
content hash: O6tUoTTdt3KK-YEtgv9fEmGt4xkS8dpxI4EtZi_2yAM