-
-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inner_text joins text without whitespace #636
Comments
I don't think this is a good idea. Would this only impact span tags? What if the tags already have a space between them? What about two spaces? How do you differentiate the There's too much ambiguity, not to mention it would break backwards compatibility. |
That was only an example. Is it the intention for inner_text to concatenate content from separate tags without delineation? |
Ya, it literally just recursively joins the @flavorjones you have any ideas? |
Wouldn't want to break anything, but I'm not imagining a use-case for munging text like that. Should the method accept a block or options perhaps? Webkit appears to use newlines, at least in the console. |
You may want to use the Loofah gem (I wrote it). It's got a #to_text method that inserts whitespace after an inline element, and a newline after a block element. |
Excellent, looks like just what I need. Thanks flavor. |
@tenderlove Please reconsider reopening this one. It's a bug. When I ask for the text of an element, you can't change it. If I have Regarding the ambiguity, you just add one whitespace and that's all. If there's already other whitespaces there, it's up to the user use Had a nasty bug because of this. |
In the meantime, a workaround is using this: |
Whitespace is a language-specific choice for a word separator. There are languages in the world such as Japanese that do not use space for separating words or sentences. As you may know, the XML/HTML and DOM specifications are clear about how to deal with whitespaces, so unless this argument is based on some standards and backward compatibility is fully taken into account, we could never be able to buy it. I, for one, have never seen a DOM API that complements implicit whitespaces between nodes, and I think an XPath equivalent for Nokogiri::HTML(str).xpath('string(.)') #=> "onetwo" |
Firefox
So, whats a problem? What did you expect from |
…er work - see sparklemotion/nokogiri#636 x-path join and split replicates the old behavior. Will look into Loofah gem, but this works for now. Need to modularize the code and get these methods out of the mods metadata datastream
Joining
<span>one</span><span>two</span>
inner_text elements without whitespace results inonetwo
rather thanone two
. Votes for a single space when joining?https://github.com/tenderlove/nokogiri/commit/be67bd3eb17bda8b08a14a512980983691376c65#lib/nokogiri/xml/node_set.rb-P7
The text was updated successfully, but these errors were encountered: