Now all element node attributes have to be threaded through the eph.attributes which is done by the garnish function.
48 lines
1.2 KiB
Elixir
48 lines
1.2 KiB
Elixir
defmodule Outlook.InternalTree do
|
|
|
|
alias Outlook.InternalTree.{Html,Modifiers,RawInternalBasic,InternalTree,Translation}
|
|
alias Outlook.HtmlPreparations.HtmlPreparation
|
|
|
|
def render_html(tree) do
|
|
tree
|
|
|> HtmlPreparation.strip_whitespace_textnodes()
|
|
|> Html.to_html()
|
|
end
|
|
|
|
def render_html_preview(tree, target \\ "1") do
|
|
tree
|
|
|> Html.to_html_preview(target)
|
|
end
|
|
|
|
require Logger
|
|
def apply_modifier(tree, modifier, nids, opts \\ %{}) do
|
|
# Logger.info modifier
|
|
Modifiers.traverse_tree(tree, modifier, nids, opts)
|
|
end
|
|
|
|
def partition_text(tree) do
|
|
# validate_sibling_collocation(tree)
|
|
tree
|
|
|> RawInternalBasic.set_split_markers()
|
|
|> RawInternalBasic.partition_to_tunits()
|
|
end
|
|
|
|
def garnish(tree, options) do
|
|
options = Enum.reduce(
|
|
~w(el_ids el_names tu_ids)a,
|
|
options,
|
|
fn prop, opts -> Map.put_new(opts, prop, []) end
|
|
)
|
|
options = Enum.reduce(
|
|
~w(elements tunits)a,
|
|
options,
|
|
fn prop, opts -> Map.put_new(opts, prop, %{}) end
|
|
)
|
|
InternalTree.garnish(tree, options)
|
|
end
|
|
|
|
def render_translation(tree, translation) do
|
|
Translation.render_translation(tree, translation)
|
|
end
|
|
end
|