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