Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-markup Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 12:31:20 2020 GMT+0.
• Introduction | What cl-markup is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
(html
(:body
(:p :id "title" "aiueo")))
;=> "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
; \"http://www.w3.org/TR/html4/loose.dtd\">
; <html><body><p id=\"title\">aiueo</p></body></html>"
Generally CL-MARKUP generates efficient codes which mainly consists of series of `write-string's as much as possible. See how following two examples are expanded by macro expansion.
As you can see, the codes are a bit more complicated than that of CL-WHO because CL-MARKUP alters the destination of output in run-time.
Example A:
;; Example A
(let ((*output-stream* t))
(loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
("http://marcusmiller.com/" . "Marcus Miller")
("http://www.milesdavis.com/" . "Miles Davis"))
do (markup (:a :href link
(:b title))
(:br))))
;; Example A: generated by CL-MARKUP
(let ((*output-stream* t))
(loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
("http://marcusmiller.com/" . "Marcus Miller")
("http://www.milesdavis.com/" . "Miles Davis"))
do (if *output-stream*
(progn (write-string "<a href=\"" *output-stream*)
(write-string (escape-string (cl-markup::ensure-string link))
*output-stream*)
(write-string "\"><b>" *output-stream*)
(write-string (escape-string (cl-markup::ensure-string title))
*output-stream*)
(write-string "</b></a><br />" *output-stream*))
(with-output-to-string (#:G0)
(write-string "<a href=\"" #:G0)
(write-string (escape-string (cl-markup::ensure-string link)) #:G0)
(write-string "\"><b>" #:G0)
(write-string (escape-string (cl-markup::ensure-string title)) #:G0)
(write-string "</b></a><br />" #:G0)))))
Example B:
;; Example B
(markup
(:table :border 0 :cellpadding 4
(loop for i below 25 by 5
collect
(markup
(:tr :align "right"
(loop for j from i below (+ i 5)
collect
(markup
(:td :bgcolor
(if (oddp j)
"pink"
"green")
(format nil "~@R" (1+ j))))))))))
;; Example B: generated by CL-MARKUP
(if *output-stream*
(progn (write-string "<table border=\"0\" cellpadding=\"4\">"
*output-stream*)
(write-string (let ((#:G0
(loop for i below 25 by 5
collect (markup
(:tr
:align
"right"
(loop for j
from
i
below
(+ i 5)
collect (markup
(:td
:bgcolor
(if
(oddp j)
"pink"
"green")
(format
nil
"~@r"
(1+ j))))))))))
(if (consp #:G0)
(with-output-to-string (#:G1)
(dolist (#:G2 #:G0)
(write-string #:G2 #:G1)))
#:G0))
*output-stream*)
(write-string "</table>" *output-stream*))
(with-output-to-string (#:G0)
(write-string "<table border=\"0\" cellpadding=\"4\">"
#:G0)
(write-string (let
((#:G0
(loop for i below 25 by 5
collect (markup
(:tr
:align
"right"
(loop for j
from
i
below
(+ i 5)
collect (markup
(:td
:bgcolor
(if
(oddp j)
"pink"
"green")
(format
nil
"~@r"
(1+
j))))))))))
(if
(consp #:G0)
(with-output-to-string
(#:G1)
(dolist
(#:G2 #:G0)
(write-string #:G2 #:G1)))
#:G0))
#:G0)
(write-string "</table>" #:G0)))
markup is the simplest way to generate HTML.
(markup (:p "あいうえお"))
;=> "<p>あいうえお</p>"
By default, CL-MARKUP follows XHTML valid styling.
(markup (:br))
;=> "<br />"
You can configure the style by setting *markup-language*.
(eval-when (:compile-toplevel :load-toplevel :execute)
(setf *markup-language* :html))
Don't forget to wrap setf with eval-when since it is used in compile-time in order to expand markup. This also means you are NOT allowed to write codes like this:
;; THIS IS A WRONG EXAMPLE!!
(let ((*markup-language* :html))
(markup (:br)))
;=> "<br />"
In case you really want to delay the decision until run-time, use markup*, a functional version of markup.
;; This is a correct one.
;; But I don't recommend this for performance.
(let ((*markup-language* :xhtml))
(markup* '(:br)))
;=> "<br>"
Other macros such as html, xhtml, html5, and xml output DOCTYPE before markup.
(html (:p "あいうえお") (:br))
;=> "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><p>あいうえお</p><br></html>"
(html5 (:p "あいうえお") (:br))
;=> "<!DOCTYPE html><html><p>あいうえお</p><br></html>"
(xhtml (:p "あいうえお") (:br))
;=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><p>あいうえお</p><br /></html>"
(xml (:p "あいうえお") (:br))
;=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><p>あいうえお</p><br />"
Embedded strings are escaped automatically.
(markup (:p "Tiffany & Co."))
;=> "<p>Tiffany & Co.</p>"
If you don't want this behavior, set *auto-escape* nil or use raw for temporal suppression.
(let ((*auto-escape* nil))
(markup (:p "Tiffany & Co.")))
;=> "<p>Tiffany & Co.</p>"
(markup (:p (raw "Tiffany & Co.")))
;=> "<p>Tiffany & Co.</p>"
Also, when you want to ensure a certain code to be escaped (maybe inside raw) use esc, which has the similar syntax as that of raw.
Markup macros returns html as a string. This behavior can be customized by modifying *output-stream* which is defaulted to *standard-output*.
;; Default behavior
(let (*output-stream*)
(markup (:p "hoge"))
;=> "<p>hoge</p>"
;; Output to *standard-output* directly
(let ((*output-stream* t))
(markup (:p "hoge")))
;;=> <p>hoge</p>
;=> "<p>hoge</p>"
You can embed Lisp code in the body of each tag.
(markup (:ul (loop for item in '(1 2 3) collect (markup (:li item)))))
For more readability, CL-MARKUP provides a reader macro #M which can be enabled by (enable-markup-syntax).
(enable-markup-syntax)
#M(:ul (loop for item in '(1 2 3) collect #M(:li item))))
Copyright (c) 2011 Eitarow F
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The cl-markup system |
Eitarow Fukamachi
LLGPL
0.1
cl-markup.asd (file)
src (module)
Modules are listed depth-first from the system components tree.
• The cl-markup/src module |
cl-markup (system)
src/
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The cl-markup/src/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
cl-markup.asd
cl-markup (system)
Next: The cl-markup/src/util․lisp file, Previous: The cl-markup․asd file, Up: Lisp files [Contents][Index]
Next: The cl-markup/src/special․lisp file, Previous: The cl-markup/src/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
src (module)
src/util.lisp
Next: The cl-markup/src/markup․lisp file, Previous: The cl-markup/src/util․lisp file, Up: Lisp files [Contents][Index]
util.lisp (file)
src (module)
src/special.lisp
Next: The cl-markup/src/helper․lisp file, Previous: The cl-markup/src/special․lisp file, Up: Lisp files [Contents][Index]
special.lisp (file)
src (module)
src/markup.lisp
Next: The cl-markup/src/readmacro․lisp file, Previous: The cl-markup/src/markup․lisp file, Up: Lisp files [Contents][Index]
markup.lisp (file)
src (module)
src/helper.lisp
Previous: The cl-markup/src/helper․lisp file, Up: Lisp files [Contents][Index]
helper.lisp (file)
src (module)
src/readmacro.lisp
enable-markup-syntax (macro)
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The cl-markup-asd package | ||
• The cl-markup package |
Next: The cl-markup package, Previous: Packages, Up: Packages [Contents][Index]
cl-markup.asd
Previous: The cl-markup-asd package, Up: Packages [Contents][Index]
package.lisp (file)
markup
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported macros | ||
• Exported functions |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Valid markup languages are :html, :xhtml and :xml
special.lisp (file)
Stream to output the generated string. If this is nil, then just return as a string the result. T means *standard-output*.
special.lisp (file)
Next: Exported functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
readmacro.lisp (file)
helper.lisp (file)
markup.lisp (file)
markup.lisp (file)
markup.lisp (file)
helper.lisp (file)
markup.lisp (file)
markup.lisp (file)
Previous: Exported macros, Up: Exported definitions [Contents][Index]
markup.lisp (file)
markup.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal macros | ||
• Internal functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
markup.lisp (file)
markup.lisp (file)
markup.lisp (file)
Previous: Internal macros, Up: Internal definitions [Contents][Index]
markup.lisp (file)
readmacro.lisp (file)
markup.lisp (file)
readmacro.lisp (file)
markup.lisp (file)
markup.lisp (file)
markup.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L M |
---|
Jump to: | C F L M |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | %
A D E F H M P R S T W X |
---|
Jump to: | %
A D E F H M P R S T W X |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
S |
---|
Jump to: | *
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P S |
---|
Jump to: | C P S |
---|