Doctest formatting without causing tests to fail

I have a function that has a very long return value. I want to format it with line breaks, but this would cause the doctest to expect those line breaks in the function output.

Is there a way to format the expected return value that wouldn’t require me to change the function’s return value?

Here is an example of what I have:

iex> Softswitch.XML.Core.serialize(Softswitch.XML.Core.root(
...> Softswitch.XML.Core.section("dialplan", 
...> Softswitch.XML.Core.condition("source", "mod_sofia"))))
'<?xml version="1.0" encoding="UTF-8" standalone="no"?><document type="freeswitch/xml"><section name="dialplan"><condition field="source" expression="mod_sofia"/></section></document>'

Here is what I want to do:

iex> Softswitch.XML.Core.serialize(Softswitch.XML.Core.root(
...> Softswitch.XML.Core.section("dialplan", 
...> Softswitch.XML.Core.condition("source", "mod_sofia"))))
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="dialplan"><condition field="source" expression="mod_sofia"/></section>
</document>'

As far as I know this is not possible with doctests. You can either turn your doctest into a simple example (remove the iex> prefixes) but you’ll lose the actual testing, or leave it like this. What I try to do in this cases is either have an example with something that returns something smaller that fits nicely.

Or assign that output to a binding then run tests on that binding (I do that a lot in my published libraries if you see).