Skip to content

Fix quoted text in indented HTML serialization - #37

Open
Joseph-Mutua wants to merge 1 commit into
serpapi:masterfrom
Joseph-Mutua:fix/issue-35-pretty-text-serialization
Open

Joseph-Mutua wants to merge 1 commit into
serpapi:masterfrom
Joseph-Mutua:fix/issue-35-pretty-text-serialization

Conversation

@Joseph-Mutua

@Joseph-Mutua Joseph-Mutua commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

@zyc9012 @forthrin :

Summary

Fix indented HTML serialization adding artificial quotation marks around text nodes.

Fixes #35.

Problem

Nokolexbor delegates indented output to Lexbor's pretty tree serializer. That serializer represents text as quoted diagnostic strings, including whitespace-only nodes, so the quotes became literal HTML output.

Changes

  • add an opt-in Lexbor serialization flag that suppresses only synthetic text delimiters
  • use that flag for indented inner_html and outer_html serialization
  • cover documents, nodes and aliases, NodeSets, fragments, escaping, whitespace, and raw-text elements

Before

<html>
  <head>
  </head>
  <body>
    <h1>
      "Hello, World!"
    </h1>
    " "
  </body>
</html>

After

<html>
  <head>
  </head>
  <body>
    <h1>
      Hello, World!
    </h1>
     
  </body>
</html>

The whitespace-only text node remains present but is no longer wrapped in synthetic quotes.

Testing

  • bundle exec ruby -Ilib -Ispec spec/node_spec.rb — 136 runs, 315 assertions
  • bundle exec ruby -Ilib -Ispec spec/node_set_spec.rb — 58 runs, 122 assertions
  • bundle exec ruby -Ilib -Ispec spec/document_fragment_spec.rb — 14 runs, 24 assertions
  • bundle exec rake — 311 runs, 4,651 assertions
  • gem build nokolexbor.gemspec — success

All test commands completed with zero failures, errors, or skips.

Notes

  • Non-indented serialization is unchanged.
  • Escaping and script/style raw-text behavior remain covered.
  • A local Ruby 4.0 Docker ASAN run could not complete because globally preloading the system libasan caused Ruby and Minitest's child diff process to stall. No sanitizer error was emitted; the repository's Linux CI memory check remains authoritative.

@Joseph-Mutua

Copy link
Copy Markdown
Contributor Author

Verification evidence

Attached are the reproduction and verification artifacts for issue #35:

  • before/after serializer output
  • targeted and full test results
  • environment and investigation notes
  • ASAN attempt details (not claimed as passing)
  • ZIP archive containing the same evidence set

issue-35-before.txt
issue-35-after.txt
issue-35-targeted-tests.txt
issue-35-full-tests.txt
issue-35-full-tests-before.txt
issue-35-environment.txt
issue-35-investigation.md
issue-35-asan.txt
nokolexbor-issue-35-evidence.zip

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.

Indentation code quotes all strings, even whitespace between tags

1 participant