-
-
Notifications
You must be signed in to change notification settings - Fork 901
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 API to set line number, fixes #1657 #1658
Conversation
@fulldecent Please add some tests for this behavior. |
I have some tests here but they are not working. Requesting assistance, I'm in over my head. |
I'm happy to work with anybody on the nokogumbo project who can help me understand what the desired behavior is. But this PR is doing bad things with memory (valgrind picks these up as failures in the test suite) and so the PR is not acceptable even if the tests were passing and the JRuby API was similarly enhanced. |
I haven't had a chance to look closely, but I think my comment gives a pretty good hint.
In nokogumbo, the function setting the line numbers only deals with element, text, CDATA, and comment nodes. I have a comment about it being okay to set small line numbers on CDATA nodes. The first thing I would try is adding conditionals to only set the line number if it is one of text, element, comment, or pi nodes. It'd also be good to double check that I didn't misunderstand what was going on with the |
@stevecheckoway @flavorjones @gjtorikian sorry team, I do not have much technical expertise to add here to this PR. My intention was just to get the correct people in this room and get the PR started with what we already have available. May I please ask:
If we can't get this done then I will be happy to learn so and then I can continue by closing this and going downstream to close dependent items. But it will be much better if we /can/ get this done. |
In order to consider this PR, I would need to see:
and a nice-to-have would be:
Details on the illegal memory access:
|
I'd also like to see more meaningful tests than what's currently present for some classes, e.g.:
and while I understand that the existing legacy tests for |
Honestly, I'm happy to write the C implementation, and even explore the Java implementation, for this feature. But I need tests to tell me what nokogumbo expects the behavior to be. |
Hello. Will the Nokogiri team please clarify if a contribution here is welcome and will be accepted? If so, type of solution will be acceptable? |
I believe this might be fixed upstream. Has anybody here been working on that and if so could you please cross reference? |
@fulldecent What do you mean by upstream here? I just checked the latest version of libxml and there's no API to set line numbers. |
Sorry about that. Here is my reference: stevecheckoway/nokogumbo@e884196 But I see this is incorrect. |
Sorry if what I said earlier on this issue wasn't clear; I would absolutely accept a PR introducing an API to set the line number in libxml2! My expectations are simply that it would need to come with unit tests, and will need to pass the existing Nokogiri test suite which notably runs valgrind's memcheck on all unit tests (see notes above). Because the consumer of the API will primarily be Nokogumbo, I do not expect a JRuby/Xerces/NekoHTML implementation to be submitted. I'm fine with this API call being libxml2-only and the tests being skipped Hope that response makes sense. |
This adds a way to set XML node line numbers.
Why would you want to do that? Constructed nodes. See one implementation that needs this here rubys/nokogumbo#53 (comment)
Sorry, this is maybe a useless contribution, I don't actually know Ruby, just pretending.
This fixes issue #1657.