Module em_filter

em_filter — Public API and HTML Utilities.

Authors: Steve Roques.

Description

em_filter — Public API and HTML Utilities

All nodes in the Emergence system are agents. The Queen connects to em_disco the same way any other agent does.

Handler contract

Every handler module must export:

handle(Body :: binary(), Memory :: map()) -> {Result :: term(), NewMemory :: map()}

Memory is always a live map. Returning the same map as NewMemory is valid for stateless behaviour — no special config needed.

Config map keys (all optional)

capabilities => [binary()] Announced to em_disco via agent_hello. Defaults to [].

memory => ram | ets ram (default): memory lives in the gen_server state and resets to #{} if the worker is restarted. ets: memory is persisted in an ETS table and survives worker restarts within the same BEAM session.

Function Index

base_capabilities/0Returns the root capabilities shared by all em_filter agents.
clean_text/3
decode_hex_entities/1
decode_html_entities/1
decode_named_entities/1
decode_numeric_entities/1
ensure_binary/1
extract_attribute/2
extract_elements/2
get_text/1
resolve_named_entity/1
safe_binary_replace/3
should_skip_link/2
start_agent/3
stop_agent/1
strip_scripts/1

Function Details

base_capabilities/0

base_capabilities() -> [binary()]

Returns the root capabilities shared by all em_filter agents.

clean_text/3

clean_text(D::term(), I::term(), Dt::term()) -> binary()

decode_hex_entities/1

decode_hex_entities(Text::binary()) -> binary()

decode_html_entities/1

decode_html_entities(T::binary()) -> binary()

decode_named_entities/1

decode_named_entities(Text::binary()) -> binary()

decode_numeric_entities/1

decode_numeric_entities(Text::binary()) -> binary()

ensure_binary/1

ensure_binary(B::term()) -> binary()

extract_attribute/2

extract_attribute(E::binary(), Attr::string()) -> {ok, binary()} | error

extract_elements/2

extract_elements(Html::binary(), Selector::string()) -> term()

get_text/1

get_text(E::binary()) -> binary()

resolve_named_entity/1

resolve_named_entity(X1::binary()) -> binary() | undefined

safe_binary_replace/3

safe_binary_replace(S::binary(), P::binary(), R::binary()) -> binary()

should_skip_link/2

should_skip_link(Link::binary(), Excluded::[string()]) -> boolean()

start_agent/3

start_agent(AgentName::atom(), HandlerModule::module(), Config::map()) -> {ok, pid()} | {error, term()}

stop_agent/1

stop_agent(AgentName::atom()) -> ok | {error, term()}

strip_scripts/1

strip_scripts(Html::binary() | string()) -> {ok, binary()} | {error, cleaning_failed}


Generated by EDoc