Permalink
Browse files

added cliki2 markup extensions: category-link and category-list

  • Loading branch information...
1 parent 57013f5 commit b2d06bfa1f6b8b35d338d527b2c80e6328c3c3b7 @archimag archimag committed Mar 18, 2011
Showing with 36 additions and 18 deletions.
  1. +0 −2 src/categories.lisp
  2. +4 −1 src/defmodule.lisp
  3. +32 −15 src/markup.lisp
View
@@ -1,7 +1,5 @@
(in-package #:cliki2)
-(defpackage #:cliki2.categories)
-
(defun category-keyword (category-title)
(intern (string-upcase category-title) '#:cliki2.categories))
View
@@ -1,12 +1,15 @@
;;;; defmodule.lisp
+(defpackage #:cliki2.categories)
+
(defpackage #:cliki2.markup
(:use #:cl #:iter #:esrap)
(:export #:generate-html-from-markup))
(restas:define-module #:cliki2
(:use #:cl #:iter #:bknr.datastore #:bknr.indices #:cliki2.markup)
- (:export #:view-article #:view-person))
+ (:export #:view-article #:view-person
+ #:category-keyword))
(in-package #:cliki2)
View
@@ -70,13 +70,19 @@
:href (clhs-lookup:spec-lookup symbol)))
stream))
+(define-rule category-link (and (and (? #\\) "*(") (+ (and (! #\)) character)) #\))
+ (:destructure (start category end)
+ (declare (ignore start end))
+ (cons :article-link (concat category))))
+
(define-rule 3bmd-grammar::link
(or 3bmd-grammar::explicit-link
3bmd-grammar::reference-link
3bmd-grammar::auto-link
article-link
person-link
- hyperspec-link))
+ hyperspec-link
+ category-link))
(define-rule empty-lines
(* (and (* (or #\Space #\Tab)) (? #\Return) #\Newline)))
@@ -99,18 +105,29 @@
(:lambda (a)
(list :code a)))
-(define-rule 3bmd-grammar::code (or 3bmdcode code-block))
-
-;;;; category *()
-
-;;;; category list /()
-
-;; (defmethod docutils:visit-node ((writer docutils.writer.html:html-writer) (node category-content))
-;; (append-template 'cliki2.view:category-content
-;; :items (iter (for article in (articles-with-category (category-content-title node)))
-;; (collect
-;; (list :title (article-title article)
-;; :href (restas:genurl 'view-article
-;; :title (article-title article)))))))
-
+(defun category-char-p (character)
+ (not (member character '(#\: #\" #\)))))
+
+(define-rule category-name (and (? #\") (+ (category-char-p character)) (? #\"))
+ (:lambda (list)
+ (concat (second list))))
+
+(define-rule category-list (and (and (? #\\) "_/(")
+ category-name
+ (* (and (! #\)) character))
+ ")")
+ (:lambda (list)
+ (cons :cliki2-category-list (cliki2:category-keyword (second list)))))
+
+
+(defmethod 3bmd::print-tagged-element ((tag (eql :cliki2-category-list)) stream category)
+ (write-string (cliki2.view:category-content
+ (list :items
+ (iter (for article in (cliki2::articles-with-category category))
+ (collect
+ (list :title (cliki2::article-title article)
+ :href (restas:genurl 'cliki2:view-article
+ :title (cliki2::article-title article)))))))
+ stream))
+(define-rule 3bmd-grammar::code (or 3bmdcode code-block category-list))

0 comments on commit b2d06bf

Please sign in to comment.