Module scrapelect::interpreter::filter::builtin

source ·
Expand description

Documentation for scrapelect’s built-in filters.

Conventions used:

  • Signature of a filter: value: T | name(arg_1: U_1, ...): V means that name is a filter that takes a pipeline value of type T, has arguments arg_i of type U_i, and returns a value of type V
    • Specifying an arg type with a question mark (e.g., value: Value | dbg(msg: String?): Value) means that that argument (e.g., msg) is optional and can be omitted.
  • List shorthand: a List is represented as [a_0, a_1, a_2, ..., a_n] to mean that its elements are a_0, ..., a_n in that order. Indexing starts at 0. This syntax is currently not valid scrapelect, but it is useful to express in documentation.
  • Structure shorthand: similarly, a structure is represented as { key_1: value_1, key_2: value_2, … } to indicate that it has keys that correspond to the given values. This is not valid scrapelect, but it is useful in documentation.
  • Element shorthand: an inline HTML element (e.g., <a href="github.com/suaviloquence/scrapelect">Link text</a>) is also not valid scrapelect, but is useful to demonstrate how Elements are used in filters.

Functions§

  • andfilter_doc
    Signature: value: Bool | and(with: Bool): Bool
  • attrsfilter_doc
    Signature: value: Element | attrs(): Structure
  • dbgfilter_doc
    Signature: value | dbg(msg: String?): Value
  • eqfilter_doc
    Signature: value | eq(to: Value): Bool
  • floatfilter_doc
    Signature: value: (String or Int or Float) | float(): Float
  • idfilter_doc
    Signature: value | id(): Value
  • intfilter_doc
    Signature: value: (String or Int or Float) | int(): Int
  • is_infilter_doc
    Signature: value | is_in(list: List): Bool
  • keysfilter_doc
    Signature: value: Structure | keys(): List<String>
  • notfilter_doc
    Signature: value: Bool | not(): Bool
  • nthfilter_doc
    Signature: value: List | nth(i: Int): Value
  • orfilter_doc
    Signature: value: Bool | or(with: Bool): Bool
  • splitfilter_doc
    Signature: value: String | is_in(on: String?): List<String>
  • stripfilter_doc
    Signature: value: String | strip(): String
  • takefilter_doc
    Signature: value: Structure | take(key: String): Value
  • teefilter_doc
    Signature: value | tee(into: String): Value
  • textfilter_doc
    Signature: value: Element | text(): String
  • truthyfilter_doc
    Signature: value | truthy(): Bool
  • valuesfilter_doc
    Signature: value: Structure | values(): List