lib/draftjs_html/node.rb in draftjs_html-0.8.0 vs lib/draftjs_html/node.rb in draftjs_html-0.9.0
- old
+ new
@@ -16,10 +16,10 @@
StringNode = Struct.new(:raw) do
def to_nokogiri(document)
lines = raw.lines
text_nodes = lines.flat_map.with_index do |text, i|
nodes = [Nokogiri::XML::Text.new(text.chomp, document)]
- nodes << Nokogiri::XML::Node.new('br', document) if i < lines.size - 1
+ nodes << Nokogiri::XML::Node.new('br', document) if text.end_with?("\n")
nodes
end
Nokogiri::XML::NodeSet.new(document, text_nodes)
end