Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Commit 196e877

Browse files
committed
Use pandoc 1.14 and delete a dependency on Emacs.
1 parent 24921ee commit 196e877

File tree

2 files changed

+18
-40
lines changed

2 files changed

+18
-40
lines changed

README.markdown

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
## Requirements
66

7-
* "timeout" (or "gtimeout" on Mac OS) command
8-
* Pandoc (for converting Markdown files)
9-
* Emacs (for converting Org files)
7+
* "timeout" (or "gtimeout" on Mac OS) command
8+
* Pandoc 1.14 or later (for converting README files)
109

1110
## Installation
1211

src/readme.lisp

+16-37
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
(defparameter *pandoc-path* (or (uiop:getenv "PANDOC_PATH")
1616
"pandoc"))
1717

18-
(defparameter *emacs-path* (or (uiop:getenv "EMACS_PATH")
19-
"emacs"))
20-
2118
(defun which (command)
2219
(handler-case
2320
(let* ((result (with-output-to-string (s)
@@ -40,41 +37,23 @@
4037
(or (which command)
4138
(error "Requiement ~S does not exist. Ensure if it's installed and check your PATH." command))))
4239

43-
(defun convert-readme (file)
40+
(defun pandoc (file &key (from "markdown") (to "html"))
4441
(check-type file pathname)
4542
(assert (uiop:file-exists-p file))
46-
(let ((type (pathname-type file)))
47-
(cond
48-
((or (null type)
49-
(string= type "txt"))
50-
(convert-plaintext-into-html file))
51-
((or (string= type "markdown")
52-
(string= type "md"))
53-
(convert-markdown-into-html file))
54-
((string= type "org")
55-
(convert-org-into-html file)))))
56-
57-
(defun convert-plaintext-into-html (file)
58-
(concatenate 'string "<pre>" (uiop:read-file-string file) "</pre>"))
59-
60-
(defun convert-markdown-into-html (file)
6143
(check-if-command-installed *timeout-command* *pandoc-path*)
62-
(ignore-some-conditions (uiop:subprocess-error)
63-
(with-output-to-string (s)
64-
(uiop:run-program `(,*timeout-command* 10 ,*pandoc-path* ,(namestring file))
65-
:force-shell t
66-
:output s
67-
:error-output *error-output*))))
44+
(with-output-to-string (s)
45+
(uiop:run-program `(,*timeout-command* "10" ,*pandoc-path* "-f" ,from "-t" ,to ,(namestring (probe-file file)))
46+
:force-shell t
47+
:output s
48+
:error-output *error-output*)))
6849

69-
(defun convert-org-into-html (file)
70-
(check-if-command-installed *timeout-command* *emacs-path*)
71-
(ignore-some-conditions (uiop:subprocess-error)
72-
(with-output-to-string (s)
73-
(uiop:run-program `(,*timeout-command*
74-
10
75-
,*emacs-path* "-Q" "-batch" "--file" ,(namestring file)
76-
"--eval" "(setq org-export-with-toc nil)"
77-
"--eval" "(princ (org-export-as-html 3 nil 'string t))")
78-
:force-shell t
79-
:output s
80-
:error-output *error-output*))))
50+
(defun convert-readme (file)
51+
(check-type file pathname)
52+
(let ((type (pathname-type file)))
53+
(ignore-some-conditions (uiop:subprocess-error)
54+
(cond
55+
((or (string= type "markdown")
56+
(string= type "md"))
57+
(pandoc file :from "markdown"))
58+
((string= type "org")
59+
(pandoc file :from "org"))))))

0 commit comments

Comments
 (0)