Overbryd / exoml

A module to decode/encode xml into a tree structure
MIT License
7 stars 3 forks source link

indent output on encode #3

Open Overbryd opened 4 years ago

Overbryd commented 4 years ago

https://elixirforum.com/t/exoml-parse-xml-strings-into-a-tree/8048/12?u=overbryd

Proposed API:

> xml = {"tag", [], [{"foo", [], ["bar"]}}
> Exoml.encode(xml, indent: 2) |> IO.puts()
<tag>
  <foo>bar</foo>
</tag>
tobstarr commented 4 years ago

:+1:

Maybe https://golang.org/pkg/encoding/xml/#Encoder.Indent could be a good inspiration fore the API.

Allowing strings as indent (instead of Integers) would avoid the tabs vs. spaces issue. With the prefix one could e.g. use two tabs as prefix but indent with " " to format xml for markdown.