Fix issue with end of sentence 'disguised' by markup

This commit is contained in:
Thelonius Kort
2023-01-11 22:15:04 +01:00
parent 2d3a511bff
commit cf9118c5ac
2 changed files with 90 additions and 1 deletions

View File

@ -62,6 +62,7 @@ defmodule Outlook.InternalTree.RawInternalBasic do
}
end
)
|> strip_empty_tunits()
end
def partition_inlinelevel([ %InternalNode{type: :element} = node | rest ]) do
@ -73,7 +74,7 @@ defmodule Outlook.InternalTree.RawInternalBasic do
def partition_inlinelevel([ %InternalNode{type: :text} = textnode | rest ]) do
content = if String.contains?(textnode.content, @splitmarker) do
String.split(textnode.content, @splitmarker, trim: true)
String.split(textnode.content, @splitmarker, trim: false)
|> Enum.map(fn cont -> %InternalNode{textnode | content: cont} end)
else
textnode
@ -89,6 +90,22 @@ defmodule Outlook.InternalTree.RawInternalBasic do
def partition_inlinelevel([]), do: []
def strip_empty_tunits([ %TranslationUnit{content: ""} | rest]) do
strip_empty_tunits(rest)
end
def strip_empty_tunits([ %{type: :element} = node | rest]) do
[ %InternalNode{ node | content: strip_empty_tunits(node.content) }
| strip_empty_tunits(rest) ]
end
def strip_empty_tunits([ node | rest]) do
[ node | strip_empty_tunits(rest) ]
end
def strip_empty_tunits([]), do: []
@doc """
iex> chunk_with_list([1, 1, [2, 2], 3, 3, [4, 4, 4], 5, 5])
[[1, 1, 2], [2, 3, 3, 4], [4], [4, 5, 5]]