section

Types

A “section” found in the document, that is either:

  • A custom tag (e.g. to process
  • A section of text that doesn’t contain any custom tags. It might have variables (e.g. @person.first_name) for us to replace though.
pub type Section {
  Text(value: String, start: Int, context: Context)
  Tag(
    name: String,
    attrs: Dict(String, String),
    children: List(Section),
    start: Int,
    context: Context,
  )
}

Constructors

  • Text(value: String, start: Int, context: Context)
  • Tag(
      name: String,
      attrs: Dict(String, String),
      children: List(Section),
      start: Int,
      context: Context,
    )

Functions

pub fn get_attrs(s: String) -> Dict(String, String)

Get the attributes as key-value pairs, from a custom tag. For example, if we’re parsing this:

'items="people" item="person" index="i"'

Then this function should return a dict with these key -> value pairs: items -> people item -> person index -> i

Any leading and trailing whitespace in the text will be removed.

pub fn get_sections(
  raw_sections: List(RawSection),
) -> List(Section)
pub fn get_sections_rec(
  sections: List(RawSection),
  tag_stack: List(RawTag),
  acc: List(Section),
  child_dict: Dict(Int, List(Section)),
) -> List(Section)
Search Document