Sanitize HtmlTreeComponent

This commit is contained in:
Thelonius Kort
2023-01-27 12:02:29 +01:00
parent 13c08918cc
commit f76f218652
4 changed files with 21 additions and 55 deletions

View File

@ -11,10 +11,4 @@ defmodule Outlook.HtmlPreparations do
|> HtmlPreparation.floki_to_internal
|> HtmlPreparation.set_sibling_with
end
def get_tree_items(content_tree) do
content_tree
|> HtmlPreparation.strip_whitespace_textnodes
|> HtmlPreparation.build_indentation_list(0)
end
end

View File

@ -90,20 +90,4 @@ defmodule Outlook.HtmlPreparations.HtmlPreparation do
end
def strip_whitespace_textnodes([]), do: []
def build_indentation_list [ %{type: :element} = node | rest], level do
[ %{node: Map.replace(node, :content, []), level: level}
| [ build_indentation_list(node.content, level + 1)
| build_indentation_list(rest, level)
]
] |> List.flatten
end
def build_indentation_list [ node | rest ], level do
[ %{node: node, level: level}
| build_indentation_list( rest, level ) ]
end
def build_indentation_list([ ], _), do: []
end