Add explicit CDATA guard cleanup - #39
Merged
Merged
Conversation
zyc9012
requested changes
Sep 24, 2026
| # and embedded wrappers are returned unchanged. | ||
| # | ||
| # @return [String] | ||
| def unwrapped_text |
Collaborator
There was a problem hiding this comment.
I think the method name is too general.
Maybe unwrapped_cdata_text or unwrap_cdata_text
Contributor
Author
There was a problem hiding this comment.
Addressed in aac2c60: the method is now Node#unwrap_cdata_text, matching its CDATA-specific scope.
I also separated the two transformations noted on the issue. The helper now removes only a complete recognized CDATA guard and preserves whitespace; callers can use node.unwrap_cdata_text.strip when they also want generic surrounding-whitespace cleanup.
zyc9012
approved these changes
Sep 27, 2026
zyc9012
left a comment
Collaborator
There was a problem hiding this comment.
Thank you @Joseph-Mutua! LGTM.
This file contains hidden or 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
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.
Summary
Node#unwrap_cdata_textas an explicit, non-mutating convenience APItext/content, surrounding whitespace, and incomplete, mismatched, or embedded guards unchangedString#stripasnode.unwrap_cdata_text.stripwhen generic surrounding-whitespace cleanup is wantedAPI choice
The CDATA-specific name reflects the method's deliberately narrow responsibility. Whitespace cleanup remains the responsibility of
String#strip, so it behaves consistently for guarded and ordinary text.Validation
bundle exec ruby -Itest -Ispec spec/node_spec.rb— 138 runs, 328 assertionsbundle exec rake test— 312 runs, 4,660 assertionsbundle exec yardoc --no-output lib/nokolexbor/node.rb@zyc9012 @forthrin, this follows the explicit opt-in direction from #31 while keeping normal DOM accessors lossless.
Fixes #31