Add support for img tags
This commit is contained in:
@ -10,6 +10,7 @@ defmodule Outlook.InternalTree.RawInternalBasic do
|
||||
|
||||
@splitmarker "@@translationunit@@"
|
||||
@nonperiodmarker "@@nonperiod@@"
|
||||
@void_elements ~w(img br hr)
|
||||
|
||||
def set_split_markers([ %InternalNode{type: :text} = textnode | rest ]) do
|
||||
[ %InternalNode{textnode |
|
||||
@ -68,9 +69,14 @@ defmodule Outlook.InternalTree.RawInternalBasic do
|
||||
|> strip_empty_tunits()
|
||||
end
|
||||
|
||||
def partition_inlinelevel([ node | rest ]) when node.name in @void_elements do
|
||||
[ node | partition_inlinelevel(rest) ]
|
||||
end
|
||||
|
||||
def partition_inlinelevel([ %InternalNode{type: :element} = node | rest ]) do
|
||||
[ partition_inlinelevel(node.content)
|
||||
|> chunk_with_list()
|
||||
# elements without content are being dropped here
|
||||
|> Enum.map(fn nodelist -> %InternalNode{node | content: nodelist} end)
|
||||
| partition_inlinelevel(rest) ]
|
||||
end
|
||||
@ -93,7 +99,7 @@ defmodule Outlook.InternalTree.RawInternalBasic do
|
||||
def partition_inlinelevel([]), do: []
|
||||
|
||||
|
||||
def strip_empty_nodes([%{type: :element} = node | rest]) when node.name in ~w(img br) do
|
||||
def strip_empty_nodes([%{type: :element} = node | rest]) when node.name in @void_elements do
|
||||
[ node | strip_empty_nodes(rest) ]
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user