-
Notifications
You must be signed in to change notification settings - Fork 65
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
Do not output :text event after the root tag is closed #167
Merged
kou
merged 1 commit into
ruby:master
from
naitoh:do_not_outpu_text_event_after_the_root_tag_is_closed
Jul 12, 2024
Merged
Do not output :text event after the root tag is closed #167
kou
merged 1 commit into
ruby:master
from
naitoh:do_not_outpu_text_event_after_the_root_tag_is_closed
Jul 12, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kou
reviewed
Jul 11, 2024
test/parse/test_text.rb
Outdated
events[event[0]] = event[1] | ||
end | ||
|
||
assert_equal("b", events[:text]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check all :text
event values instead of the last :text
event value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
I see.
## Why? GitHub: fix rubyGH-163 ## Change - sax_test.rb ``` require 'rexml/parsers/sax2parser' require 'rexml/parsers/pullparser' require 'rexml/parsers/streamparser' require 'libxml-ruby' require 'nokogiri' xml = <<EOS <root> a b c </root> <!-- ok comment --> <?abc version="1.0" ?> EOS class Listener def method_missing(name, *args) p [name, *args] end end puts "LibXML(SAX)" parser = LibXML::XML::SaxParser.string(xml) parser.callbacks = Listener.new parser.parse puts "" puts "Nokogiri(SAX)" parser = Nokogiri::XML::SAX::Parser.new(Listener.new) parser.parse(xml) puts "" puts "REXML(SAX)" parser = REXML::Parsers::SAX2Parser.new(xml) parser.listen(Listener.new) parser.parse puts "" puts "REXML(Pull)" parser = REXML::Parsers::PullParser.new(xml) while parser.has_next? res = parser.pull p res end puts "" puts "REXML(Stream)" parser = REXML::Parsers::StreamParser.new(xml, Listener.new).parse ``` ## Before (rexml 3.3.1) ``` LibXML(SAX) [:on_start_document] [:on_start_element_ns, "root", {}, nil, nil, {}] [:on_characters, " a b c \n"] [:on_end_element_ns, "root", nil, nil] [:on_comment, " ok comment "] [:on_processing_instruction, "abc", "version=\"1.0\" "] [:on_end_document] Nokogiri(SAX) [:start_document] [:start_element_namespace, "root", [], nil, nil, []] [:characters, " a b c \n"] [:end_element_namespace, "root", nil, nil] [:comment, " ok comment "] [:processing_instruction, "abc", "version=\"1.0\" "] [:end_document] REXML(SAX) [:start_document] [:start_element, nil, "root", "root", {}] [:progress, 6] [:characters, " a b c \n"] [:progress, 15] [:end_element, nil, "root", "root"] [:progress, 22] [:characters, "\n"] [:progress, 23] [:comment, " ok comment "] [:progress, 42] [:characters, "\n"] [:progress, 43] [:processing_instruction, "abc", " version=\"1.0\" "] [:progress, 65] [:characters, "\n"] [:progress, 66] [:end_document] REXML(Pull) start_element: ["root", {}] text: [" a b c \n", " a b c \n"] end_element: ["root"] text: ["\n", "\n"] comment: [" ok comment "] text: ["\n", "\n"] processing_instruction: ["abc", " version=\"1.0\" "] text: ["\n", "\n"] REXML(Stream) [:tag_start, "root", {}] [:text, " a b c \n"] [:tag_end, "root"] [:text, "\n"] [:comment, " ok comment "] [:text, "\n"] [:instruction, "abc", " version=\"1.0\" "] [:text, "\n"] ``` ## After(This PR) ``` REXML(SAX) [:start_document] [:start_element, nil, "root", "root", {}] [:progress, 6] [:characters, " a b c \n"] [:progress, 15] [:end_element, nil, "root", "root"] [:progress, 22] [:comment, " ok comment "] [:progress, 42] [:processing_instruction, "abc", " version=\"1.0\" "] [:progress, 65] [:end_document] REXML(Pull) start_element: ["root", {}] text: [" a b c \n", " a b c \n"] end_element: ["root"] comment: [" ok comment "] processing_instruction: ["abc", " version=\"1.0\" "] end_document: [] REXML(Stream) [:tag_start, "root", {}] [:text, " a b c \n"] [:tag_end, "root"] [:comment, " ok comment "] [:instruction, "abc", " version=\"1.0\" "] ```
naitoh
force-pushed
the
do_not_outpu_text_event_after_the_root_tag_is_closed
branch
from
July 11, 2024 23:56
8cfaf49
to
2054024
Compare
kou
changed the title
Do not output :text event after the root tag is closed.
Do not output :text event after the root tag is closed
Jul 12, 2024
Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why?
GitHub: fix GH-163
Change
Before (rexml 3.3.1)
After(This PR)