prettyprint.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 19 Feb 2017 12:33:28 +0200
changeset 2096 bb22372fc204
parent 1912 8b81a8f0f692
child 2097 614569553a08
permissions -rw-r--r--
Pretty print json.

.. -*- coding: utf-8; -*-

===========================
 Pretty print source code.
===========================
.. contents::
   :local:

About pretty printing.
======================

Code formatter, beautifier, pretty printer.

http://en.wikipedia.org/wiki/Pretty-printer
  Wiki article on pretty printing.

json
====

With Python 2.6+::

  $ python -m simplejson.tool  $FILE

In terminal you can add color support with ``pygmentize``::

  $ curl -s http://.../... | python -m simplejson.tool | pygmentize -l json

xml
===

With tidy::

  $ tidy -xml -i -utf8 -o out.xml in.xml

or in Emacs::

  C-x h C-x <RET> c utf-8 <RET> C-u M-| tidy -q -xml -i -utf8 -

With xmllint::

  $ xmllint --format file.xml

or in Emacs::

  : C-x h C-u M-| xmllint --format - <RET>

With Emacs and nxml you need introduce line-breaks and then::

  C-x h C-M-\

http://tidy.sourceforge.net
  Home page.
http://www.emacswiki.org/cgi-bin/wiki/tidy.el
  Emacs bindings.
http://xmlindent.sourceforge.net/
  xmlindent home page.

c/c++/java/c#.
==============

Artistic Style, astyle.
-----------------------

A Free, Fast and Small Automatic Formatter for C, C++, C#, and Java Source Code.

There are exist package for Cygwin, Debian.

  http://astyle.sourceforge.net/
                home page

Uncrustify.
-----------

Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA.

Exist package for Windows (binary from home page), Debian.

  http://uncrustify.sourceforge.net/
                home page

jpplib.
-------

Pretty Printer Library.

  http://jpplib.sourceforge.net/
                Home page.

Perl.
=====

http://perltidy.sourceforge.net/
  Home page.