diff --git a/lib/rexml/formatters/pretty.rb b/lib/rexml/formatters/pretty.rb index ff0e1022..b35260c9 100644 --- a/lib/rexml/formatters/pretty.rb +++ b/lib/rexml/formatters/pretty.rb @@ -103,6 +103,11 @@ def write_cdata( node, output) super end + def write_instruction( node, output ) + output << ' ' * @level + super + end + def write_document( node, output ) # Ok, this is a bit odd. All XML documents have an XML declaration, # but it may not write itself if the user didn't specifically add it, diff --git a/test/formatter/test_pretty.rb b/test/formatter/test_pretty.rb index a3e97d54..a89981fe 100644 --- a/test/formatter/test_pretty.rb +++ b/test/formatter/test_pretty.rb @@ -7,6 +7,14 @@ def format(node, indentation=2) output end + class InstructionTest < self + def test_instruction_is_indented_like_comment + document = REXML::Document.new("") + assert_equal("\n \n \n \n", + format(document)) + end + end + class TextTest < self def test_source_document_is_not_modified document = REXML::Document.new("hello world")