Explorer

markdown.line-text

description
Read a line of markdown.to-html that is not blank, a code fence or a heading: a list item, a table row, a block quote line or a line of a paragraph (an indented line after a list item continues the item)
type
Fn(state: @markdown.state, line: String, trimmed: String, doc_prefix: String) -> @markdown.state
expression
fn(state$0, line$1, trimmed$2, doc_prefix$3) =>
  match @markdown.list-item(trimmed: $2) {
    #some(item$4) =>
      match $0.block {
        #list(list$5) =>
          match @core.equal(left: $5.ordered, right: $4.ordered) {
            true =>
              {
                blocks: $0.blocks,
                block: #list<@markdown.block>({ordered: $5.ordered, items: @core.list-append(list: $5.items, item: $4.text)})
              },
            false =>
              {
                blocks: @markdown.flush(state: $0, doc_prefix: $3).blocks,
                block: #list<@markdown.block>({ordered: $4.ordered, items: [$4.text]})
              }
          },
        _ =>
          {
            blocks: @markdown.flush(state: $0, doc_prefix: $3).blocks,
            block: #list<@markdown.block>({ordered: $4.ordered, items: [$4.text]})
          }
      },
    #none(_) =>
      match @std.string-starts-with(value: $2, prefix: "|") {
        true =>
          match $0.block {
            #table(rows$6) =>
              {blocks: $0.blocks, block: #table<@markdown.block>(@core.list-append(list: $6, item: $2))},
            _ =>
              {blocks: @markdown.flush(state: $0, doc_prefix: $3).blocks, block: #table<@markdown.block>([$2])}
          },
        false =>
          match @std.string-starts-with(value: $2, prefix: ">") {
            true =>
              let quoted$7 = @definy.string-trim(value: @core.string-slice(value: $2, start: 1, end: @core.string-length(value: $2)));
              match $0.block {
                #quote(lines$8) =>
                  {blocks: $0.blocks, block: #quote<@markdown.block>(@core.list-append(list: $8, item: $7))},
                _ =>
                  {blocks: @markdown.flush(state: $0, doc_prefix: $3).blocks, block: #quote<@markdown.block>([$7])}
              },
            false =>
              match $0.block {
                #paragraph(lines$9) =>
                  {blocks: $0.blocks, block: #paragraph<@markdown.block>(@core.list-append(list: $9, item: $2))},
                #quote(lines$10) =>
                  {blocks: $0.blocks, block: #quote<@markdown.block>(@core.list-append(list: $10, item: $2))},
                #list(list$11) =>
                  match @std.string-starts-with(value: $1, prefix: " ") {
                    true =>
                      {
                        blocks: $0.blocks,
                        block: #list<@markdown.block>({ordered: $11.ordered, items: @markdown.append-to-last(items: $11.items, text: $2)})
                      },
                    false =>
                      {
                        blocks: @markdown.flush(state: $0, doc_prefix: $3).blocks,
                        block: #paragraph<@markdown.block>([$2])
                      }
                  },
                _ =>
                  {
                    blocks: @markdown.flush(state: $0, doc_prefix: $3).blocks,
                    block: #paragraph<@markdown.block>([$2])
                  }
              }
          }
      }
  }
visibility
public
markdown.line-text (project markdown, branch main, snapshot A_DQB42norQipCLzT0TSP-ZbZiC-EXHKoYK6tAFWTC0)
id: fWggtnI4_hfYgIaWUv07B-qTWtVlZM0Z5i4ckrZot_g
content hash: 1gHTwilDHwPD30njDaPjLx0IQRpIKuvndImOM8VyMuA