Explorer

markdown.list-item

description
A Markdown list item (- , * or 1. at the start of the trimmed line): whether it is ordered and its text. Nested items are read as items of the same list
type
Fn(trimmed: String) -> Union{#none, #some(Record{ordered: Boolean, text: String})}
expression
fn(trimmed$0) =>
  let length$1 = @core.string-length(value: $0);
  match @core.or(
      left: @std.string-starts-with(value: $0, prefix: "- "),
      right: @std.string-starts-with(value: $0, prefix: "* ")
    ) {
    true =>
      #some({ordered: false, text: @core.string-slice(value: $0, start: 2, end: $1)}),
    false =>
      let dot$2 = @core.string-index-of(text: $0, target: ". ", start: 0);
      match @core.and(
          left: @core.and(left: @core.less-than(left: 0, right: $2), right: @core.less-than(left: $2, right: 4)),
          right: @markdown.is-digits(text: @core.string-slice(value: $0, start: 0, end: $2))
        ) {
        true =>
          #some({
            ordered: true,
            text: @core.string-slice(value: $0, start: @core.plus(left: $2, right: 2), end: $1)
          }),
        false =>
          #none
      }
  }
visibility
public
markdown.list-item (project markdown, branch main, snapshot A_DQB42norQipCLzT0TSP-ZbZiC-EXHKoYK6tAFWTC0)
id: Rv5iDssEccymEzVsw4-ur85aRFwXGiuDtmvkXd7IZds
content hash: EHAp9XY8caQbGmoxLDp3IUowbYqIvynFrVEqOVS5-Og