Skip to content

Releases

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 09 Nov 16:46
v0.2.0
ab9c4bc

libtexpr v0.2.0

Changelog

Added

  • Optional blocks {text [FIELD]}: removed whole when a placeholder inside is empty, kept without the braces otherwise
  • Engine.render_blocks (only the blocks), Engine.render_placeholders (only the [...]) and Engine.render_text (both, blocks first)
  • Block with PATTERN and check, which returns BlockIssue(kind, text) with a BlockIssueKind: UNCLOSED, UNOPENED, EMPTY, NESTED

Install

Latest

uv add libtexpr

Versioned

uv add libtexpr==0.2.0

What's Changed

New Contributors

Full Changelog: v0.1.0...v0.2.0

v0.1.0

Choose a tag to compare

@github-actions github-actions released this 27 Oct 15:11
v0.1.0
0d58906

libtexpr v0.1.0

Changelog

Added

  • Parser for placeholders such as [ДОЛГ.СУММА * 2 | деньги: кратко]: fields, numbers, words, names in Latin or Cyrillic, arithmetic with parentheses and unary minus, and a pipeline of functions with arguments
  • Engine with register, validate, evaluate and render_text, which leaves a placeholder that fails exactly as written
  • Function and Param: a function declares its name, code, input and output types, and arguments with allowed values and defaults
  • Typed values between functions: TEXT is str, NUMBER is Decimal, DATE is datetime.date; evaluate converts to the input type of each function and always returns text
  • Exact arithmetic with Decimal; numbers in data may use a comma as the decimal separator and spaces as thousands separators, and dates are YYYY-MM-DD
  • validate returns every problem found: UNKNOWN_FIELD, UNKNOWN_FUNCTION, TYPE_MISMATCH and BAD_ARGUMENT
  • Errors rooted in TexprError: ParseError subclasses carry the position of the error, an exception or a wrongly typed result from a function becomes FunctionError
  • Limits of 500 characters and 20 nesting levels, exposed as Placeholder.MAX_LENGTH and Placeholder.MAX_NESTING and reported as LimitExceededError
  • Placeholder.parse and Placeholder.extract to read a placeholder and to find the placeholders in a text
  • No runtime dependencies; Python 3.12 or newer

Install

Latest

uv add libtexpr

Versioned

uv add libtexpr==0.1.0

Full Changelog: https://github.com/StafLoker/libtexpr/commits/v0.1.0