Hello ๐
I'm currently using your awesome library to do a TextDelta to HTML converter on the backend side.
When converting a particular document to lines
, I noticed some attributes were lost in translation.
Sample unexpected output
input_textdelta = %TextDelta{
ops: [
%{insert: "\nTitle 1"},
%{attributes: %{header: 1}, insert: "\n"},
%{insert: "\nTitle 2"},
%{attributes: %{header: 1}, insert: "\n\n"},
%{insert: "\n"}
]
}
TextDelta.lines(input_textdelta)
# Outputs:
{:ok,
[
{%TextDelta{ops: []}, %{}},
{%TextDelta{ops: [%{insert: " Title 1"}]}, %{header: 1}},
{%TextDelta{ops: []}, %{}},
{%TextDelta{ops: [%{insert: " Title 2"}]}, %{}}, # <=== Here, we're missing the attribute `header: 1`
{%TextDelta{ops: []}, %{}}, # <=== Here as well. ๐ค
{%TextDelta{ops: []}, %{}}
]}
As you can see, the %{header: 1}
attribute has been lost on Title 2
and the subsequent line. This only seems to happen on the last lines of the document. The rest of the document is properly separated into lines.
What makes me say it's a potential bug is that when comparing with the HTML output of QuillJS, this generates the following HTML:
<p><br><p>
<h1>Title 1</h1>
<p><br><p>
<h1>Title 2</h1>
<h1><br></h1>
<p><br><p>
I'll see if I can provide a pull request fixing the issue and thanks again for this awesome library ๐ป