NativeElixirPdfUtilities.Validators.HtmlValidator (native_elixir_pdf_utilities v1.1.0)

View Source

Native HTML validation, stage input contracts and shared resource accounting.

Rendering stages use this internal validator as the source of truth for admitted structures and budgets. Applications should use NativeElixirPdfUtilities.HtmlToPdf.

Summary

Types

Canonical document canvas decision from computed root/body styles.

Functions

Returns comment-normalized CSS and byte gaps for mapping spans to the authored source.

Returns CSS lexical units with quoted strings and escapes kept opaque for component parsing.

Decodes the contents of an already validated CSS string token.

Resolves applicable editing keywords; non-root foreign elements stop editing inheritance.

Returns static popover box defaults without inferring activation or top-layer state.

Prepares iframe dimensions and legacy border suppression before author CSS.

Internal resolution of an already validated styled tree's canvas plan or legacy body-only canvas before allocation.

Normalizes comments without joining CSS tokens; syntax mode retains non-whitespace boundaries.

Parses balanced CSS variable references and fallback dependencies without substitution.

Parses HTML's permissive list-of-floating-point-numbers microsyntax using the shared scalar parser.

Parses a legacy browser attribute using its fixed signed 32-bit conversion invariant.

Prepares source length grammar with symbolic unit and percentage dependencies, without measured scales.

Prepares variable syntax and source dependencies without substituting an inherited value.

Internal canvas selection from computed CSS styles; a painted root keeps body paint on its own box.

Prepares validated page geometry and margins for a styled document and layout options.

Releases the exact DOM validation memo after its style preparation has completed.

Checks authored control content or the initial DOM after selected-content copying.

Validates the canonical positive orphan and widow counts carried by one source paragraph.

Validates a prepared CSS size expression using the shared numeric, depth and work bounds.

Types

document_canvas()

@type document_canvas() :: %{style: map(), body_background_propagated: boolean()}

Canonical document canvas decision from computed root/body styles.

image_budget()

@type image_budget() :: :atomics.atomics_ref()

Functions

css_comment_projection(source, mode \\ :syntax)

@spec css_comment_projection(String.t(), :syntax | :value) ::
  {String.t(), [{non_neg_integer(), non_neg_integer()}]}

Returns comment-normalized CSS and byte gaps for mapping spans to the authored source.

css_component_units(source)

@spec css_component_units(String.t()) :: [String.t()]

Returns CSS lexical units with quoted strings and escapes kept opaque for component parsing.

decode_css_string(token)

@spec decode_css_string(String.t()) :: String.t()

Decodes the contents of an already validated CSS string token.

html_editing_state(node)

@spec html_editing_state(map()) :: :editable | :not_editable | :inherit

Resolves applicable editing keywords; non-root foreign elements stop editing inheritance.

html_popover_defaults(attributes, tag, font_size)

@spec html_popover_defaults(map(), String.t(), number()) :: map()

Returns static popover box defaults without inferring activation or top-layer state.

iframe_hints(attributes)

@spec iframe_hints(term()) ::
  {:ok, map()}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Prepares iframe dimensions and legacy border suppression before author CSS.

layout_canvas(tree)

Internal resolution of an already validated styled tree's canvas plan or legacy body-only canvas before allocation.

normalize_css_comments(source, mode \\ :syntax)

@spec normalize_css_comments(String.t(), :syntax | :value) :: String.t()

Normalizes comments without joining CSS tokens; syntax mode retains non-whitespace boundaries.

parse_css_variable_references(value)

@spec parse_css_variable_references(String.t()) ::
  {:ok, [map()]}
  | :error
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Parses balanced CSS variable references and fallback dependencies without substitution.

parse_html_float_list(value)

@spec parse_html_float_list(String.t()) :: [float()]

Parses HTML's permissive list-of-floating-point-numbers microsyntax using the shared scalar parser.

parse_html_legacy_int32(value)

@spec parse_html_legacy_int32(term()) :: {:ok, integer()} | :error

Parses a legacy browser attribute using its fixed signed 32-bit conversion invariant.

prepare_css_length_source(value, context \\ :nonnegative)

@spec prepare_css_length_source(
  String.t(),
  :nonnegative | :margin | :length | :signed_length
) ::
  {:ok, map() | :auto}
  | :error
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Prepares source length grammar with symbolic unit and percentage dependencies, without measured scales.

prepare_css_variable_source(value, budget)

@spec prepare_css_variable_source(String.t(), :atomics.atomics_ref()) ::
  {:ok, [map()]}
  | :error
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Prepares variable syntax and source dependencies without substituting an inherited value.

prepare_document_canvas(root_style, body_style)

@spec prepare_document_canvas(map() | nil, map() | nil) :: document_canvas()

Internal canvas selection from computed CSS styles; a painted root keeps body paint on its own box.

prepare_layout_input(styled_tree, opts)

@spec prepare_layout_input(term(), term()) ::
  {:ok,
   %{
     page_size: {number(), number()},
     margins:
       NativeElixirPdfUtilities.Validators.PageGeometryValidator.margins()
   }}
  | {:error,
     atom() | {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Prepares validated page geometry and margins for a styled document and layout options.

release_style_input(dom)

@spec release_style_input(map()) :: :ok

Releases the exact DOM validation memo after its style preparation has completed.

valid_form_element?(tag, attributes, children, surface)

@spec valid_form_element?(String.t(), map(), [term()], :authored | :initial_dom) ::
  boolean()

Checks authored control content or the initial DOM after selected-content copying.

validate_paragraph_line_counts(box, stage)

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

Validates the canonical positive orphan and widow counts carried by one source paragraph.

validate_prepared_css_size(value, context \\ :width)

@spec validate_prepared_css_size(term(), term()) ::
  :ok | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Validates a prepared CSS size expression using the shared numeric, depth and work bounds.