Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop adding extra new line after XML declaration with pretty format #164

Merged
merged 1 commit into from
Jul 11, 2024

Commits on Jul 10, 2024

  1. fix REXML::Formatters::Pretty#write_document

    ## Why?
    Fix REXML::Formatters::Pretty#write_document, which implicitly assumes that the XML file ends with a newline.
    
    If the XML file does not end with a newline, a space is added to the end of the first line.
    
    ```
    Failure: test_indent(REXMLTests::TestDocument::WriteTest::ArgumentsTest)
    /Users/naitoh/ghq/github.com/naitoh/rexml/test/test_document.rb:270:in `test_indent'
         267:           output = ""
         268:           indent = 2
         269:           @document.write(output, indent)
      => 270:           assert_equal(<<-EOX.chomp, output)
         271: <?xml version='1.0' encoding='UTF-8'?>
         272: <message>
         273:   Hello world!
    <"<?xml version='1.0' encoding='UTF-8'?>\n" +
    "<message>\n" +
    "  Hello world!\n" +
    "</message>"> expected but was
    <"<?xml version='1.0' encoding='UTF-8'?> \n" +
    "<message>\n" +
    "  Hello world!\n" +
    "</message>">
    
    diff:
    ? <?xml version='1.0' encoding='UTF-8'?>
      <message>
        Hello world!
      </message>
    
    ```
    naitoh committed Jul 10, 2024
    Configuration menu
    Copy the full SHA
    01162bd View commit details
    Browse the repository at this point in the history