Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Include line numbers from the parser. #55

Merged
merged 1 commit into from Sep 2, 2018

Conversation

stevecheckoway
Copy link
Collaborator

Neither libxml2 nor Nokogiri contain an API for setting the line numbers
for a node. When the libxml2 headers are available, the line numbers can
be set directly in the node structure.

@fulldecent
Copy link
Contributor

Are there any reservations about merging this PR?

@stevecheckoway
Copy link
Collaborator Author

The reservation that I have is nokogumbo works correctly (although slower) even when libxml2 headers are not available. This PR introduces a behavioral difference.

@fulldecent
Copy link
Contributor

Reference for 65535 problem:

sparklemotion/nokogiri#533

@rubys
Copy link
Owner

rubys commented Sep 2, 2018

This PR introduces a behavioral difference.

FWIW, I'm OK with this difference, as long as it is documented.

@stevecheckoway
Copy link
Collaborator Author

Okay. I'll add this.

I just pushed a substantial rewrite to this code that no longer uses recursion to add the elements starting with the leaves. Instead, it starts building the tree in pre-order (which was what your original implementation did, iirc). This was to work around some Nokogiri limitations regarding namespaces (which we now support).

But this should be easy enough to redo. I think it's best if we just give up on line numbers greater than 65534 since the correct behavior depends on how libxml2 is built and it doesn't work for every type of node.

Neither libxml2 nor Nokogiri contain an API for setting the line numbers
for a node. When the libxml2 headers are available, the line numbers can
be set directly in the node structure.

Closes: rubys#53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants