NativeElixirPdfUtilities.Validators.CssMathValidator (native_elixir_pdf_utilities v1.1.0)

View Source

Shared bounded CSS calculations with dimensional arithmetic and the Values 4 numeric functions.

Summary

Types

A length-percentage source with validated grammar and measured point scales.

Functions

Tokenizes balanced CSS components while keeping strings and escapes opaque.

Evaluates a CSS scalar or math function in an already prepared length environment.

Evaluates an absolute color component using the pinned scalar calculation grammar without font or viewport authority.

Collects unit and percentage dependencies through the shared length calculation grammar.

Prepares a length-percentage calculation while deferring its percentage basis.

Collects units through the shared grammar after validating a length-percentage type.

Evaluates a prepared length against its actual point-valued percentage basis.

Types

dimension()

@type dimension() :: %{optional(atom()) => integer()}

length_calculation()

@type length_calculation() ::
  {:css_calculation, {String.t(), %{required(String.t()) => number()}}}

A length-percentage source with validated grammar and measured point scales.

numeric()

@type numeric() :: number() | :infinity | :negative_infinity | :nan

Functions

component_tokens(value, products?)

@spec component_tokens(String.t(), boolean() | :ranges) ::
  {:ok, [String.t()]} | :invalid

Tokenizes balanced CSS components while keeping strings and escapes opaque.

evaluate(value, environment)

@spec evaluate(String.t(), map()) :: {:ok, numeric(), dimension()} | :error

Evaluates a CSS scalar or math function in an already prepared length environment.

Finite arithmetic overflow aborts through the shared render-budget diagnostic path. Explicit CSS infinity and NaN retain their calculation semantics.

evaluate_color_component(value)

@spec evaluate_color_component(String.t()) :: {:ok, numeric(), dimension()} | :error

Evaluates an absolute color component using the pinned scalar calculation grammar without font or viewport authority.

length_dependencies(value)

@spec length_dependencies(term()) ::
  {:ok, %{units: [String.t()], percentage?: boolean()}}
  | :error
  | {:error, NativeElixirPdfUtilities.Diagnostics.detailed_error()}

Collects unit and percentage dependencies through the shared length calculation grammar.

prepare_length(value, scales)

@spec prepare_length(term(), term()) ::
  {:ok, length_calculation()}
  | :error
  | {:error, NativeElixirPdfUtilities.Diagnostics.detailed_error()}

Prepares a length-percentage calculation while deferring its percentage basis.

referenced_length_units(value)

@spec referenced_length_units(term()) ::
  {:ok, [String.t()]}
  | :error
  | {:error, NativeElixirPdfUtilities.Diagnostics.detailed_error()}

Collects units through the shared grammar after validating a length-percentage type.

resolve_length(calculation, basis)

@spec resolve_length(term(), term()) ::
  {:ok, number()}
  | {:error, NativeElixirPdfUtilities.Diagnostics.detailed_error()}

Evaluates a prepared length against its actual point-valued percentage basis.