Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/rexml/formatters/pretty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions test/formatter/test_pretty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("<a><?pi data?><!--c--><b/></a>")
assert_equal("<a>\n <?pi data?>\n <!--c-->\n <b/>\n</a>",
format(document))
end
end

class TextTest < self
def test_source_document_is_not_modified
document = REXML::Document.new("<a><b>hello world</b></a>")
Expand Down
Loading