Nokogiri::HTML::DocumentFragment.parse invalid trimming of text nodes

18 views
Skip to first unread message

Erik Johansson

unread,
Jan 20, 2012, 3:14:18 AM1/20/12
to nokogi...@googlegroups.com
I'm parsing a document and want to modify some text nodes. The code is pretty much:
node.xpath('.//text() | ./text()').each do |text|
string = text.text
....
text.replace Nokogiri::HTML::DocumentFragment.parse(string)
end

The issue here is that the text node has a trailing space (as it's part of a greater whole) but Nokogiri just kills the space with DocumentFragment.parse. Is there any way to work around this? I personally think that trimming by default, more often that not, results in weird results.

Erik Johansson

unread,
Jan 20, 2012, 3:20:00 AM1/20/12
to nokogi...@googlegroups.com
You can ignore this, it was I who was too hasty :/
Sorry
Reply all
Reply to author
Forward
0 new messages