I’m using HaXml to transform a XML file and it’s all quite working nicely. However the output HaXml generates looks really ugly, mainly because it inserts a linebreak at almost every closing bracket.
Here’s some code that generates a xml:
writeFile outPath (show . PP.content . head $ test (docContent (posInNewCxt "" Nothing) (xmlParse "" "")))
test =
mkElemAttr "test" [("a", literal "1"), ("b", literal "2")]
[
mkElem "nested" []
]
and here’s the output it generates:
<test a="1" b="2"
><nested/></test>
Of course it is worse with more elements.
I know that HaXml uses Text.PrettyPrint.HughesPJ for rendering, but using different styles
didn’t change much.
So, is there a way to change the output?
Replacing you call to
showwithText.PrettyPrint.renderStyleyou can get a few different behaviors:Experimenting with different out-of-the-box styles:
Default style
style { mode = OneLineMode }
style { mode = LeftMode, lineLength = 2 }
So you can certainly do a few different things.
If you don’t like any of these, you can write a custom processors, using
fullRender:where your custom behavior can be programmed into the
TextDetailsfunction.