Add support for img tags

This commit is contained in:
Thelonius Kort
2023-01-15 17:27:51 +01:00
parent b520df2561
commit f2dd8de143
4 changed files with 98 additions and 1 deletions

View File

@ -208,5 +208,83 @@ defmodule Outlook.InternalTreeTest do
}
]
end
test "img tag won't be considered an empty element" do
tree = [
%Outlook.InternalTree.InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "cGK7c5koxnjH",
content: [
%Outlook.InternalTree.InternalNode{
name: "img",
attributes: %{src: "/images/flower.png"},
type: :element,
nid: "druVejfHcuX7",
content: [],
eph: %{sibling_with: :inline}
}
],
eph: %{sibling_with: :block}
}
]
assert InternalTree.partition_text(tree) |> unify_nids_in_tunits() == [
%Outlook.InternalTree.InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "cGK7c5koxnjH",
content: [
%Outlook.InternalTree.TranslationUnit{
status: :untranslated,
nid: "xxxxxx",
content: "<img src=\"/images/flower.png\">",
eph: %{}
}
],
eph: %{sibling_with: :block}
}
]
end
test "br tag won't be considered an empty element" do
tree = [
%Outlook.InternalTree.InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "cGK7c5koxnjH",
content: [
%Outlook.InternalTree.InternalNode{
name: "br",
attributes: %{},
type: :element,
nid: "druVejfHcuX7",
content: [],
eph: %{sibling_with: :inline}
}
],
eph: %{sibling_with: :block}
}
]
assert InternalTree.partition_text(tree) |> unify_nids_in_tunits() == [
%Outlook.InternalTree.InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "cGK7c5koxnjH",
content: [
%Outlook.InternalTree.TranslationUnit{
status: :untranslated,
nid: "xxxxxx",
content: "<br>",
eph: %{}
}
],
eph: %{sibling_with: :block}
}
]
end
end
end