Function parse_list

Source
fn parse_list<F, G>(
    list: &[Token],
    is_list_item: F,
    make_block: G,
) -> MdBlockElement
where F: Fn(&[Token]) -> bool, G: Fn(Vec<MdListItem>) -> MdBlockElement,
Expand description

Generic list parser used to reduce code duplication between ordered and unordered lists.

Handles splitting lines, identifying list items, and parsing nested lists. The behavior is determined by a predicate for identifying list items and a constructor for the resulting block.

§Arguments

  • list - The tokens to parse.
  • is_list_item - Predicate to identify a top-level list item.
  • make_block - Constructor for the resulting MdBlockElement.

§Returns

An MdBlockElement representing either an ordered or unordered list, depending on the passed in constructor.