Skip to main content

try_parse_setext_heading

Function try_parse_setext_heading 

Source
pub fn try_parse_setext_heading(
    lines: &[&str],
    pos: usize,
) -> Option<(usize, char)>
Expand description

Try to parse a setext heading from lines, returns (level, underline_char) if found.

Setext headings consist of:

  1. A non-empty text line (heading content)
  2. An underline of = (level 1) or - (level 2) characters

Rules:

  • Underline must be at least 3 characters long
  • Underline can have leading/trailing spaces (up to 3 leading spaces)
  • All underline characters must be the same (= or -)
  • Text line cannot be indented 4+ spaces (would be code block)
  • Text line cannot be empty/blank