I've found what appears to be a bug in the builder library, but don't
know where to report it. The problem occurs when using indentation
(i.e. :indent > 0) and when the most deeply nested command contains a
block that returns just text, i.e. if it uses << or contains a
Builder::XmlMarkup.new that targets the builder object above it. This
causes the indentation to break down, placing a newline after the
opening tag, setting the text against the left margin, and then
indenting the closing tag.
The source of the problem is the loop between the block part of the
method_missing method and the _nested_structures method in xmlbase.rb.
It works if the lowest level command contains a simple text argument
(e.g. xml.name(author.name)), but not otherwise. I have worked around it
by redefining text!(text) as _text(text), thus switching off all
escaping of text, but that is not a fix.
It would, however, be useful to have a global option that turns off
escaping, so that one could simply use the ordinary text argument. I am
trying to produce human-readable documents, hence the indentation, and
don't want my accented letters and typographical symbols turned into
numbers. In addition, some of my input contains presentational markup
elements, such as <emphasize>, <superscript> etc, that should not be
I am not a professional programmer, and not good enough to offer a fix
to the problem (although I could probably manage setting up the global
option). This does, however, make me realize that thanks to Rails I am
actually doing things that I would not even have thought of attempting a
couple of years ago, so many thanks to all who work on such an excellent
Best wishes for the future.