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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nokogi...@googlegroups.com
You can ignore this, it was I who was too hasty :/ Sorry