Skip to content
Newer
Older
100644 136 lines (103 sloc) 4.7 KB
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
1 (in-package #:cliki2)
2 (in-readtable cliki2)
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
3
5a7e779 @archimag refactoring
archimag authored Mar 19, 2011
4 (defvar *cliki2-rules* (alexandria:copy-hash-table *rules*))
5
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
6 (defmacro define-rule (symbol expression &body options)
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
7 `(let ((*rules* *cliki2-rules*))
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
8 (defrule ,symbol ,expression ,@options)))
9
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
10 (let ((cliki2-grammar (esrap:compile-grammar '3bmd-grammar::block)))
11 (defun parse-cliki2-doc (markup)
12 (let ((*rules* *cliki2-rules*)
13 (curpos 0))
14 (iter (multiple-value-bind (block pos)
15 (parse cliki2-grammar markup :start curpos :junk-allowed t)
16 (while block) (collect block)
17 (while pos) (setf curpos pos))))))
18
19 (defun generate-html-from-markup (markup &optional
20 (sanitize-mode sanitize:+relaxed+))
21 (sanitize:clean
22 (with-output-to-string (s)
23 (3bmd:print-doc-to-stream
24 (parse-cliki2-doc (3bmd::expand-tabs markup :add-newlines t)) s))
25 sanitize-mode))
26
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
27 ;;; cliki2 markup extensions
28
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
29 ;;;; article-link
30
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
31 (define-rule article-link (and (and (? #\\) "_(") (+ (and (! #\)) character)) #\))
32 (:destructure (start article end)
33 (declare (ignore start end))
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
34 (cons :article-link (cut-whitespace (text article)))))
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
35
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
36 (defmethod 3bmd:print-tagged-element ((tag (eql :article-link)) *html-stream* title)
39d1d43 @vsedach Put up account info page
authored Nov 14, 2011
37 (pprint-article-link title))
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
38
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
39 ;;;; person-link
40
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
41 (define-rule person-link (and "_P(" (+ (and (! #\)) character)) #\))
42 (:destructure (start name end)
43 (declare (ignore start end))
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
44 (cons :person-link (cut-whitespace (text name)))))
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
45
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
46 (defmethod 3bmd:print-tagged-element ((tag (eql :person-link)) *html-stream* name)
47 #H[<a href="$(#/site/account?name={name})" class="person">${name}</a>])
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
48
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
49 ;;;; hyperspec-link
50
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
51 (define-rule hyperspec-link (and "_H(" (+ (and (! #\)) character)) #\))
52 (:destructure (start symbol end)
53 (declare (ignore start end))
2eb30fe @archimag sync with esrap
archimag authored Apr 29, 2011
54 (cons :hyperspec-link (text symbol))))
5606e43 @archimag added to markup: hyperspec-ref and code-block
archimag authored Mar 6, 2011
55
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
56 (defmethod 3bmd:print-tagged-element ((tag (eql :hyperspec-link)) *html-stream* symbol)
57 #H[<a href="${(clhs-lookup:spec-lookup symbol)}" class="hyperspec">${symbol}</a>]) ;; where does this come from?
5606e43 @archimag added to markup: hyperspec-ref and code-block
archimag authored Mar 6, 2011
58
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
59 ;;;; category-link
60
b2d06bf @archimag added cliki2 markup extensions: category-link and category-list
archimag authored Mar 18, 2011
61 (define-rule category-link (and (and (? #\\) "*(") (+ (and (! #\)) character)) #\))
62 (:destructure (start category end)
63 (declare (ignore start end))
a4f1460 @vsedach Synced with 3bmd changes, factored out article description printing
authored Nov 15, 2011
64 (cons :article-link (cut-whitespace (text category)))))
b2d06bf @archimag added cliki2 markup extensions: category-link and category-list
archimag authored Mar 18, 2011
65
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
66 ;;;; code-block
67
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
68 (define-rule empty-lines
69 (* (and (* (or #\Space #\Tab)) (? #\Return) #\Newline)))
5606e43 @archimag added to markup: hyperspec-ref and code-block
archimag authored Mar 6, 2011
70
57013f5 @archimag added cliki2 markup extensions: article-link, person-link, hyperspec-…
archimag authored Mar 18, 2011
71 (define-rule code-block (and "<code>"
72 empty-lines
73 (+ (and (! (and empty-lines "</code>")) character))
74 empty-lines
75 "</code>")
76 (:destructure (start w1 code w2 end)
77 (declare (ignore start w1 w2 end))
2eb30fe @archimag sync with esrap
archimag authored Apr 29, 2011
78 (cons :lisp-code-block (text code))))
17416b2 @archimag added markup: article-ref and person-ref
archimag authored Mar 6, 2011
79
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
80 (defmethod 3bmd:print-tagged-element ((tag (eql :lisp-code-block)) *html-stream* code)
81 #H[<div class="code">${(colorize::html-colorization :common-lisp code)}</div>])
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
82
83 ;;;; category-list
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
84
b2d06bf @archimag added cliki2 markup extensions: category-link and category-list
archimag authored Mar 18, 2011
85 (defun category-char-p (character)
86 (not (member character '(#\: #\" #\)))))
87
88 (define-rule category-name (and (? #\") (+ (category-char-p character)) (? #\"))
89 (:lambda (list)
2eb30fe @archimag sync with esrap
archimag authored Apr 29, 2011
90 (text (second list))))
b2d06bf @archimag added cliki2 markup extensions: category-link and category-list
archimag authored Mar 18, 2011
91
92 (define-rule category-list (and (and (? #\\) "_/(")
93 category-name
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
94 (* (and (! #\)) character))
b2d06bf @archimag added cliki2 markup extensions: category-link and category-list
archimag authored Mar 18, 2011
95 ")")
96 (:lambda (list)
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
97 (cons :cliki2-category-list (category-keyword (second list)))))
b2d06bf @archimag added cliki2 markup extensions: category-link and category-list
archimag authored Mar 18, 2011
98
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
99 (sanitize:define-sanitize-mode +links-only+
e666c10 @archimag "category list" markup extension - add short article description (as …
archimag authored Apr 1, 2011
100 :elements ("a")
e9228f3 @archimag improved internal links
archimag authored Apr 2, 2011
101 :attributes (("a" . ("href" "class")))
e666c10 @archimag "category list" markup extension - add short article description (as …
archimag authored Mar 31, 2011
102 :protocols (("a" . (("href" . (:ftp :http :https :mailto :relative))))))
103
f26f020 @vsedach Replaced css-based pprint-article-summary-li rules with a simpler sep…
authored Nov 16, 2011
104 (defun pprint-article-summary-li (article separator)
a4f1460 @vsedach Synced with 3bmd changes, factored out article description printing
authored Nov 16, 2011
105 #H[<li>] (pprint-article-link (title article))
f26f020 @vsedach Replaced css-based pprint-article-summary-li rules with a simpler sep…
authored Nov 16, 2011
106 #H[ ${separator}
107 ${(generate-html-from-markup (article-description article) +links-only+)}
108 </li>])
a4f1460 @vsedach Synced with 3bmd changes, factored out article description printing
authored Nov 16, 2011
109
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
110 (defmethod 3bmd:print-tagged-element ((tag (eql :cliki2-category-list)) *html-stream* category)
f26f020 @vsedach Replaced css-based pprint-article-summary-li rules with a simpler sep…
authored Nov 16, 2011
111 #H[<ul>] (dolist (article (sort (copy-list (articles-with-category category))
112 #'string< :key 'canonical-title))
113 (pprint-article-summary-li article "-"))
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
114 #H[</ul>])
9873a6f @archimag added categories
archimag authored Mar 7, 2011
115
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
116 ;;;; package-link
117
118 (define-rule package-link (and ":(package" (+ (or #\Tab #\Space #\Newline #\Return)) "\"" (+ (and (! #\") character)) "\")")
119 (:destructure (start w1 quote link end)
120 (declare (ignore start w1 quote end))
2eb30fe @archimag sync with esrap
archimag authored Apr 29, 2011
121 (cons :package-link (text link))))
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
122
41b9d56 @vsedach Removed RESTAS, simplified some things.
authored Nov 2, 2011
123 (defmethod 3bmd:print-tagged-element ((tag (eql :package-link)) *html-stream* link)
124 #H[<a href="${link}" class="download">Download ASDF package from ${link}</a>])
b4b73a6 @archimag added "package-link" markup extension
archimag authored Apr 2, 2011
125
126 ;;;; cliki2 markup extensions
e666c10 @archimag "category list" markup extension - add short article description (as …
archimag authored Mar 31, 2011
127
a4f1460 @vsedach Synced with 3bmd changes, factored out article description printing
authored Nov 16, 2011
128 (define-rule 3bmd-grammar::inline-extensions
7b531a5 @archimag Revert "sync with 3bmd/extensible branch"
archimag authored Apr 29, 2011
129 (or article-link
130 person-link
131 hyperspec-link
132 category-link
133 code-block
134 category-list
135 package-link))
Something went wrong with that request. Please try again.