Skip to content

docs: clarify toString($format) and no_blanks interaction (GH #234) - #285

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/docs-tostring-format-blanks
Draft

toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/docs-tostring-format-blanks

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

Add documentation clarifying that toString($format) only re-indents output when whitespace-only text nodes are absent.

Why

Users commonly expect toString(1) to pretty-print any parsed document (see GH #234, StackOverflow #7215316). The formatter respects existing text content, so documents parsed with default settings retain their original whitespace text nodes, preventing re-indentation. nwellnhof confirmed this is the intended libxml2 behavior.

How

Added a note to the Document toString section in docs/libxml.dbk explaining the interaction with whitespace text nodes, with a code example showing no_blanks => 1 at parse time. Regenerated lib/XML/LibXML/Document.pod.

Testing

  • make pod_docs regenerates cleanly
  • Full test suite passes

Ref: #234


Quality Report

Changes: 2 files changed, 45 insertions(+)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan

…s (GH #234)

Users commonly expect toString(1) to produce indented output on any
parsed document, but the formatter only inserts indentation between
child elements that are not already separated by text content.

Add a note to the Document toString documentation explaining that
no_blanks => 1 is needed at parse time to strip existing whitespace
text nodes before re-indentation can take effect.
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