author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sat, 10 Feb 2018 01:49:07 +0200 | |
changeset 2230 | 9e6ad6607a9e |
parent 2228 | 837f1337c59b |
child 2285 | 41b2a3652b35 |
permissions | -rw-r--r-- |
1334
9bf0d5a1f0cf
Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1326
diff
changeset
|
1 |
.. -*- coding: utf-8; -*- |
1209 | 2 |
|
3 |
=========================== |
|
4 |
Pretty print source code. |
|
5 |
=========================== |
|
6 |
.. contents:: |
|
1905
fba288d59662
Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
7 |
:local: |
1209 | 8 |
|
1326
8aac6cb8518d
About pretty printing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1323
diff
changeset
|
9 |
About pretty printing. |
8aac6cb8518d
About pretty printing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1323
diff
changeset
|
10 |
====================== |
8aac6cb8518d
About pretty printing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1323
diff
changeset
|
11 |
|
1209 | 12 |
Code formatter, beautifier, pretty printer. |
13 |
||
2096 | 14 |
http://en.wikipedia.org/wiki/Pretty-printer |
15 |
Wiki article on pretty printing. |
|
1326
8aac6cb8518d
About pretty printing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1323
diff
changeset
|
16 |
|
2096 | 17 |
json |
1209 | 18 |
==== |
19 |
||
2097
614569553a08
Pretty print json with jq.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2096
diff
changeset
|
20 |
With ``jq`` (available in Debian/Cygwin):: |
614569553a08
Pretty print json with jq.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2096
diff
changeset
|
21 |
|
614569553a08
Pretty print json with jq.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2096
diff
changeset
|
22 |
$ jq $FILE |
614569553a08
Pretty print json with jq.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2096
diff
changeset
|
23 |
$ curl -s http://.../... | jq |
614569553a08
Pretty print json with jq.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2096
diff
changeset
|
24 |
|
614569553a08
Pretty print json with jq.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2096
diff
changeset
|
25 |
By default ``jq`` produce colorized output in terminal! |
614569553a08
Pretty print json with jq.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2096
diff
changeset
|
26 |
|
2096 | 27 |
With Python 2.6+:: |
28 |
||
29 |
$ python -m simplejson.tool $FILE |
|
2098
1a896c3e47c2
Alternative Python module to pretty-print json.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2097
diff
changeset
|
30 |
$ python -m json.tool $FILE |
2096 | 31 |
|
32 |
In terminal you can add color support with ``pygmentize``:: |
|
33 |
||
34 |
$ curl -s http://.../... | python -m simplejson.tool | pygmentize -l json |
|
35 |
||
36 |
xml |
|
37 |
=== |
|
38 |
||
39 |
With tidy:: |
|
1209 | 40 |
|
41 |
$ tidy -xml -i -utf8 -o out.xml in.xml |
|
42 |
||
43 |
or in Emacs:: |
|
44 |
||
45 |
C-x h C-x <RET> c utf-8 <RET> C-u M-| tidy -q -xml -i -utf8 - |
|
46 |
||
2096 | 47 |
With xmllint:: |
1209 | 48 |
|
49 |
$ xmllint --format file.xml |
|
50 |
||
2096 | 51 |
or in Emacs:: |
1209 | 52 |
|
53 |
: C-x h C-u M-| xmllint --format - <RET> |
|
54 |
||
2096 | 55 |
With Emacs and nxml you need introduce line-breaks and then:: |
1209 | 56 |
|
57 |
C-x h C-M-\ |
|
58 |
||
2096 | 59 |
http://tidy.sourceforge.net |
60 |
Home page. |
|
61 |
http://www.emacswiki.org/cgi-bin/wiki/tidy.el |
|
62 |
Emacs bindings. |
|
63 |
http://xmlindent.sourceforge.net/ |
|
64 |
xmlindent home page. |
|
1209 | 65 |
|
66 |
c/c++/java/c#. |
|
1323
1d94538d70c9
http://perltidy.sourceforge.net/
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1209
diff
changeset
|
67 |
============== |
1209 | 68 |
|
69 |
Artistic Style, astyle. |
|
70 |
----------------------- |
|
71 |
||
72 |
A Free, Fast and Small Automatic Formatter for C, C++, C#, and Java Source Code. |
|
73 |
||
74 |
There are exist package for Cygwin, Debian. |
|
75 |
||
2228
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2098
diff
changeset
|
76 |
http://astyle.sourceforge.net/ |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2098
diff
changeset
|
77 |
home page |
1209 | 78 |
|
79 |
Uncrustify. |
|
80 |
----------- |
|
81 |
||
82 |
Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA. |
|
83 |
||
84 |
Exist package for Windows (binary from home page), Debian. |
|
85 |
||
2228
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2098
diff
changeset
|
86 |
http://uncrustify.sourceforge.net/ |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2098
diff
changeset
|
87 |
home page |
1209 | 88 |
|
89 |
jpplib. |
|
90 |
------- |
|
91 |
||
92 |
Pretty Printer Library. |
|
93 |
||
2228
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2098
diff
changeset
|
94 |
http://jpplib.sourceforge.net/ |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2098
diff
changeset
|
95 |
Home page. |
1209 | 96 |
|
1323
1d94538d70c9
http://perltidy.sourceforge.net/
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1209
diff
changeset
|
97 |
Perl. |
1d94538d70c9
http://perltidy.sourceforge.net/
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1209
diff
changeset
|
98 |
===== |
1d94538d70c9
http://perltidy.sourceforge.net/
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1209
diff
changeset
|
99 |
|
2096 | 100 |
http://perltidy.sourceforge.net/ |
101 |
Home page. |
|
1323
1d94538d70c9
http://perltidy.sourceforge.net/
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1209
diff
changeset
|
102 |