Class: WhiteSpaceFilter

WhiteSpaceFilter(chunker, polisher, caller)

Filters and normalizes whitespace-only text nodes that are not visually meaningful.

Removes or replaces ignorable text nodes (e.g., extra line breaks, tabs, or spaces) except in contexts where whitespace is meaningful (e.g., inside <pre> tags).

Constructor

new WhiteSpaceFilter(chunker, polisher, caller)

Create a WhiteSpaceFilter instance.

Create a WhiteSpaceFilter instance.

Parameters:
Name Type Description
chunker Object

Handles document chunking.

polisher Object

Handles CSS polishing/styling.

caller Object

The invoking processor or engine.

Source:

Extends

  • Handler

Methods

filter(content)

Filters out or normalizes ignorable whitespace-only text nodes from content.

Filters out or normalizes ignorable whitespace-only text nodes from content.

Parameters:
Name Type Description
content DocumentFragment | HTMLElement

The DOM content to filter.

Source:

filterEmpty(node) → {number}

Determines whether a text node should be removed or normalized.

Determines whether a text node should be removed or normalized. Replaces content with a single space if it's between significant siblings, and removes the node if it's safe to do so.

Parameters:
Name Type Description
node Text

The text node to evaluate.

Source:
Returns:

A NodeFilter constant indicating filter behavior.

Type
number