prettyprint.rst
changeset 2096 bb22372fc204
parent 1912 8b81a8f0f692
child 2097 614569553a08
equal deleted inserted replaced
2095:b9bf144836b8 2096:bb22372fc204
     9 About pretty printing.
     9 About pretty printing.
    10 ======================
    10 ======================
    11 
    11 
    12 Code formatter, beautifier, pretty printer.
    12 Code formatter, beautifier, pretty printer.
    13 
    13 
    14   http://en.wikipedia.org/wiki/Pretty-printer
    14 http://en.wikipedia.org/wiki/Pretty-printer
    15                 Wiki article.
    15   Wiki article on pretty printing.
    16 
    16 
    17 xml.
    17 json
    18 ====
    18 ====
    19 
    19 
    20 tidy.
    20 With Python 2.6+::
    21 -----
    21 
    22 ::
    22   $ python -m simplejson.tool  $FILE
       
    23 
       
    24 In terminal you can add color support with ``pygmentize``::
       
    25 
       
    26   $ curl -s http://.../... | python -m simplejson.tool | pygmentize -l json
       
    27 
       
    28 xml
       
    29 ===
       
    30 
       
    31 With tidy::
    23 
    32 
    24   $ tidy -xml -i -utf8 -o out.xml in.xml
    33   $ tidy -xml -i -utf8 -o out.xml in.xml
    25 
    34 
    26 or in Emacs::
    35 or in Emacs::
    27 
    36 
    28   C-x h C-x <RET> c utf-8 <RET> C-u M-| tidy -q -xml -i -utf8 -
    37   C-x h C-x <RET> c utf-8 <RET> C-u M-| tidy -q -xml -i -utf8 -
    29 
    38 
    30   http://tidy.sourceforge.net
    39 With xmllint::
    31                 Home page.
       
    32   http://www.emacswiki.org/cgi-bin/wiki/tidy.el
       
    33                 Emacs bindings.
       
    34 
       
    35 xmllint.
       
    36 --------
       
    37 ::
       
    38 
    40 
    39   $ xmllint --format file.xml
    41   $ xmllint --format file.xml
    40 
    42 
    41 or in Emacs:
    43 or in Emacs::
    42 
    44 
    43   : C-x h C-u M-| xmllint --format - <RET>
    45   : C-x h C-u M-| xmllint --format - <RET>
    44 
    46 
    45 Emacs and nxml.
    47 With Emacs and nxml you need introduce line-breaks and then::
    46 ---------------
       
    47 
       
    48 You need introduce line-breaks and then::
       
    49 
    48 
    50   C-x h C-M-\
    49   C-x h C-M-\
    51 
    50 
    52 xmlindent.
    51 http://tidy.sourceforge.net
    53 ----------
    52   Home page.
    54 
    53 http://www.emacswiki.org/cgi-bin/wiki/tidy.el
    55   http://xmlindent.sourceforge.net/
    54   Emacs bindings.
       
    55 http://xmlindent.sourceforge.net/
       
    56   xmlindent home page.
    56 
    57 
    57 c/c++/java/c#.
    58 c/c++/java/c#.
    58 ==============
    59 ==============
    59 
    60 
    60 Artistic Style, astyle.
    61 Artistic Style, astyle.
    86                 Home page.
    87                 Home page.
    87 
    88 
    88 Perl.
    89 Perl.
    89 =====
    90 =====
    90 
    91 
    91   http://perltidy.sourceforge.net/
    92 http://perltidy.sourceforge.net/
    92                 Home page.
    93   Home page.
    93 
    94