vxml_pipeline/core

Core desugarer and pipeline types, errors, warnings, and VXML utilities.

Types

pub type ContextualVXMLCondition =
  fn(
    vxml.VXML,
    List(vxml.VXML),
    List(vxml.VXML),
    List(vxml.VXML),
    List(vxml.VXML),
  ) -> Bool

One named VXML -> VXML transformation step.

pub type Desugarer {
  Desugarer(
    name: String,
    stringified_param: option.Option(String),
    stringified_outside: option.Option(String),
    transform: fn(vxml.VXML) -> Result(
      #(vxml.VXML, List(DesugaringWarning)),
      DesugaringError,
    ),
  )
}

Constructors

pub type DesugarerTransform =
  fn(vxml.VXML) -> Result(
    #(vxml.VXML, List(DesugaringWarning)),
    DesugaringError,
  )
pub type DesugaringError {
  DesugaringError(blame: blame.Blame, message: String)
}

Constructors

pub type DesugaringWarning {
  DesugaringWarning(blame: blame.Blame, message: String)
}

Constructors

  • DesugaringWarning(blame: blame.Blame, message: String)
pub type LatexDelimiterPair {
  DoubleDollar
  SingleDollar
  BackslashParenthesis
  BackslashSquareBracket
  BeginEndAlign
  BeginEndAlignStar
  BeginEndEnvironment(name: String)
}

Constructors

  • DoubleDollar
  • SingleDollar
  • BackslashParenthesis
  • BackslashSquareBracket
  • BeginEndAlign
  • BeginEndAlignStar
  • BeginEndEnvironment(name: String)
pub type LatexDelimiterSingleton {
  DoubleDollarSingleton
  SingleDollarSingleton
  BackslashOpeningParenthesis
  BackslashClosingParenthesis
  BackslashOpeningSquareBracket
  BackslashClosingSquareBracket
  BeginAlign
  EndAlign
  BeginAlignStar
  EndAlignStar
  BeginEnvironment(name: String)
  EndEnvironment(name: String)
}

Constructors

  • DoubleDollarSingleton
  • SingleDollarSingleton
  • BackslashOpeningParenthesis
  • BackslashClosingParenthesis
  • BackslashOpeningSquareBracket
  • BackslashClosingSquareBracket
  • BeginAlign
  • EndAlign
  • BeginAlignStar
  • EndAlignStar
  • BeginEnvironment(name: String)
  • EndEnvironment(name: String)

The ordered VXML -> VXML transformation stage, not the full render loop.

pub type Pipeline =
  List(Desugarer)
pub type SelectorError {
  EmptyTag
  InvalidTag
  InvalidKey
}

Constructors

  • EmptyTag
  • InvalidTag
  • InvalidKey
pub type SingletonError {
  MoreThanOne
  LessThanOne
}

Constructors

  • MoreThanOne
  • LessThanOne
pub type TrafficLight {
  Continue
  GoBack
}

Constructors

  • Continue
  • GoBack

Values

pub fn aggregate_on_first(
  l: List(#(a, b)),
) -> dict.Dict(a, List(b))
pub fn append_if_not_present(items: List(a), item: a) -> List(a)
pub fn assert_drop_last(z: List(a)) -> List(a)
pub fn assert_drop_prefix(s: String, prefix: String) -> String
pub fn assert_split_style(
  style: String,
) -> List(#(String, String))
pub fn attrs_append_classes(
  attrs: List(vxml.Attr),
  blame: blame.Blame,
  classes: String,
) -> List(vxml.Attr)
pub fn attrs_delete(
  attrs: List(vxml.Attr),
  key: String,
) -> List(vxml.Attr)
pub fn attrs_extract_first(
  attrs: List(vxml.Attr),
  key: String,
) -> #(option.Option(vxml.Attr), List(vxml.Attr))
pub fn attrs_extract_key_occurrences(
  attrs: List(vxml.Attr),
  key: String,
) -> #(List(vxml.Attr), List(vxml.Attr))
pub fn attrs_extract_key_val(
  attrs: List(vxml.Attr),
  key: String,
  val: String,
) -> #(List(vxml.Attr), List(vxml.Attr))
pub fn attrs_extract_unique_key_or_none(
  attrs: List(vxml.Attr),
  key: String,
) -> Result(
  #(option.Option(vxml.Attr), List(vxml.Attr)),
  DesugaringError,
)
pub fn attrs_first_with_key(
  attrs: List(vxml.Attr),
  key: String,
) -> option.Option(vxml.Attr)
pub fn attrs_have_class(
  attrs: List(vxml.Attr),
  class: String,
) -> Bool
pub fn attrs_have_key(
  attrs: List(vxml.Attr),
  key: String,
) -> Bool
pub fn attrs_have_key_val(
  attrs: List(vxml.Attr),
  key: String,
  val: String,
) -> Bool
pub fn attrs_merge_prepend_styles(
  attrs: List(vxml.Attr),
  blame: blame.Blame,
  styles: String,
) -> List(vxml.Attr)
pub fn attrs_merge_styles(
  attrs: List(vxml.Attr),
  blame: blame.Blame,
  styles: String,
) -> List(vxml.Attr)
pub fn attrs_replace_val(
  attrs: List(vxml.Attr),
  from: String,
  to: String,
) -> List(vxml.Attr)
pub fn attrs_set(
  attrs: List(vxml.Attr),
  blame: blame.Blame,
  key: String,
  val: String,
) -> List(vxml.Attr)
pub fn attrs_unique_key_or_none(
  attrs: List(vxml.Attr),
  key: String,
) -> Result(option.Option(vxml.Attr), DesugaringError)
pub fn attrs_val_first_with_key(
  attrs: List(vxml.Attr),
  key: String,
) -> option.Option(String)
pub fn attrs_val_first_with_key_expected(
  attrs: List(vxml.Attr),
  key: String,
  blame: blame.Blame,
) -> Result(String, DesugaringError)
pub fn attrs_val_of_unique_key(
  attrs: List(vxml.Attr),
  key: String,
  blame: blame.Blame,
) -> Result(String, DesugaringError)
pub fn attrs_with_key(
  attrs: List(vxml.Attr),
  key: String,
) -> List(vxml.Attr)
pub fn break_out_first_word(input: String) -> #(String, String)

“word” == “non-whitespace” == empty string if string starts with whitespace

returns: -> #(before_first_space, everything_afterwards)

pub fn compose_style(keyvals: List(#(String, String))) -> String
pub fn delete(items: List(a), item: a) -> #(Bool, List(a))
pub fn delete_singleton_empty_lines_in_list(
  nodes: List(vxml.VXML),
) -> List(vxml.VXML)
pub fn descendant_lines(v: vxml.VXML) -> List(vxml.Line)
pub fn descendant_text_contains(v: vxml.VXML, s: String) -> Bool
pub fn descendant_text_does_not_contain(
  vxml: vxml.VXML,
  s: String,
) -> Bool
pub fn descendants_with_class(
  vxml: vxml.VXML,
  class: String,
) -> List(vxml.VXML)
pub fn descendants_with_tag(
  vxml: vxml.VXML,
  tag: String,
) -> List(vxml.VXML)
pub fn dict_from_list(
  l: List(#(a, b)),
) -> Result(dict.Dict(a, b), DesugaringError)
pub fn drop_ending_slash(path: String) -> String
pub fn drop_last(z: List(a)) -> List(a)
pub fn drop_prefix(s: String, prefix: String) -> String
pub fn drop_suffix(s: String, suffix: String) -> String
pub fn ensure_prefix(s: String, prefix: String) -> String
pub fn ensure_suffix(s: String, suffix: String) -> String
pub fn expand_selector_shorthand(
  shorthand: String,
) -> Result(vxml.VXML, SelectorError)
pub fn extract_first_word_from_t_node_if_t(
  vxml: vxml.VXML,
) -> #(option.Option(vxml.VXML), vxml.VXML)

“word” == “non-whitespace” == empty string if node starts with whitespace

returns -> #( Option(new T(..) containing first word), node leftover with word taken out, )

pub fn extract_last_word_from_t_node_if_t(
  vxml: vxml.VXML,
) -> #(vxml.VXML, option.Option(vxml.VXML))

“word” == “non-whitespace” == empty string if node ends with whitespace

returns -> #( node leftover with last word taken out, Option(new T(..) containing last word), )

pub fn extract_trim_end(content: String) -> #(String, String)
pub fn extract_trim_start(content: String) -> #(String, String)
pub fn filter_descendants(
  vxml: vxml.VXML,
  condition: fn(vxml.VXML) -> Bool,
) -> List(vxml.VXML)
pub fn find_replace_if_t(
  node: vxml.VXML,
  from: String,
  to: String,
) -> vxml.VXML
pub fn find_replace_if_t__batch(
  node: vxml.VXML,
  pairs: List(#(String, String)),
) -> vxml.VXML
pub fn first_line_ends_with(
  lines: List(vxml.Line),
  s: String,
) -> Bool
pub fn first_line_starts_with(
  lines: List(vxml.Line),
  s: String,
) -> Bool
pub fn first_with_tag(
  nodes: List(vxml.VXML),
  tag: String,
) -> option.Option(vxml.VXML)
pub fn from_tag(
  blame: blame.Blame,
  tag: String,
) -> Result(vxml.VXML, DesugaringError)
pub fn get_contained(
  from: List(a),
  in: List(a),
) -> option.Option(a)
pub fn get_duplicate(list: List(a)) -> option.Option(a)
pub fn html_info_shorthand_to_attrs(
  blame: blame.Blame,
  info: String,
) -> Result(
  #(
    option.Option(vxml.Attr),
    option.Option(vxml.Attr),
    option.Option(vxml.Attr),
    option.Option(vxml.Attr),
  ),
  String,
)
pub fn insert_before_first(
  list: List(a),
  elt: a,
  condition: fn(a) -> Bool,
) -> List(a)
pub fn insert_child_before_first_in_list(
  nodes: List(vxml.VXML),
  child: vxml.VXML,
  before: String,
) -> List(vxml.VXML)
pub fn insert_in_list_pair_as_dict(
  list_pairs: List(#(a, b)),
  item: #(a, b),
) -> List(#(a, b))
pub fn invalid_tag(tag: String) -> Bool
pub fn is_t(node: vxml.VXML) -> Bool
pub fn is_t_and_text_contains(
  vxml: vxml.VXML,
  content: String,
) -> Bool
pub fn is_t_or_is_one_of(
  node: vxml.VXML,
  tags: List(String),
) -> Bool
pub fn is_v(node: vxml.VXML) -> Bool
pub fn is_v_and_has_attr_with_key(
  vxml: vxml.VXML,
  key: String,
) -> Bool
pub fn is_v_and_has_class(vxml: vxml.VXML, class: String) -> Bool
pub fn is_v_and_tag_equals(vxml: vxml.VXML, tag: String) -> Bool
pub fn is_v_and_tag_is_not_one_of(
  vxml: vxml.VXML,
  tags: List(String),
) -> Bool
pub fn is_v_and_tag_is_one_of(
  vxml: vxml.VXML,
  tags: List(String),
) -> Bool
pub fn is_v_and_tag_not_equals(
  vxml: vxml.VXML,
  tag: String,
) -> Bool
pub fn kebab_case_to_camel_case(input: String) -> String
pub fn keys(attrs: List(vxml.Attr)) -> List(String)
pub fn last_to_first_concatenation(
  vxmls: List(vxml.VXML),
) -> List(vxml.VXML)
pub fn last_to_first_concatenation_in_list_list_lines(
  l: List(List(vxml.Line)),
) -> List(vxml.Line)
pub fn last_to_first_concatenation_in_list_list_of_lines_where_all_but_last_list_are_already_reversed(
  list_of_lists: List(List(vxml.Line)),
) -> List(vxml.Line)
pub fn latex_inline_delimiters() -> List(LatexDelimiterPair)
pub fn latex_strippable_delimiter_pairs() -> List(
  LatexDelimiterPair,
)
pub fn latex_strippable_display_delimiters() -> List(
  LatexDelimiterPair,
)
pub fn lines_are_whitespace(lines: List(vxml.Line)) -> Bool
pub fn lines_contain(lines: List(vxml.Line), s: String) -> Bool
pub fn lines_first_blame(lines: List(vxml.Line)) -> blame.Blame
pub fn lines_map_content(
  lines: List(vxml.Line),
  m: fn(String) -> String,
) -> List(vxml.Line)
pub fn lines_remove_starting_empty_lines(
  l: List(vxml.Line),
) -> List(vxml.Line)
pub fn lines_total_chars(lines: List(vxml.Line)) -> Int
pub fn lines_trim_start(
  lines: List(vxml.Line),
) -> List(vxml.Line)
pub fn list_param_stringifier(param: List(p)) -> String
pub fn list_set(
  items: List(a),
  index: Int,
  element: a,
) -> List(a)
pub fn list_string_stringifier(param: List(String)) -> String
pub fn merge_attrs(attrs: List(vxml.Attr)) -> List(vxml.Attr)
pub fn merge_classes(a: String, b: String) -> String
pub fn merge_styles(a: String, b: String) -> String
pub fn normalize_spaces(s: String) -> String
pub fn not_contains(list: List(a), element: a) -> Bool
pub fn on_t_on_v(
  node: vxml.VXML,
  f1: fn(blame.Blame, List(vxml.Line)) -> c,
  f2: fn(blame.Blame, String, List(vxml.Attr), List(vxml.VXML)) -> c,
) -> c
pub fn opening_and_closing_delimiter_strings(
  delimiters: List(LatexDelimiterPair),
) -> #(List(String), List(String))
pub fn opening_and_closing_string_for_pair(
  pair: LatexDelimiterPair,
) -> #(String, String)
pub fn optional_style_extract_unique_key_or_none(
  style_attr: option.Option(vxml.Attr),
  key: String,
) -> Result(
  #(option.Option(String), option.Option(vxml.Attr)),
  DesugaringError,
)
pub fn pair_2nd(t: #(a, b)) -> b
pub fn plain_concatenation_in_list(
  nodes: List(vxml.VXML),
) -> List(vxml.VXML)
pub fn pour(from: List(a), into: List(a)) -> List(a)

dumps the contents of ‘from’ “upside-down” into ‘into’, so that the first element of ‘from’ ends up buried inside the resulting list, while the last element of ‘from’ ends up surfaced as the first element of the result

pub fn pour_before_first(
  list: List(a),
  to_pour: List(a),
  condition: fn(a) -> Bool,
) -> List(a)
pub fn pour_before_first_in_list(
  nodes: List(vxml.VXML),
  to_insert: List(vxml.VXML),
  before: String,
) -> List(vxml.VXML)
pub fn pour_but_last(
  from: List(a),
  into: List(a),
) -> #(List(a), a)
pub fn prefix_partition(
  list: List(a),
  condition: fn(a) -> Bool,
) -> #(List(a), List(a))
pub fn quad_drop_3rd(t: #(a, b, c, d)) -> #(a, b, d)
pub fn quad_drop_4th(t: #(a, b, c, d)) -> #(a, b, c)
pub fn quad_to_pair(t: #(a, b, c, d)) -> #(a, #(b, c, d))
pub fn quad_to_pair_pair(t: #(a, b, c, d)) -> #(#(a, b), #(c, d))
pub fn quads_to_pair_pairs(
  l: List(#(a, b, c, d)),
) -> List(#(#(a, b), #(c, d)))
pub fn quads_to_pairs(
  l: List(#(a, b, c, d)),
) -> List(#(a, #(b, c, d)))
pub fn read_singleton(z: List(a)) -> Result(a, SingletonError)
pub fn remove_class(classes: String, class: String) -> String
pub fn remove_in_class_attr(
  attrs: List(vxml.Attr),
  to_be_removed: String,
) -> List(vxml.Attr)
pub fn replace_attr_val(
  attr: vxml.Attr,
  from: String,
  to: String,
) -> vxml.Attr
pub fn reversed_lines_trim_end(
  lines: List(vxml.Line),
) -> List(vxml.Line)
pub fn split_lines(
  lines: List(vxml.Line),
  splitter: String,
) -> List(List(vxml.Line))
pub fn string_pair_to_attr(
  pair: #(String, String),
  blame: blame.Blame,
) -> vxml.Attr
pub fn string_pairs_to_attrs(
  pairs: List(#(String, String)),
  blame: blame.Blame,
) -> List(vxml.Attr)
pub fn style_extract_unique_key_or_none(
  style: String,
  key: String,
  blame: blame.Blame,
) -> Result(#(option.Option(String), String), DesugaringError)
pub fn substitute_in_class_attr(
  attrs: List(vxml.Attr),
  from: String,
  to: String,
) -> List(vxml.Attr)
pub fn suffix_partition(
  l: List(a),
  condition: fn(a) -> Bool,
) -> #(List(a), List(a))
pub fn supplement_in_class_attr(
  attrs: List(vxml.Attr),
  if_this_is_there: String,
  then_add: String,
) -> List(vxml.Attr)
pub fn t_end_insert_line(
  vxml: vxml.VXML,
  line: vxml.Line,
) -> vxml.VXML
pub fn t_end_insert_text(
  vxml: vxml.VXML,
  text: String,
) -> vxml.VXML
pub fn t_extract_ending_spaces(
  node: vxml.VXML,
) -> #(option.Option(vxml.VXML), vxml.VXML)
pub fn t_extract_starting_spaces(
  node: vxml.VXML,
) -> #(option.Option(vxml.VXML), vxml.VXML)
pub fn t_find_replace(
  node: vxml.VXML,
  from: String,
  to: String,
) -> vxml.VXML
pub fn t_find_replace__batch(
  vxml: vxml.VXML,
  pairs: List(#(String, String)),
) -> vxml.VXML
pub fn t_map(
  vxmls: List(vxml.VXML),
  f: fn(vxml.VXML) -> vxml.VXML,
) -> List(vxml.VXML)
pub fn t_remove_ending_empty_lines(
  vxml: vxml.VXML,
) -> option.Option(vxml.VXML)
pub fn t_remove_starting_empty_lines(
  vxml: vxml.VXML,
) -> option.Option(vxml.VXML)
pub fn t_start_insert_line(
  vxml: vxml.VXML,
  line: vxml.Line,
) -> vxml.VXML
pub fn t_start_insert_text(
  vxml: vxml.VXML,
  text: String,
) -> vxml.VXML
pub fn t_t_last_to_first_concatenation(
  node1: vxml.VXML,
  node2: vxml.VXML,
) -> vxml.VXML
pub fn total_chars(vxml: vxml.VXML) -> Int
pub fn trim_ending_spaces_except_last_line(
  vxml: vxml.VXML,
) -> vxml.VXML
pub fn trim_starting_spaces_except_first_line(
  vxml: vxml.VXML,
) -> vxml.VXML
pub fn triple_3rd(t: #(a, b, c)) -> c
pub fn triple_drop_2nd(t: #(a, b, c)) -> #(a, c)
pub fn triple_drop_3rd(t: #(a, b, c)) -> #(a, b)
pub fn triple_to_pair(t: #(a, b, c)) -> #(a, #(b, c))
pub fn triples_to_aggregated_dict(
  l: List(#(a, b, c)),
) -> dict.Dict(a, List(#(b, c)))
pub fn triples_to_dict(
  l: List(#(a, b, c)),
) -> dict.Dict(a, #(b, c))
pub fn triples_to_pairs(
  l: List(#(a, b, c)),
) -> List(#(a, #(b, c)))
pub fn try_map_fold(
  over items: List(q),
  from state: a,
  with f: fn(a, q) -> Result(#(q, a), c),
) -> Result(#(List(q), a), c)
pub fn use_list_pair_as_dict(
  list_pairs: List(#(a, b)),
  key: a,
) -> Result(b, Nil)
pub fn v_append_classes(
  node: vxml.VXML,
  classes: String,
) -> vxml.VXML
pub fn v_append_classes_if(
  node: vxml.VXML,
  classes: String,
  condition: fn(vxml.VXML) -> Bool,
) -> vxml.VXML
pub fn v_assert_pop_attr(
  vxml: vxml.VXML,
  key: String,
) -> #(vxml.VXML, vxml.Attr)
pub fn v_assert_pop_attr_val(
  vxml: vxml.VXML,
  key: String,
) -> #(vxml.VXML, String)
pub fn v_attrs_constructor(
  blame: blame.Blame,
  tag: String,
  attrs: List(#(String, String)),
) -> vxml.VXML
pub fn v_attrs_with_key(
  vxml: vxml.VXML,
  key: String,
) -> List(vxml.Attr)
pub fn v_children_with_class(
  vxml: vxml.VXML,
  class: String,
) -> List(vxml.VXML)
pub fn v_children_with_tag(
  vxml: vxml.VXML,
  tag: String,
) -> List(vxml.VXML)
pub fn v_children_with_tags(
  vxml: vxml.VXML,
  tags: List(String),
) -> List(vxml.VXML)
pub fn v_end_insert_line(
  vxml: vxml.VXML,
  line: vxml.Line,
) -> vxml.VXML
pub fn v_end_insert_text(
  vxml: vxml.VXML,
  text: String,
) -> vxml.VXML
pub fn v_extract_children(
  vxml: vxml.VXML,
  condition: fn(vxml.VXML) -> Bool,
) -> #(vxml.VXML, List(vxml.VXML))
pub fn v_extract_ending_spaces(
  node: vxml.VXML,
) -> #(option.Option(vxml.VXML), vxml.VXML)
pub fn v_extract_starting_spaces(
  node: vxml.VXML,
) -> #(option.Option(vxml.VXML), vxml.VXML)
pub fn v_filter_children(
  vxml: vxml.VXML,
  condition: fn(vxml.VXML) -> Bool,
) -> List(vxml.VXML)
pub fn v_first_attr_with_key(
  vxml: vxml.VXML,
  key: String,
) -> option.Option(vxml.Attr)
pub fn v_first_child_with_tag(
  vxml: vxml.VXML,
  tag: String,
) -> option.Option(vxml.VXML)
pub fn v_get_children(vxml: vxml.VXML) -> List(vxml.VXML)
pub fn v_get_tag(vxml: vxml.VXML) -> String
pub fn v_has_attr_with_key(vxml: vxml.VXML, key: String) -> Bool
pub fn v_has_class(vxml: vxml.VXML, class: String) -> Bool
pub fn v_has_key_val(
  vxml: vxml.VXML,
  key: String,
  val: String,
) -> Bool
pub fn v_map(
  vxmls: List(vxml.VXML),
  f: fn(vxml.VXML) -> vxml.VXML,
) -> List(vxml.VXML)
pub fn v_pour_before_first(
  vxml: vxml.VXML,
  to_insert: List(vxml.VXML),
  before: String,
) -> vxml.VXML
pub fn v_prepend_attr(
  vxml: vxml.VXML,
  attr: vxml.Attr,
) -> vxml.VXML
pub fn v_prepend_child(
  vxml: vxml.VXML,
  child: vxml.VXML,
) -> vxml.VXML
pub fn v_prepend_unique_key_attr(
  vxml: vxml.VXML,
  attr: vxml.Attr,
) -> Result(vxml.VXML, Nil)
pub fn v_remove_ending_empty_lines(node: vxml.VXML) -> vxml.VXML
pub fn v_remove_starting_empty_lines(
  node: vxml.VXML,
) -> vxml.VXML
pub fn v_replace_children_with(
  vxml: vxml.VXML,
  children: List(vxml.VXML),
) -> vxml.VXML
pub fn v_set_attr(
  vxml: vxml.VXML,
  blame: blame.Blame,
  key: String,
  val: String,
) -> vxml.VXML
pub fn v_set_tag(v: vxml.VXML, tag: String) -> vxml.VXML
pub fn v_start_insert_line(
  vxml: vxml.VXML,
  line: vxml.Line,
) -> vxml.VXML
pub fn v_start_insert_text(
  vxml: vxml.VXML,
  text: String,
) -> vxml.VXML
pub fn v_tag_is_one_of(
  vxml: vxml.VXML,
  tags: List(String),
) -> Bool
pub fn v_trim_end(node: vxml.VXML) -> vxml.VXML
pub fn v_trim_start(node: vxml.VXML) -> vxml.VXML
pub fn v_unique_child(
  vxml: vxml.VXML,
  tag: String,
) -> Result(vxml.VXML, DesugaringError)
pub fn v_unique_child_with_singleton_error(
  vxml: vxml.VXML,
  tag: String,
) -> Result(vxml.VXML, SingletonError)
pub fn v_val_of_first_attr_with_key(
  vxml: vxml.VXML,
  key: String,
) -> option.Option(String)
pub fn valid_tag(tag: String) -> Bool
pub fn validate_unique_keys(
  l: List(#(a, b)),
) -> Result(List(#(a, b)), DesugaringError)
pub fn vxml_digest(vxml: vxml.VXML) -> String
pub fn with_default(
  o: option.Option(a),
  default: a,
) -> option.Option(a)
Search Document