-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwiki2html.ros
executable file
·66 lines (59 loc) · 1.75 KB
/
wiki2html.ros
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
(ros:ensure-asdf)
#+quicklisp
(ql:quickload
'(3bmd
3bmd-ext-tables
3bmd-ext-wiki-links
3bmd-ext-code-blocks
cl-ppcre
clip
alexandria)
:silent t)
)
(defpackage :ros.script.wiki2html.3723862172
(:use :cl))
(in-package :ros.script.wiki2html.3723862172)
;; Enable 3bmd features
(setq 3bmd-wiki:*wiki-links* t
3bmd-wiki:*wiki-processor* t
3bmd-tables:*table-class* "pure-table"
3bmd-tables:*tables* t
3bmd-code-blocks:*code-blocks* t)
(defmethod 3bmd-wiki:process-wiki-link ((w t) nt formatted a stream)
(declare (ignore w nt a))
(format stream "<a href=\"~a.html\">~a</a>"
(ppcre:regex-replace-all " " formatted "-")
formatted))
(defun render-markdown (file)
(values
(alexandria::with-output-to-string (stream)
(3bmd:parse-and-print-to-stream file stream))
(ppcre:regex-replace-all "-" (pathname-name file) " ")))
(defun render-html (title article navigation)
(clip:process-to-string
(alexandria:read-file-into-string #p"./_template.html")
:title title
:article article
:navigation navigation))
(defun main (&rest argv)
(declare (ignorable argv))
(loop
:with navigation := (render-markdown #p"./roswell.wiki/_Sidebar.md")
:for file :in (directory #p"./roswell.wiki/*.md")
:for (article title) := (multiple-value-list (render-markdown file))
:unless (string= (pathname-name file) "_Sidebar") :do
(alexandria:write-string-into-file
(render-html title article navigation)
(make-pathname
:directory '(:relative ".")
:name (pathname-name file)
:type "html")
:if-exists :supersede
:if-does-not-exist :create)))
;;; vim: set ft=lisp lisp: