Sablon.HTMLConverter.ASTBuilder (sablon v0.4.3)

Copy Markdown View Source

Converts an HTML tree into the AST the WordML writer consumes.

Every element is looked up in Sablon.Configuration; tags with an AST class are handed to it, tags without one disappear and pass their properties down to their children. The nesting rules registered with each tag are enforced here, so invalid markup fails loudly instead of producing a document Word refuses to open.

Summary

Functions

Returns true when any of nodes is a block level tag.

Looks a tag up in the configuration, raising when it is not registered.

Converts nodes into AST nodes, seeding them with properties.

Functions

any_block_tags?(nodes)

@spec any_block_tags?([Sablon.XML.Node.t()]) :: boolean()

Returns true when any of nodes is a block level tag.

fetch_tag(tag_name)

@spec fetch_tag(atom() | binary()) :: Sablon.Configuration.HTMLTag.t()

Looks a tag up in the configuration, raising when it is not registered.

html_to_ast(env, nodes, properties)

@spec html_to_ast(Sablon.Environment.t(), [Sablon.XML.Node.t()], Sablon.Props.t()) ::
  [struct()]

Converts nodes into AST nodes, seeding them with properties.