Implement xsl:output indent="yes" (resolves #219). - #220
Merged
Conversation
`xmlTransformedText` ignored the indent attribute entirely, so `<xsl:output indent="yes"/>` had no effect on the result tree serialization. Elements are now pretty-printed (2-space indent) when `indent="yes"` and all of an element's children are elements, comments, or processing instructions (i.e. no significant text), so mixed content is left untouched to avoid corrupting text values. `xsl:result-document` accepts its own indent attribute, falling back to `xsl:output` when unspecified. Several existing tests declared `indent="yes"` without any assertion depending on it (a leftover from indent being a no-op); their expected strings are updated to the now-correct indented output. Bumps `src/xpath/lib` submodule to DesignLiquido/xpath@39bb40d.
Coverage report
Test suite run success681 tests passing in 67 suites. Report generated by 🧪jest coverage report action from 5fa47a4 |
Contributor
There was a problem hiding this comment.
Pull request overview
Implements support for xsl:output indent="yes" (and per-xsl:result-document overrides) by threading an indent flag into XML/HTML serialization and updating expectations across affected tests.
Changes:
- Add
indentto serialization options and plumb it fromxsl:outputandxsl:result-document. - Implement pretty-printing in
xmlTransformedTextwith a 2-space indentation rule that avoids mixed-content corruption. - Update and add tests to assert the new indentation behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/xslt/xslt.test.tsx | Updates expected serialized output strings to match new pretty-print behavior. |
| tests/xslt/output-indent.test.ts | Adds focused test coverage for xsl:output / xsl:result-document indentation behavior. |
| tests/xslt/include.test.tsx | Updates expected included-stylesheet output to include indentation/newlines. |
| tests/xslt/import.test.tsx | Updates expected imported-stylesheet output to include indentation/newlines. |
| tests/xslt/choose.test.tsx | Updates expected outputs to reflect indentation when indent="yes" is present. |
| tests/lmht/lmht.test.tsx | Updates LMHT-related expectations to match indented serialization. |
| tests/lmht/html-to-lmht.test.tsx | Updates HTML→LMHT transformation expectations to match indented serialization. |
| src/xslt/xslt.ts | Parses/stores indent from xsl:output and applies per-xsl:result-document override. |
| src/dom/xml-output-options.ts | Extends XmlOutputOptions with optional indent and documents behavior. |
| src/dom/xml-functions.ts | Implements indentation logic during DOM serialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
xmlTransformedTextignored the indent attribute entirely, so<xsl:output indent="yes"/>had no effect on the result tree serialization.Elements are now pretty-printed (2-space indent) when
indent="yes"and all of an element's children are elements, comments, or processing instructions (i.e. no significant text), so mixed content is left untouched to avoid corrupting text values.xsl:result-documentaccepts its own indent attribute, falling back toxsl:outputwhen unspecified.Several existing tests declared
indent="yes"without any assertion depending on it (a leftover from indent being a no-op); their expected strings are updated to the now-correct indented output.Bumps
src/xpath/libsubmodule to DesignLiquido/xpath@39bb40d.