-
-
Notifications
You must be signed in to change notification settings - Fork 902
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
Add Nokogiri::XML::Node#line=
#1918
Conversation
Add support for setting the line number on elements from Ruby. This only works when Nokogiri uses `libxml2`. Line numbers less than 65535 may be set. Larger line numbers require `libxml2` to be compiled with a particular option and even then, it is buggy. See https://bugzilla.gnome.org/show_bug.cgi?id=767138.
Code Climate has analyzed commit a730f85 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (80% is the threshold). This pull request will bring the total coverage in the repository to 93.8% (0.0% change). View more on Code Climate. |
Thanks for submitting this, I'll do my best to take a look in the next day or so. |
Any updates on this? |
@gjtorikian thanks for poking. my personal life is nuts right now and have had limited time to devote to new-feature and PR velocity (have only managed to get security-related updates out for some packages). I'm aligned with this feature but haven't had time to review details and merge it. That said, I expect this will be in v1.11.0 and have tagged it for that milestone. ETA is in the next week or two (optimistically). |
Ah, no worries. Self care is important and I hope things settle down for you. 💜 |
Thanks for your patience. Merging. Will be in v1.11.0, due out in late December (coincident with the Ruby 2.7 release). |
Please note that this was included in v1.11.0.rc1, so if you want to test, you can use that version. |
Great, thanks! |
Add support for setting the line number on elements from Ruby. This only
works when Nokogiri uses
libxml2
.Line numbers less than 65535 may be set. Larger line numbers require
libxml2
to be compiled with a particular option and even then, it isbuggy. See https://bugzilla.gnome.org/show_bug.cgi?id=767138.
Thank you for contributing to Nokogiri! To help us prioritize, please take care to answer the questions below when you submit this pull request.
What problem is this PR intended to solve?
This PR is intended to solve the issues for downstream projects. In particular, gjtorikian/html-proofer#362 in html-proofer which is preventing that from using Nokogumbo for HTML5 parsing.
This implementation is similar to #1658 (which I think was broken because the option,
XML_PARSE_BIG_LINES
, mentioned in #1764 is not used). This version simply limits the number of lines to a maximum of 65534. This limitation could be removed ifXML_PARSE_BIG_LINES
is used, but that could be done later.Note that the implementation of
set_line()
is slightly different from #1658 which returnsself
rather than the argument.set_native_content()
andset_name
return the argument so I followed that approach.Have you included adequate test coverage?
It is tested in the same manner as
Nokogiri::XML::Node#line
. (I think that should be better tested, but JRuby's line number heuristic seems like it would be easy to break and I'm not sure how to use JRuby to test.)Does this change affect the C or the Java implementations?
This effects the C version only. The Java version uses a heuristic to get line numbers but that heuristic doesn't quite work.