Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google-code-prettify xml indention

I have added line breaks in a generated xml doc.

<aa>"\n"
<bb>some text etc.</bb>"\n"
</aa>"\n"

this should end up as:

<aa>
  <bb>some text etc.</bb>
</aa>

Is this possible with google-code-prettify - or should I do it myself in the code that generates the xml?

Thanks in advance

like image 456
Chris G. Avatar asked Nov 28 '25 16:11

Chris G.


1 Answers

Prettify can style source code, but it does not re-indent or break lines.

It will preserve tags in your code so, so you can indent your code using line-breaks or you can use HTML layout to do that as in

<style>
  code.prettyprint { display: block; white-space: pre-wrap }
  div.el {margin-left: 2em}
</style>
<code class="prettyprint">
  <div class=el>&lt;aa&gt;<div class=el>&lt;bb&gt;...&lt;/bb&gt;</div>&lt;/aa&gt;</div>
</code>

The <div class=el> uses margin-left to indent by a certain amount, and the pre-wrap causes line to wrap within the indented block.

like image 157
Mike Samuel Avatar answered Dec 02 '25 03:12

Mike Samuel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!