Cleanup some code

This commit is contained in:
Thelonius Kort
2023-01-04 15:27:30 +01:00
parent 9a7dc7cf80
commit 49b72cbf68
2 changed files with 10 additions and 7 deletions

View File

@ -56,7 +56,7 @@ defmodule Outlook.InternalTree.RawInternalBasic do
Logger.info "inline_tree #{inline_tree |> inspect}" Logger.info "inline_tree #{inline_tree |> inspect}"
partition_inlinelevel(inline_tree) partition_inlinelevel(inline_tree)
|> chunk_with_list() |> chunk_with_list()
|> Html.strip_attributes # to be implemented |> Html.strip_attributes
|> Enum.map(fn sentence -> |> Enum.map(fn sentence ->
%TranslationUnit{ %TranslationUnit{
content: Html.to_html(sentence), content: Html.to_html(sentence),

View File

@ -5,13 +5,11 @@ defmodule Outlook.InternalTreeTest do
describe "internal_tree" do describe "internal_tree" do
alias Outlook.InternalTree alias Outlook.InternalTree
alias Outlook.InternalTree.{InternalNode,Html,Basic,TranslationUnit} alias Outlook.InternalTree.{InternalNode,TranslationUnit}
import Outlook.ArticlesFixtures
@default_uuid "11111111-1111-1111-1111-111111111111" @default_uuid "11111111-1111-1111-1111-111111111111"
test "partition_text/1 returns correctly dingens..." do test "partition_text/1 returns correctly partitioned text without overlapping markup" do
tree = [ tree = [
%InternalNode{ %InternalNode{
name: "p", name: "p",
@ -79,14 +77,19 @@ defmodule Outlook.InternalTreeTest do
eph: %{sibling_with: :block} eph: %{sibling_with: :block}
} }
] ]
assert InternalTree.partition_text(tree) |> unify_uuids_in_tunits() == [ assert InternalTree.partition_text(tree) |> unify_uuids_in_tunits() == [
%InternalNode{name: "p", attributes: %{}, type: :element, uuid: "8293da39-18e3-4695-8ec5-a3a4a06f006c", %InternalNode{name: "p", attributes: %{}, type: :element, uuid: "8293da39-18e3-4695-8ec5-a3a4a06f006c",
content: [ content: [
%TranslationUnit{status: :untranslated, uuid: @default_uuid, %TranslationUnit{status: :untranslated, uuid: @default_uuid,
content: "A sentence with many letters <a href=\"dingsda.com\">and many, many <b>words. </b></a>"}, content: "A sentence with many letters <a href=\"dingsda.com\">and many, many <b>words. </b></a>"},
%TranslationUnit{status: :untranslated, uuid: @default_uuid, %TranslationUnit{status: :untranslated, uuid: @default_uuid,
content: "<a href=\"dingsda.com\"><b>A</b> sentence</a> with many letters and many, many words. "}], content: "<a href=\"dingsda.com\"><b>A</b> sentence</a> with many letters and many, many words. "}
eph: %{sibling_with: :block}}] ],
eph: %{sibling_with: :block}
}
]
end
test "partition_text/1 doesn't split numbers and abbreviated names" do test "partition_text/1 doesn't split numbers and abbreviated names" do
tree = [ tree = [