From f4b5abef5a4b9b7e715438e46003a4cbe0671d1c Mon Sep 17 00:00:00 2001 From: Thelonius Kort Date: Wed, 4 Jan 2023 14:26:38 +0100 Subject: [PATCH] Update to_html/1 to accept maps instead of only %InternalNode{}s --- lib/outlook/internal_tree/html.ex | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/outlook/internal_tree/html.ex b/lib/outlook/internal_tree/html.ex index 888e42d..aff0828 100644 --- a/lib/outlook/internal_tree/html.ex +++ b/lib/outlook/internal_tree/html.ex @@ -22,24 +22,23 @@ defmodule Outlook.InternalTree.Html do def strip_attributes([]), do: [] - def to_html([ %InternalNode{type: :element} = node | rest]) do - attr_string = Map.put(node.attributes, :uuid, node.uuid) - |> Enum.map_join(" ", fn {k,v} -> "#{k}=\"#{v}\"" end) - "<#{node.name} #{attr_string}>" <> + def to_html([%{type: :element} = node | rest]) do + attr_string = Enum.map_join(node.attributes, "", fn {k,v} -> " #{k}=\"#{v}\"" end) + "<#{node.name}#{attr_string}>" <> to_html(node.content) <> "" <> to_html(rest) end - def to_html([ %InternalNode{type: :text} = node | rest]) do + def to_html([%{type: :text} = node | rest]) do node.content <> to_html(rest) end - def to_html([ %InternalNode{type: :comment} = node | rest]) do + def to_html([%{type: :comment} = node | rest]) do "" <> to_html(rest) end - def to_html([ %TranslationUnit{} = tunit | rest]) do + def to_html([%TranslationUnit{} = tunit | rest]) do ~s(#{tunit.content}) <> to_html(rest) end