gnu: Add highlight.
[jackhill/guix/guix.git] / gnu / packages / pretty-print.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
3 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages pretty-print)
22 #:use-module (guix packages)
23 #:use-module (guix licenses)
24 #:use-module (guix download)
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages ghostscript)
28 #:use-module (gnu packages groff)
29 #:use-module (gnu packages imagemagick)
30 #:use-module (gnu packages gv)
31 #:use-module (gnu packages boost)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages flex)
34 #:use-module (gnu packages gperf)
35 #:use-module (gnu packages lua)
36 #:use-module (gnu packages perl)
37 #:use-module (gnu packages pkg-config))
38
39 (define-public a2ps
40 (package
41 (name "a2ps")
42 (version "4.14")
43 (source
44 (origin
45 (method url-fetch)
46 (uri (string-append "mirror://gnu/a2ps/a2ps-"
47 version ".tar.gz"))
48 (sha256
49 (base32
50 "195k78m1h03m961qn7jr120z815iyb93gwi159p1p9348lyqvbpk"))
51 (patches (search-patches
52 "a2ps-CVE-2001-1593.patch"
53 "a2ps-CVE-2014-0466.patch"))))
54 (build-system gnu-build-system)
55 (inputs
56 `(("psutils" ,psutils)
57 ("groff" ,groff)
58 ("gv" ,gv)
59 ("imagemagick" ,imagemagick)))
60 (native-inputs
61 `(("gperf" ,gperf)
62 ("perl" ,perl)))
63 (arguments
64 '(#:phases
65 (modify-phases %standard-phases
66 (add-before 'build 'patch-scripts
67 (lambda _
68 (substitute*
69 '("afm/make_fonts_map.sh"
70 "tests/defs"
71 "tests/backup.tst"
72 "tests/styles.tst")
73 (("/bin/rm") (which "rm")))))
74 (add-before 'check 'patch-test-files
75 ;; Alternatively, we could unpatch the shebangs in tstfiles
76 (lambda* (#:key inputs #:allow-other-keys)
77 (let ((perl (assoc-ref inputs "perl")))
78 (substitute* '("tests/ps-ref/includeres.ps"
79 "tests/gps-ref/includeres.ps")
80 (("/usr/local/bin/perl")
81 (string-append perl "/bin/perl"))))
82 ;; Some of the reference postscript contain a 'version 3'
83 ;; string that in inconsistent with the source text in the
84 ;; tstfiles directory. Erroneous search-and-replace?
85 (substitute* '("tests/ps-ref/InsertBlock.ps"
86 "tests/gps-ref/InsertBlock.ps"
87 "tests/ps-ref/bookie.ps"
88 "tests/gps-ref/bookie.ps")
89 (("version 3") "version 2"))
90 (substitute* '("tests/ps-ref/psmandup.ps"
91 "tests/gps-ref/psmandup.ps")
92 (("#! */bin/sh") (string-append
93 "#!" (which "sh")))))))))
94 (home-page "http://www.gnu.org/software/a2ps")
95 (synopsis "Any file to PostScript, including pretty-printing")
96 (description
97 "GNU a2ps converts almost anything to a PostScript file, ready for
98 printing. It accomplishes this by being able to delegate files to external
99 handlers, such as Groff and Gzip. It handles as many steps as is necessary to
100 produce a pretty-printed file. It also includes some extra abilities for
101 special cases, such as pretty-printing \"--help\" output.")
102 (license gpl3+)))
103
104 (define-public trueprint
105 (package
106 (name "trueprint")
107 (version "5.4")
108 (source
109 (origin
110 (method url-fetch)
111 (uri (string-append "mirror://gnu/trueprint/trueprint-"
112 version ".tar.gz"))
113 (sha256
114 (base32
115 "13rkc0fga10xyf56yy9dnq95zndnfadkhxflnp24skszj21y8jqh"))))
116 (build-system gnu-build-system)
117 (arguments
118 ;; Must define DIFF_CMD for tests to pass
119 '(#:configure-flags '("CPPFLAGS=-DDIFF_CMD=\\\"diff\\\"")))
120 (home-page "http://www.gnu.org/software/trueprint")
121 (synopsis "Pretty-print C sources and other plain text to PostScript")
122 (description
123 "GNU Trueprint translates C source code files as PostScript files.
124 In addition to the basic source code output, it can also perform diff-marking,
125 indentation counting, function and file indices and more.")
126 (license gpl2)))
127
128 (define-public enscript
129 (package
130 (name "enscript")
131 (version "1.6.6")
132 (source
133 (origin
134 (method url-fetch)
135 (uri (string-append "mirror://gnu/enscript/enscript-"
136 version ".tar.gz"))
137 (sha256
138 (base32
139 "1fy0ymvzrrvs889zanxcaxjfcxarm2d3k43c9frmbl1ld7dblmkd"))))
140 (build-system gnu-build-system)
141 (home-page "http://www.gnu.org/software/enscript")
142 (synopsis "Generating PostScript, including pretty-printing")
143 (description
144 "GNU Enscript is a program to convert ASCII text files to PostScript,
145 HTML or RTF formats, to be stored in files or sent immediately to a printer.
146 It also includes the capability to perform syntax highlighting for several
147 different programming languages.")
148 (license gpl3+)))
149
150 (define-public source-highlight
151 (package
152 (name "source-highlight")
153 (version "3.1.8")
154 (source
155 (origin
156 (method url-fetch)
157 (uri (string-append "mirror://gnu/src-highlite/source-highlight-"
158 version ".tar.gz"))
159 (sha256
160 (base32
161 "18xdalxg7yzrxc1njzgw7aryq2jdm7zq2yqz41sc7k6il5z6lcq1"))))
162 (build-system gnu-build-system)
163 ;; The ctags that comes with emacs does not support the --excmd options,
164 ;; so can't be used
165 (inputs
166 `(("boost" ,boost)))
167 (native-inputs
168 `(("bison" ,bison)
169 ("flex" ,flex)))
170 (arguments
171 `(#:configure-flags
172 (list (string-append "--with-boost="
173 (assoc-ref %build-inputs "boost")))
174 #:parallel-tests? #f ;There appear to be race conditions
175 #:phases (alist-cons-before
176 'check 'patch-test-files
177 (lambda _
178 ;; Unpatch shebangs in test input so that source-highlight
179 ;; is still able to infer input language
180 (substitute* '("tests/test.sh"
181 "tests/test2.sh"
182 "tests/test.tcl")
183 (((string-append "#! *" (which "sh"))) "#!/bin/sh"))
184 ;; Initial patching unrecoverably removes whitespace, so
185 ;; remove it also in the comparison output.
186 (substitute* '("tests/test.sh.html"
187 "tests/test2.sh.html"
188 "tests/test.tcl.html")
189 (("#! */bin/sh") "#!/bin/sh")))
190 %standard-phases)))
191 (home-page "http://www.gnu.org/software/src-highlite")
192 (synopsis "Produce a document with syntax highlighting from a source file")
193 (description
194 "GNU source-highlight reads in a source code file and produces an output
195 file in which the keywords are highlighted in different colors to designate
196 their syntactic role. It supports over 150 different languages and it can
197 output to 8 different formats, including HTML, LaTeX and ODF. It can also
198 output to ANSI color escape sequences, so that highlighted source code can be
199 seen in a terminal.")
200 (license gpl3+)
201 (properties '((ftp-directory . "/gnu/src-highlite")))))
202
203 (define-public highlight
204 (package
205 (name "highlight")
206 (version "3.33")
207 (source
208 (origin
209 (method url-fetch)
210 (uri (string-append "http://www.andre-simon.de/zip/highlight-"
211 version ".tar.bz2"))
212 (sha256
213 (base32
214 "0g2whi6pxl640795vymikm82a1my841jmh7fiqzbrjpc9wsk1db4"))))
215 (build-system gnu-build-system)
216 (arguments
217 `(#:tests? #f ; no tests
218 #:make-flags
219 (let ((confdir (string-append %output "/share/highlight/config/")))
220 (list (string-append "PREFIX=" %output)
221 (string-append "HL_CONFIG_DIR=" confdir)
222 (string-append "conf_dir=" confdir)))
223 #:phases
224 (modify-phases %standard-phases
225 (delete 'configure)
226 (add-after 'unpack 'fix-search-for-lua
227 (lambda _
228 (substitute* "src/makefile"
229 (("(pkg-config.*)lua" _ prefix)
230 (string-append prefix "lua-5.3")))
231 #t)))))
232 (inputs
233 `(("lua" ,lua)
234 ("boost" ,boost)))
235 (native-inputs
236 `(("pkg-config" ,pkg-config)))
237 (home-page "http://www.andre-simon.de/doku/highlight/en/highlight.php")
238 (synopsis "Convert code to documents with syntax highlighting")
239 (description "Highlight converts source code to HTML, XHTML, RTF, LaTeX,
240 TeX, SVG, BBCode and terminal escape sequences with colored syntax
241 highlighting. Language definitions and color themes are customizable.")
242 (license gpl3+)))
243
244 (define-public astyle
245 (package
246 (name "astyle")
247 (version "2.05")
248 (source
249 (origin
250 (method url-fetch)
251 (uri (string-append "mirror://sourceforge/astyle/astyle/astyle%20"
252 version "/astyle_" version "_linux.tar.gz"))
253 (sha256
254 (base32
255 "0f9sh9kq5ajp1yz133h00fr9235p1m698x7n3h7zbrhjiwgynd6s"))))
256 (build-system gnu-build-system)
257 (arguments
258 `(#:tests? #f ;no tests
259 #:make-flags (list (string-append "prefix=" %output)
260 "INSTALL=install"
261 "all")
262 #:phases (alist-replace
263 'configure
264 (lambda _ (chdir "build/gcc"))
265 (alist-cons-after
266 'install 'install-libs
267 (lambda* (#:key outputs #:allow-other-keys)
268 ;; Libraries are not installed by default
269 (let* ((output (assoc-ref outputs "out"))
270 (libdir (string-append output "/lib")))
271 (begin
272 (mkdir-p libdir)
273 (for-each (lambda (l)
274 (copy-file
275 l (string-append libdir "/" (basename l))))
276 (find-files "bin" "lib*")))))
277 %standard-phases))))
278 (home-page "http://astyle.sourceforge.net/")
279 (synopsis "Source code indenter, formatter, and beautifier")
280 (description
281 "Artistic Style is a source code indenter, formatter, and beautifier for
282 the C, C++, C++/CLI, Objective‑C, C#, and Java programming languages.")
283 (license lgpl3+)))