1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
3 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
4 ;;; Copyright © 2016, 2019 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2017 Nikita <nikita@n0.is>
6 ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org>
8 ;;; Copyright © 2020 EuAndreh <eu@euandre.org>
9 ;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
10 ;;; Copyright © 2021 Zhu Zihao <all_but_last@163.com>
11 ;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
12 ;;; Copyright © 2022 jgart <jgart@dismail.de>
13 ;;; Copyright © 2022 Vinicius Monego <monego@posteo.net>
15 ;;; This file is part of GNU Guix.
17 ;;; GNU Guix is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
22 ;;; GNU Guix is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30 (define-module (gnu packages markup)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module (guix gexp)
35 #:use-module (guix packages)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system trivial)
38 #:use-module (guix build-system cmake)
39 #:use-module (guix build-system perl)
40 #:use-module (guix build-system python)
41 #:use-module (guix utils)
42 #:use-module (guix gexp)
43 #:use-module (gnu packages)
44 #:use-module (gnu packages base)
45 #:use-module (gnu packages check)
46 #:use-module (gnu packages compression)
47 #:use-module (gnu packages libffi)
48 #:use-module (gnu packages perl)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages python)
51 #:use-module (gnu packages python-xyz)
52 #:use-module (gnu packages web))
54 (define-public hoedown
61 (url "https://github.com/hoedown/hoedown")
63 (file-name (git-file-name name version))
66 "1kr3hxjg2dgmwy9738qgj3sh3f5cygx0zxskkfhrg7x19bq9yd26"))))
67 (build-system gnu-build-system)
69 '(#:make-flags (list "CC=gcc" (string-append "PREFIX=" %output))
70 #:phases (modify-phases %standard-phases
71 (delete 'configure)) ; no configure script
72 #:test-target "test"))
74 `(("python" ,python-2)
76 (synopsis "Markdown processing library")
77 (description "Hoedown is a standards compliant, fast, secure markdown
78 processing library written in C.")
79 (home-page "https://github.com/hoedown/hoedown")
80 (license license:expat)))
82 (define-public markdown
90 "http://daringfireball.net/projects/downloads/"
91 (string-capitalize name) "_" version ".zip"))
93 (base32 "0dq1pj91pvlwkv0jwcgdfpv6gvnxzrk3s8mnh7imamcclnvfj835"))))
94 (build-system trivial-build-system)
96 '(#:modules ((guix build utils))
99 (use-modules (guix build utils))
100 (let ((source (assoc-ref %build-inputs "source"))
101 (out (assoc-ref %outputs "out"))
102 (perlbd (string-append (assoc-ref %build-inputs "perl") "/bin"))
103 (unzip (search-input-file %build-inputs "/bin/unzip")))
105 (with-directory-excursion out
106 (invoke unzip source)
108 (mkdir-p "share/doc")
109 (rename-file "Markdown_1.0.1/Markdown.pl" "bin/markdown")
110 (rename-file "Markdown_1.0.1/Markdown Readme.text"
112 (patch-shebang "bin/markdown" (list perlbd))
113 (delete-file-recursively "Markdown_1.0.1"))
115 (native-inputs (list unzip))
117 (home-page "http://daringfireball.net/projects/markdown")
118 (synopsis "Text-to-HTML conversion tool")
120 "Markdown is a text-to-HTML conversion tool for web writers. It allows
121 you to write using an easy-to-read, easy-to-write plain text format, then
122 convert it to structurally valid XHTML (or HTML).")
123 (license (license:non-copyleft "file://License.text"
124 "See License.text in the distribution."))))
126 (define-public lowdown
127 (let ((commit "1de10c1d71bfb4348ae0beaec8b1547d5e114969")
131 (version (git-version "0.10.0" revision commit))
136 (url "https://github.com/kristapsdz/lowdown")
138 (file-name (git-file-name name version))
140 (base32 "1wh07nkiihvp1m79sj4qlnqklnn0rfp3hwls8sqcp0bfd96wpa1h"))))
141 (build-system gnu-build-system)
144 #:test-target "regress"
146 #~(modify-phases %standard-phases
149 (invoke "./configure"
150 (string-append "PREFIX=" #$output)
151 (string-append "MANDIR=" #$output "/share/man")))))
152 #:make-flags #~(list "CFLAGS=-fPIC")))
155 (home-page "https://kristaps.bsd.lv/lowdown/")
156 (synopsis "Simple Markdown translator")
157 (description "Lowdown is a Markdown translator producing HTML5,
158 roff documents in the ms and man formats, LaTeX, gemini, and terminal output.")
159 (license license:isc))))
161 (define-public discount
168 "http://www.pell.portland.or.us/~orc/Code/"
169 "discount/discount-" version ".tar.bz2"))
172 "024mxv0gpvilyfczarcgy5m7h4lv6qvhjfpf5i73qkxhszjjn9mi"))))
173 (build-system gnu-build-system)
175 `(#:test-target "test"
176 #:parallel-build? #f ; libmarkdown won't be built in time
178 (string-append "LFLAGS=-L. -Wl,-rpath="
179 (assoc-ref %outputs "out") "/lib"))
181 (modify-phases %standard-phases
182 (add-before 'configure 'set-AC_PATH
184 ;; The default value is not suitable, so override using an
185 ;; environment variable. This just affects the build, and not the
186 ;; resulting store item.
187 (setenv "AC_PATH" (getenv "PATH"))
190 (lambda* (#:key inputs outputs #:allow-other-keys)
191 (let ((out (assoc-ref outputs "out")))
192 (setenv "CC" ,(cc-for-target))
193 ;; The ‘validate-runpath’ phase fails otherwise.
194 (setenv "LDFLAGS" (string-append "-Wl,-rpath=" out "/lib"))
195 (invoke "./configure.sh"
196 (string-append "--prefix=" out)
200 (synopsis "Markdown processing library, written in C")
202 "Discount is a markdown implementation, written in C. It provides a
203 @command{markdown} command, and a library.")
204 (home-page "https://www.pell.portland.or.us/~orc/Code/discount/")
205 (license license:bsd-3)))
207 (define-public perl-text-markdown-discount
209 (name "perl-text-markdown-discount")
215 "mirror://cpan/authors/id/S/SE/SEKIMURA/Text-Markdown-Discount-"
220 "1xx7v3wnla7m6wa3h33whxw3vvincaicg4yra1b9wbzf2aix9rnw"))
222 (search-patches "perl-text-markdown-discount-unbundle.patch"))))
223 (build-system perl-build-system)
226 (modify-phases %standard-phases
227 (add-before 'build 'set-ldflags
228 (lambda* (#:key inputs #:allow-other-keys)
229 (substitute* "Makefile"
232 "OTHERLDFLAGS = -lmarkdown -Wl,-rpath="
233 (assoc-ref inputs "discount")
239 "https://metacpan.org/release/Text-Markdown-Discount")
241 "Fast function for converting Markdown to HTML using Discount")
243 "Text::Markdown::Discount is a Perl extension to the Discount markdown
247 use Text::Markdown::Discount;
248 my $html = markdown($text)
250 (license license:perl-license)))
252 (define-public python-cmarkgfm
254 (name "python-cmarkgfm")
258 (uri (pypi-uri "cmarkgfm" version))
261 "1jxk9cdir4q1bpjla7b7y1qfjmr7mkd0f802b2sb88njk079p1gy"))
262 (modules '((guix build utils)))
265 ;; Delete bundled cmark and generated headers.
266 (for-each delete-file-recursively
267 '("third_party/cmark" "generated"))))))
268 (build-system python-build-system)
271 #~(modify-phases %standard-phases
272 (add-after 'unpack 'relax-requirements
274 ;; Don't depend on bleeding-edge CFFI, as it is
275 ;; apparently only needed for Python >= 3.10.
276 (substitute* "setup.py"
277 (("cffi>=1\\.15\\.0")
279 (add-after 'unpack 'copy-cmark-gfm
281 ;; This package needs the cmark-gfm source files
282 ;; to generate FFI bindings.
283 (copy-recursively #+(package-source (this-package-input
285 "third_party/cmark")))
286 (add-after 'unpack 'install-cmark-headers
287 (lambda* (#:key inputs #:allow-other-keys)
288 ;; XXX: Loosely based on 'regenerate' from noxfile.py.
289 (let ((version.h (search-input-file
290 inputs "/include/cmark-gfm_version.h")))
291 (for-each (lambda (file)
292 (install-file file "generated/unix/"))
294 (find-files (dirname version.h)
297 (lambda* (#:key tests? #:allow-other-keys)
298 (when tests? (invoke "pytest" "-vv" "tests")))))))
299 (native-inputs (list python-pytest))
300 (inputs (list cmark-gfm))
301 (propagated-inputs (list python-cffi))
302 (home-page "https://github.com/theacodes/cmarkgfm")
303 (synopsis "Python bindings for GitHub's fork of cmark")
305 "This package provides a minimal set of Python bindings for the
306 GitHub cmark fork (@code{cmark-gfm}).")
307 (license license:expat)))
309 (define-public python-markdownify
311 (name "python-markdownify")
316 (uri (pypi-uri "markdownify" version))
319 "0msvrsgq9jigbgg7r7iq7ql5bgslmbxd8sq0nmpbxrjwqypgs7w2"))))
320 (build-system python-build-system)
322 (list python-pytest))
324 (list python-flake8 python-beautifulsoup4 python-six))
326 "https://github.com/matthewwithanm/python-markdownify")
327 (synopsis "Converts HTML to Markdown")
328 (description "This package provides @code{markdownify} a Python library to
329 convert HTML to Markdown.")
330 (license license:expat)))
339 (url "https://github.com/jgm/cmark")
341 (file-name (git-file-name name version))
344 "1426snw3mq8qmpdxznkhsyy75xd9v9nwlc7sph08qpdz8xnp4hr2"))))
345 (build-system cmake-build-system)
347 '(#:test-target "test"))
348 (native-inputs (list python))
349 (synopsis "CommonMark Markdown reference implementation")
350 (description "CommonMark is a strongly defined, highly compatible
351 specification of Markdown. cmark is the C reference implementation of
352 CommonMark. It provides @code{libcmark} shared library for parsing
353 CommonMark to an abstract syntax tree (@dfn{AST}) and rendering the document
354 as HTML, groff man, LaTeX, CommonMark, or an XML representation of the
355 AST. The package also provides the command-line program @command{cmark}
356 for parsing and rendering CommonMark.")
357 (home-page "https://commonmark.org")
358 ;; cmark is distributed with a BSD-2 license, but some components are Expat
359 ;; licensed. The CommonMark specification is Creative Commons CC-BY-SA 4.0
360 ;; licensed. See 'COPYING' in the source distribution for more information.
361 (license (list license:bsd-2 license:expat license:cc-by-sa4.0))))
363 (define-public cmark-gfm
367 (version "0.29.0.gfm.2")
368 (home-page "https://github.com/github/cmark-gfm")
371 (uri (git-reference (url home-page) (commit version)))
372 (file-name (git-file-name name version))
375 "0vz6zs3m22k7jzfj4782lahciwfjlbi4m3qz5crsmssip3rwdy7h"))))
377 '(#:test-target "test"
378 #:phases (modify-phases %standard-phases
379 (add-after 'install 'install-config
380 (lambda* (#:key outputs #:allow-other-keys)
381 (let ((out (assoc-ref outputs "out")))
382 ;; XXX: cmark-gfm-core-extensions.h includes this file.
383 (install-file "src/config.h"
384 (string-append out "/include"))))))))
385 (synopsis "GitHub flavored CommonMark")
387 "This package is a fork of @code{cmark}, with GitHub-specific Markdown
398 (url "https://github.com/Gottox/smu")
399 (commit (string-append "v" version))))
400 (file-name (git-file-name name version))
402 (base32 "1jm7lhnzjx4q7gcwlkvsbffcy0zppywyh50d71ami6dnq182vvcc"))))
403 (build-system gnu-build-system)
405 `(#:make-flags (list "CC=gcc"
406 (string-append "PREFIX="
407 (assoc-ref %outputs "out")))
408 #:tests? #f ; no tests included
410 (modify-phases %standard-phases
411 (delete 'configure))))
412 (home-page "https://github.com/Gottox/smu")
413 (synopsis "Simple markup")
415 "Smu is a very simple and minimal markup language. It is
416 designed for using in wiki-like environments. Smu makes it very
417 easy to write your documents on the fly and convert them into HTML.
418 Smu is capable to parse very large documents. As long as you avoid an huge
419 amount of indents it scales just great.
421 Smu was started as a rewrite of Markdown but became something more
422 lightweight and consistent. The biggest difference between Markdown
423 and smu is that smu doesn't support reference style links.")
424 (license license:x11)))
434 (url "https://github.com/mity/md4c/")
435 (commit (string-append "release-" version))))
436 (file-name (git-file-name name version))
438 (base32 "12pdh4rfjc3b0cblj5nz3jksr2376lx8ay0vw5dwa1s97q09pczq"))))
439 (build-system cmake-build-system)
440 (arguments '(#:tests? #f))
441 (home-page "https://github.com/mity/md4c/")
442 (synopsis "C Markdown parser compliant to CommonMark")
443 (description "MD4C is a C Markdown parser with a
444 SAX-like interface. It is compliant to the CommonMark specification,
445 with a few extensions.")
446 (license license:expat)))
448 (define-public python-mistletoe
450 (name "python-mistletoe")
455 (uri (pypi-uri "mistletoe" version))
457 (base32 "0h8ydzxlfzmspiz8lcm13qp720kfsxiky0qqnc2mxf4qzm16m326"))))
458 (build-system python-build-system)
461 (modify-phases %standard-phases
463 (lambda* (#:key tests? #:allow-other-keys)
465 (invoke "python" "-m" "unittest" "discover" "test")))))))
466 (home-page "https://github.com/miyuchina/mistletoe")
467 (synopsis "Extensible Markdown parser in pure Python")
469 "The @code{mistletoe} Markdown parser is a CommonMark-compliant Markdown
470 parser that supports definitions of custom tokens.
472 Parsing Markdown into an abstract syntax tree also allows @code{mistletoe} to
473 swap out renderers for different output formats, without touching any of the
475 (license license:expat)))