Global, mutable configuration for HTML conversion.
Mirrors the Sablon::Configuration singleton of the Ruby gem: it stores the
set of permitted HTML tags and the CSS -> WordML property converters, both
of which can be extended or replaced at runtime.
Sablon.configure(fn ->
Sablon.Configuration.register_html_tag(:bgcyan, :inline, properties: [highlight: "cyan"])
end)
Summary
Functions
Returns a specification to start this module under a supervisor.
Runs the converter registered for ast_node/prop_name on value.
The tag table sablon starts with.
The CSS -> WordML converters sablon starts with.
All registered style converters, keyed by AST node name.
Looks up a tag definition, returning nil when it is not registered.
Returns the full configuration state.
All permitted HTML tags, keyed by tag name.
Adds a tag definition or replaces an existing one.
Registers a CSS property converter for an AST node.
Removes a tag definition, returning it.
Removes a CSS property converter.
Restores the built-in defaults, discarding every customisation.
The converters registered for a single AST node, e.g. :run.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Runs the converter registered for ast_node/prop_name on value.
Built-in converters use this for the shared helpers (:_border, :_sz),
so overriding a helper also changes every converter that builds on it.
@spec default_html_tags() :: %{required(atom()) => Sablon.Configuration.HTMLTag.t()}
The tag table sablon starts with.
@spec default_style_conversions() :: map()
The CSS -> WordML converters sablon starts with.
@spec defined_style_conversions() :: map()
All registered style converters, keyed by AST node name.
@spec html_tag(atom() | binary()) :: Sablon.Configuration.HTMLTag.t() | nil
Looks up a tag definition, returning nil when it is not registered.
@spec instance() :: map()
Returns the full configuration state.
@spec permitted_html_tags() :: %{required(atom()) => Sablon.Configuration.HTMLTag.t()}
All permitted HTML tags, keyed by tag name.
@spec register_html_tag(atom() | binary(), :inline | :block, keyword()) :: Sablon.Configuration.HTMLTag.t()
Adds a tag definition or replaces an existing one.
@spec register_style_converter(atom(), binary() | atom(), style_converter()) :: :ok
Registers a CSS property converter for an AST node.
ast_node is the AST class name in lowercased snake case (Run ->
:run), prop_name the CSS property and converter a one-argument
function returning a {wordml_property, value} tuple.
@spec remove_html_tag(atom() | binary()) :: Sablon.Configuration.HTMLTag.t() | nil
Removes a tag definition, returning it.
Removes a CSS property converter.
@spec reset() :: :ok
Restores the built-in defaults, discarding every customisation.
The converters registered for a single AST node, e.g. :run.