Skip to content

Commit

Permalink
provides a read macro "#M(..)" as a synonym of "(markup ..)".
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Jan 8, 2011
1 parent 15496e2 commit 525ab40
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.markdown
Expand Up @@ -48,6 +48,17 @@ Markup macros output html tags into \*output-stream\*. The default is <code>NIL<
;;=> <p>hoge</p>
;=> T

## Markup syntax

You can embeded Lisp code in a tag body.

(markup (:ul (loop for item in '(1 2 3) collect (markup (:li item)))))

But, <code>markup</code> is too long to embed. cl-markup provides an usefull syntax to write more shortly.

(enable-markup-syntax)
#M(:ul (loop for item in '(1 2 3) collect #M(:li item))))

## License

Copyright (c) 2011 Eitarow Fukamachi.
Expand Down
3 changes: 2 additions & 1 deletion cl-markup.asd
Expand Up @@ -14,4 +14,5 @@
:serial t
:components ((:file "package")
(:file "special")
(:file "markup")))))
(:file "markup")
(:file "readmacro")))))
1 change: 1 addition & 0 deletions src/package.lisp
Expand Up @@ -5,6 +5,7 @@
(:export :markup :html :xhtml :xml
:doctype
:escape-string :raw :esc
:enable-markup-syntax
:*auto-escape*
:*output-stream*
:*markup-language*))
8 changes: 8 additions & 0 deletions src/readmacro.lisp
@@ -0,0 +1,8 @@
(in-package :cl-markup)

(defun markup-reader (stream char arg)
(declare (ignore char arg))
`(markup ,(read stream t nil t)))

(defun enable-markup-syntax ()
(set-dispatch-macro-character #\# #\M #'markup-reader))

0 comments on commit 525ab40

Please sign in to comment.