Skip to content

Parse innerXml correctly if there is another tag directly after the closing tag - #8

Closed
sth wants to merge 7 commits into
clipcrow:masterfrom
sth:inner-xml-nospace
Closed

sth wants to merge 7 commits into
clipcrow:masterfrom
sth:inner-xml-nospace

Conversation

@sth

@sth sth commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

In this case the closing tag is currently not recognized correctly and not removed from the captured xml fragment.

sth added 7 commits April 8, 2026 01:05
* Test input stream with multiple chunks

* Handle encoding when using `SAXParser` as an `UnderlyingSink`

* Not all types are processed

* Add parsing of `ReadableStream<string>`

* Polishing
* Add test to make sure entities are decoded

* Test if numeric entities are decoded

* Decode numeric entities
Currently they are left unchanged. Other options are possible, like
throwing an error or somehow calling a user supplied function to resolve
the entities, but for now keep it as is.
* Test for recursive decoding of entities

* Don't decode entities recursively
* Add functions to collect raw stream data on demand

Can be used to implement something like `innerHtml()`

* Add test for input collection

* Move input collection to parser state

* Add tests for input collection over multiple chunks

* Simplify input collection

* Use a class for collection tokens instead of a plain number

* On collection result emit an `inner_xml` event

* Fox indentation

* More systematic test cases for innerXML

* Renaming

* Directly extract proper innerXML in context function

* Add comment for future improvements

* Some cleanup

* Better order of classes
* Preserve white space in text

The XML spec says that white space should be preserved and losing white
space can be problematic especially in mixed content nodes, like for
example `<span><i>some</i> <b>text</b></span>`.

If more flexibility in white space handling is desired, one possibility
would be to add a config option to the parser that selects the desired
white space mode.

* Add test for white space handling
If there is another tag directly after the closing tag, we currently
don't strip the closing tag.
@sth
sth marked this pull request as draft July 29, 2026 22:20
@sth

sth commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, I didn't mean open this pull request here

@sth sth closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant