Saturday, November 22, 2008

Use PAR to format XML comment

PAR is fantastic for formatting text files. It can be used to give XML comment a pretty layout. For the following XML comment:

<!-- You can recognize truth by its beauty and -->
<!-- simplicity. When you get it right, it is obvious that it is right. -->

par 50 produces

<!-- You can recognize truth by its beauty -->
<!-- and simplicity. When you get it right, -->
<!-- it is obvious that it is right. -->

But for the following text

<!-- You can recognize truth by its beauty and simplicity. When you get it right, it is obvious that it is right. -->

par 50 produces

<!-- You can recognize truth by its beauty and
simplicity. When you get it right, it is obvious
that it is right. -->

It is not what we want. Instead, par 50 -p5 -s5 can be used to produce

<!-- You can recognize truth by its beauty -->
<!-- and simplicity. When you get it right, -->
<!-- it is obvious that it is right. -->

For the details of using PAR, you can refer to Par.

No comments: