markup.scm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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 Marius Bakke <mbakke@fastmail.com>
  8. ;;; Copyright © 2020 EuAndreh <eu@euandre.org>
  9. ;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
  10. ;;;
  11. ;;; This file is part of GNU Guix.
  12. ;;;
  13. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  14. ;;; under the terms of the GNU General Public License as published by
  15. ;;; the Free Software Foundation; either version 3 of the License, or (at
  16. ;;; your option) any later version.
  17. ;;;
  18. ;;; GNU Guix is distributed in the hope that it will be useful, but
  19. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;;; GNU General Public License for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License
  24. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  25. (define-module (gnu packages markup)
  26. #:use-module (guix licenses)
  27. #:use-module (guix download)
  28. #:use-module (guix git-download)
  29. #:use-module (guix packages)
  30. #:use-module (guix build-system gnu)
  31. #:use-module (guix build-system trivial)
  32. #:use-module (guix build-system cmake)
  33. #:use-module (guix build-system perl)
  34. #:use-module (guix build-system python)
  35. #:use-module (guix utils)
  36. #:use-module (gnu packages compression)
  37. #:use-module (gnu packages)
  38. #:use-module (gnu packages perl)
  39. #:use-module (gnu packages pkg-config)
  40. #:use-module (gnu packages python)
  41. #:use-module (gnu packages web))
  42. (define-public hoedown
  43. (package
  44. (name "hoedown")
  45. (version "3.0.7")
  46. (source (origin
  47. (method git-fetch)
  48. (uri (git-reference
  49. (url "https://github.com/hoedown/hoedown")
  50. (commit version)))
  51. (file-name (git-file-name name version))
  52. (sha256
  53. (base32
  54. "1kr3hxjg2dgmwy9738qgj3sh3f5cygx0zxskkfhrg7x19bq9yd26"))))
  55. (build-system gnu-build-system)
  56. (arguments
  57. '(#:make-flags (list "CC=gcc" (string-append "PREFIX=" %output))
  58. #:phases (modify-phases %standard-phases
  59. (delete 'configure)) ; no configure script
  60. #:test-target "test"))
  61. (native-inputs
  62. `(("python" ,python-2)
  63. ("tidy" ,tidy)))
  64. (synopsis "Markdown processing library")
  65. (description "Hoedown is a standards compliant, fast, secure markdown
  66. processing library written in C.")
  67. (home-page "https://github.com/hoedown/hoedown")
  68. (license expat)))
  69. (define-public markdown
  70. (package
  71. (name "markdown")
  72. (version "1.0.1")
  73. (source
  74. (origin
  75. (method url-fetch)
  76. (uri (string-append
  77. "http://daringfireball.net/projects/downloads/"
  78. (string-capitalize name) "_" version ".zip"))
  79. (sha256
  80. (base32 "0dq1pj91pvlwkv0jwcgdfpv6gvnxzrk3s8mnh7imamcclnvfj835"))))
  81. (build-system trivial-build-system)
  82. (arguments
  83. '(#:modules ((guix build utils))
  84. #:builder
  85. (begin
  86. (use-modules (guix build utils))
  87. (let ((source (assoc-ref %build-inputs "source"))
  88. (out (assoc-ref %outputs "out"))
  89. (perlbd (string-append (assoc-ref %build-inputs "perl") "/bin"))
  90. (unzip (string-append (assoc-ref %build-inputs "unzip")
  91. "/bin/unzip")))
  92. (mkdir-p out)
  93. (with-directory-excursion out
  94. (invoke unzip source)
  95. (mkdir "bin")
  96. (mkdir-p "share/doc")
  97. (rename-file "Markdown_1.0.1/Markdown.pl" "bin/markdown")
  98. (rename-file "Markdown_1.0.1/Markdown Readme.text"
  99. "share/doc/README")
  100. (patch-shebang "bin/markdown" (list perlbd))
  101. (delete-file-recursively "Markdown_1.0.1"))
  102. #t))))
  103. (native-inputs `(("unzip" ,unzip)))
  104. (inputs `(("perl" ,perl)))
  105. (home-page "http://daringfireball.net/projects/markdown")
  106. (synopsis "Text-to-HTML conversion tool")
  107. (description
  108. "Markdown is a text-to-HTML conversion tool for web writers. It allows
  109. you to write using an easy-to-read, easy-to-write plain text format, then
  110. convert it to structurally valid XHTML (or HTML).")
  111. (license (non-copyleft "file://License.text"
  112. "See License.text in the distribution."))))
  113. (define-public discount
  114. (package
  115. (name "discount")
  116. (version "2.2.7")
  117. (source (origin
  118. (method url-fetch)
  119. (uri (string-append
  120. "http://www.pell.portland.or.us/~orc/Code/"
  121. "discount/discount-" version ".tar.bz2"))
  122. (sha256
  123. (base32
  124. "024mxv0gpvilyfczarcgy5m7h4lv6qvhjfpf5i73qkxhszjjn9mi"))))
  125. (build-system gnu-build-system)
  126. (arguments
  127. `(#:test-target "test"
  128. #:parallel-build? #f ; libmarkdown won't be built in time
  129. #:make-flags (list
  130. (string-append "LFLAGS=-L. -Wl,-rpath="
  131. (assoc-ref %outputs "out") "/lib"))
  132. #:phases
  133. (modify-phases %standard-phases
  134. (add-before 'configure 'set-AC_PATH
  135. (lambda _
  136. ;; The default value is not suitable, so override using an
  137. ;; environment variable. This just affects the build, and not the
  138. ;; resulting store item.
  139. (setenv "AC_PATH" (getenv "PATH"))
  140. #t))
  141. (replace 'configure
  142. (lambda* (#:key inputs outputs #:allow-other-keys)
  143. (let ((out (assoc-ref outputs "out")))
  144. (setenv "CC" ,(cc-for-target))
  145. ;; The ‘validate-runpath’ phase fails otherwise.
  146. (setenv "LDFLAGS" (string-append "-Wl,-rpath=" out "/lib"))
  147. (invoke "./configure.sh"
  148. (string-append "--prefix=" out)
  149. "--shared")))))))
  150. (native-inputs
  151. `(("pkg-config" ,pkg-config)))
  152. (synopsis "Markdown processing library, written in C")
  153. (description
  154. "Discount is a markdown implementation, written in C. It provides a
  155. @command{markdown} command, and a library.")
  156. (home-page "https://www.pell.portland.or.us/~orc/Code/discount/")
  157. (license bsd-3)))
  158. (define-public perl-text-markdown-discount
  159. (package
  160. (name "perl-text-markdown-discount")
  161. (version "0.11")
  162. (source
  163. (origin
  164. (method url-fetch)
  165. (uri (string-append
  166. "mirror://cpan/authors/id/S/SE/SEKIMURA/Text-Markdown-Discount-"
  167. version
  168. ".tar.gz"))
  169. (sha256
  170. (base32
  171. "1xx7v3wnla7m6wa3h33whxw3vvincaicg4yra1b9wbzf2aix9rnw"))
  172. (patches
  173. (search-patches "perl-text-markdown-discount-unbundle.patch"))))
  174. (build-system perl-build-system)
  175. (arguments
  176. `(#:phases
  177. (modify-phases %standard-phases
  178. (add-before 'build 'set-ldflags
  179. (lambda* (#:key inputs #:allow-other-keys)
  180. (substitute* "Makefile"
  181. (("OTHERLDFLAGS = ")
  182. (string-append
  183. "OTHERLDFLAGS = -lmarkdown -Wl,-rpath="
  184. (assoc-ref inputs "discount")
  185. "/lib")))
  186. #t)))))
  187. (inputs
  188. `(("discount" ,discount)))
  189. (home-page
  190. "https://metacpan.org/release/Text-Markdown-Discount")
  191. (synopsis
  192. "Fast function for converting Markdown to HTML using Discount")
  193. (description
  194. "Text::Markdown::Discount is a Perl extension to the Discount markdown
  195. implementation.
  196. @example
  197. use Text::Markdown::Discount;
  198. my $html = markdown($text)
  199. @end example")
  200. (license perl-license)))
  201. (define-public cmark
  202. (package
  203. (name "cmark")
  204. (version "0.29.0")
  205. (source (origin
  206. (method git-fetch)
  207. (uri (git-reference
  208. (url "https://github.com/jgm/cmark")
  209. (commit version)))
  210. (file-name (git-file-name name version))
  211. (sha256
  212. (base32
  213. "0r7jpqhgnssq444i8pwji2g36058vfzwkl70wbiwj13h4w5rfc8f"))
  214. (modules '((guix build utils)))
  215. (snippet
  216. '(begin
  217. ;; Mimic upstream commit 68c3a91166347 to fix a test failure
  218. ;; when using Python 3.8. Remove for versions > 0.29.
  219. ;; See <https://github.com/commonmark/cmark/issues/313>.
  220. (substitute* "test/normalize.py"
  221. (("cgi") "html"))
  222. #t))))
  223. (build-system cmake-build-system)
  224. (arguments
  225. '(#:test-target "test"))
  226. (native-inputs `(("python" ,python)))
  227. (synopsis "CommonMark Markdown reference implementation")
  228. (description "CommonMark is a strongly defined, highly compatible
  229. specification of Markdown. cmark is the C reference implementation of
  230. CommonMark. It provides @code{libcmark} shared library for parsing
  231. CommonMark to an abstract syntax tree (@dfn{AST}) and rendering the document
  232. as HTML, groff man, LaTeX, CommonMark, or an XML representation of the
  233. AST. The package also provides the command-line program @command{cmark}
  234. for parsing and rendering CommonMark.")
  235. (home-page "https://commonmark.org")
  236. ;; cmark is distributed with a BSD-2 license, but some components are Expat
  237. ;; licensed. The CommonMark specification is Creative Commons CC-BY-SA 4.0
  238. ;; licensed. See 'COPYING' in the source distribution for more information.
  239. (license (list bsd-2 expat cc-by-sa4.0))))
  240. (define-public smu
  241. (package
  242. (name "smu")
  243. (version "1.5")
  244. (source
  245. (origin
  246. (method git-fetch)
  247. (uri (git-reference
  248. (url "https://github.com/Gottox/smu")
  249. (commit (string-append "v" version))))
  250. (file-name (git-file-name name version))
  251. (sha256
  252. (base32 "1jm7lhnzjx4q7gcwlkvsbffcy0zppywyh50d71ami6dnq182vvcc"))))
  253. (build-system gnu-build-system)
  254. (arguments
  255. `(#:make-flags (list "CC=gcc"
  256. (string-append "PREFIX="
  257. (assoc-ref %outputs "out")))
  258. #:tests? #f ; no tests included
  259. #:phases
  260. (modify-phases %standard-phases
  261. (delete 'configure))))
  262. (home-page "https://github.com/Gottox/smu")
  263. (synopsis "Simple markup")
  264. (description
  265. "Smu is a very simple and minimal markup language. It is
  266. designed for using in wiki-like environments. Smu makes it very
  267. easy to write your documents on the fly and convert them into HTML.
  268. Smu is capable to parse very large documents. As long as you avoid an huge
  269. amount of indents it scales just great.
  270. Smu was started as a rewrite of Markdown but became something more
  271. lightweight and consistent. The biggest difference between Markdown
  272. and smu is that smu doesn't support reference style links.")
  273. (license x11)))
  274. (define-public md4c
  275. (package
  276. (name "md4c")
  277. (version "0.4.8")
  278. (source
  279. (origin
  280. (method git-fetch)
  281. (uri (git-reference
  282. (url "https://github.com/mity/md4c/")
  283. (commit (string-append "release-" version))))
  284. (file-name (git-file-name name version))
  285. (sha256
  286. (base32 "12pdh4rfjc3b0cblj5nz3jksr2376lx8ay0vw5dwa1s97q09pczq"))))
  287. (build-system cmake-build-system)
  288. (arguments '(#:tests? #f))
  289. (home-page "https://github.com/mity/md4c/")
  290. (synopsis "C Markdown parser compliant to CommonMark")
  291. (description "MD4C is a C Markdown parser with a
  292. SAX-like interface. It is compliant to the CommonMark specification,
  293. with a few extensions.")
  294. (license expat)))
  295. (define-public python-mistletoe
  296. (package
  297. (name "python-mistletoe")
  298. (version "0.7.2")
  299. (source
  300. (origin
  301. (method url-fetch)
  302. (uri (pypi-uri "mistletoe" version))
  303. (sha256
  304. (base32 "18z6hqfnfjqnrcgfgl5pkj9ggf9yx0yyy94azcn1qf7hqn6g3l14"))))
  305. (build-system python-build-system)
  306. (home-page "https://github.com/miyuchina/mistletoe")
  307. (synopsis "Extensible Markdown parser in pure Python")
  308. (description
  309. "The @code{mistletoe} Markdown parser is a CommonMark-compliant Markdown
  310. parser that supports definitions of custom tokens.
  311. Parsing Markdown into an abstract syntax tree also allows @code{mistletoe} to
  312. swap out renderers for different output formats, without touching any of the
  313. core components.")
  314. (license expat)))