buffer:  added strbuf_rtrim function.
Made blocks_to_html non-recursive (using a stack).

This will help avoid stack overflows with deeply nested structures.
See #187.