<div dir="ltr"><div dir="ltr">Am Mi., 27. Juli 2022 um 16:00 Uhr schrieb Michael van Acken <<a href="mailto:michael.van.acken@gmail.com">michael.van.acken@gmail.com</a>>:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Am Mi., 27. Juli 2022 um 12:04 Uhr schrieb Adam Sotona <<a href="mailto:adam.sotona@oracle.com" target="_blank">adam.sotona@oracle.com</a>>:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="en-CZ">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">Unfortunately, “Prettyprinting” can be reduced to indentation and new lines only for XML and JSON, however YAML offers much more dynamic formatting.</span></p></div></div></blockquote><div><br></div><div>I have to admit that I never used YAML syntax in any form. Looking at the</div><div>Wikipedia page, it seems like YAML's optional "inline-style" corresponds</div><div>to the "single-line formatting" style of the prettyprinter approach, and its</div><div>indented multi-line blocks to multi-line formatting. In this case, the width</div><div>information passed up the tree would represent the "inline-style" width.</div><div><br></div><div>I would not rule out that it can be made to work. I agree with you that it</div><div>would entail more than just moving strings around, because printing</div><div>of lists and maps would have two distinct output modes. But it may</div><div>be possible to move the decision which mode to use out of the data</div><div>model.</div></div></div></blockquote><div><br></div><div>Curiosity got the better of me and I tried to put together a proof of concept.</div><div>I used sample.json as input and generated two attempts at YAML, one </div><div>formatted to a page width of 80 and another one to a width of 40.</div><div>The diff between sample.yaml and output_pp80.yaml is attached, not sure</div><div>if it is still a valid representation with its three indented inline maps.</div><div><br></div><div>Someone who understands YAML should be able to do a better job</div><div>than this. I'm not sure I got the interaction between list, map, and </div><div>map entry entirely correct.</div><div><br></div><div>The code is on github at <a href="https://github.com/mva/eval-pp">https://github.com/mva/eval-pp</a></div><div><br></div><div>-- mva</div><div><br></div><div><br></div><div><br></div><div>--- sample.yaml 2022-07-27 20:43:42.795748163 +0200<br>+++ output_pp80.yaml 2022-07-27 21:04:23.923566743 +0200<br>@@ -37,11 +37,13 @@<br> max locals: 3<br> attributes: [StackMapTable]<br> stack map frames:<br>- '@6': {locals: [Foo, int, java/lang/Throwable], stack: []}<br>- //stack map frame @0: {locals: [Foo, int, java/lang/Throwable], stack: []}<br>+ {'@6': {locals: [Foo, int, java/lang/Throwable], stack: []}}<br>+ //stack map frame @0:<br>+ {locals: [Foo, int, java/lang/Throwable], stack: []}<br> 0: [ILOAD_1, {slot: 1}]<br> 1: [IFEQ, {target: 6}]<br> 4: [ALOAD_2, {slot: 2}]<br> 5: [ATHROW]<br>- //stack map frame @6: {locals: [Foo, int, java/lang/Throwable], stack: []}<br>+ //stack map frame @6:<br>+ {locals: [Foo, int, java/lang/Throwable], stack: []}<br> 6: [RETURN]<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="en-CZ"><div><div><div><div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div></div>
</blockquote></div></div>