Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 131 lines (100 sloc) 4.742 kb
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
1 (in-package #:cliki2)
2 (in-readtable cliki2)
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
3
5a7e7795 » archimag
2011-03-19 refactoring
4 (defvar *cliki2-rules* (alexandria:copy-hash-table *rules*))
5
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
6 (defmacro define-rule (symbol expression &body options)
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
7 `(let ((*rules* *cliki2-rules*))
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
8 (defrule ,symbol ,expression ,@options)))
9
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
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
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
27 ;;; cliki2 markup extensions
28
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
29 ;;;; article-link
30
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
31 (define-rule article-link (and (and (? #\\) "_(") (+ (and (! #\)) character)) #\))
32 (:destructure (start article end)
33 (declare (ignore start end))
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
34 (cons :article-link (cut-whitespace (text article)))))
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
35
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
36 (defmethod 3bmd:print-tagged-element ((tag (eql :article-link)) *html-stream* title)
39d1d438 »
2011-11-14 Put up account info page
37 (pprint-article-link title))
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
38
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
39 ;;;; person-link
40
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
41 (define-rule person-link (and "_P(" (+ (and (! #\)) character)) #\))
42 (:destructure (start name end)
43 (declare (ignore start end))
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
44 (cons :person-link (cut-whitespace (text name)))))
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
45
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
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>])
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
48
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
49 ;;;; hyperspec-link
50
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
51 (define-rule hyperspec-link (and "_H(" (+ (and (! #\)) character)) #\))
52 (:destructure (start symbol end)
53 (declare (ignore start end))
2eb30fe0 » archimag
2011-04-29 sync with esrap
54 (cons :hyperspec-link (text symbol))))
5606e436 » archimag
2011-03-06 added to markup: hyperspec-ref and code-block
55
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
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?
5606e436 » archimag
2011-03-06 added to markup: hyperspec-ref and code-block
58
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
59 ;;;; category-link
60
b2d06bfa » archimag
2011-03-18 added cliki2 markup extensions: category-link and category-list
61 (define-rule category-link (and (and (? #\\) "*(") (+ (and (! #\)) character)) #\))
62 (:destructure (start category end)
63 (declare (ignore start end))
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
64 (cons :article-link (cliki2::cut-whitespace (text category)))))
b2d06bfa » archimag
2011-03-18 added cliki2 markup extensions: category-link and category-list
65
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
66 ;;;; code-block
67
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
68 (define-rule empty-lines
69 (* (and (* (or #\Space #\Tab)) (? #\Return) #\Newline)))
5606e436 » archimag
2011-03-06 added to markup: hyperspec-ref and code-block
70
57013f5d » archimag
2011-03-18 added cliki2 markup extensions: article-link, person-link, hyperspec-…
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))
2eb30fe0 » archimag
2011-04-29 sync with esrap
78 (cons :lisp-code-block (text code))))
17416b2f » archimag
2011-03-06 added markup: article-ref and person-ref
79
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
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>])
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
82
83 ;;;; category-list
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
84
b2d06bfa » archimag
2011-03-18 added cliki2 markup extensions: category-link and category-list
85 (defun category-char-p (character)
86 (not (member character '(#\: #\" #\)))))
87
88 (define-rule category-name (and (? #\") (+ (category-char-p character)) (? #\"))
89 (:lambda (list)
2eb30fe0 » archimag
2011-04-29 sync with esrap
90 (text (second list))))
b2d06bfa » archimag
2011-03-18 added cliki2 markup extensions: category-link and category-list
91
92 (define-rule category-list (and (and (? #\\) "_/(")
93 category-name
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
94 (* (and (! #\)) character))
b2d06bfa » archimag
2011-03-18 added cliki2 markup extensions: category-link and category-list
95 ")")
96 (:lambda (list)
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
97 (cons :cliki2-category-list (category-keyword (second list)))))
b2d06bfa » archimag
2011-03-18 added cliki2 markup extensions: category-link and category-list
98
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
99 (sanitize:define-sanitize-mode +links-only+
e666c102 » archimag
2011-04-01 "category list" markup extension - add short article description (as …
100 :elements ("a")
e9228f35 » archimag
2011-04-02 improved internal links
101 :attributes (("a" . ("href" "class")))
e666c102 » archimag
2011-04-01 "category list" markup extension - add short article description (as …
102 :protocols (("a" . (("href" . (:ftp :http :https :mailto :relative))))))
103
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
104 (defmethod 3bmd:print-tagged-element ((tag (eql :cliki2-category-list)) *html-stream* category)
105 #H[<ul>]
106 (dolist (article (sort (copy-list (cliki2::articles-with-category category))
107 #'string<
108 :key 'cliki2::canonical-title))
eb1a84bb »
2011-11-11 Fixed article rendering
109 #H[<li><a href="${(link-to article)}">${(title article)}</a> - ${(generate-html-from-markup (article-description article) +links-only+)}</li>])
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
110 #H[</ul>])
9873a6fb » archimag
2011-03-07 added categories
111
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
112 ;;;; package-link
113
114 (define-rule package-link (and ":(package" (+ (or #\Tab #\Space #\Newline #\Return)) "\"" (+ (and (! #\") character)) "\")")
115 (:destructure (start w1 quote link end)
116 (declare (ignore start w1 quote end))
2eb30fe0 » archimag
2011-04-29 sync with esrap
117 (cons :package-link (text link))))
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
118
41b9d56d »
2011-11-02 Removed RESTAS, simplified some things.
119 (defmethod 3bmd:print-tagged-element ((tag (eql :package-link)) *html-stream* link)
120 #H[<a href="${link}" class="download">Download ASDF package from ${link}</a>])
b4b73a6f » archimag
2011-04-02 added "package-link" markup extension
121
122 ;;;; cliki2 markup extensions
e666c102 » archimag
2011-04-01 "category list" markup extension - add short article description (as …
123
7b531a50 » archimag
2011-04-29 Revert "sync with 3bmd/extensible branch"
124 (define-rule 3bmd-grammar:inline-extensions
125 (or article-link
126 person-link
127 hyperspec-link
128 category-link
129 code-block
130 category-list
131 package-link))
Something went wrong with that request. Please try again.