Skip to content

Commit 4e6c293

Browse files
committed
Created an html5 tags file and system, as well as exported the html5 document stuff
1 parent a58112b commit 4e6c293

File tree

6 files changed

+182
-16
lines changed

6 files changed

+182
-16
lines changed

buildnode-html5.asd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
;; -*- lisp -*-
2+
3+
(eval-when (:compile-toplevel :load-toplevel :execute)
4+
(unless (find-package :net.acceleration.buildnode.system)
5+
(defpackage :net.acceleration.buildnode.system
6+
(:use :common-lisp :asdf))))
7+
8+
(in-package :net.acceleration.buildnode.system)
9+
10+
(defsystem :buildnode-html5
11+
:description "Tool for building up an xml dom of an html5 document"
12+
:components
13+
((:module :src
14+
:serial T
15+
:components
16+
((:module :tags
17+
:serial T
18+
:components
19+
((:file "html5-tags"))))))
20+
:depends-on (:buildnode))

buildnode.asd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
:cl-interpol
3030
;; TODO:
3131
;; for html-generation - probably not a dependancy of the whole library
32-
:closure-html
32+
:closure-html
33+
:cl-ppcre
34+
:symbol-munger
3335
))
3436

3537
(defsystem :buildnode-test

src/buildnode.lisp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,12 @@ This sets the doctype to be html 4.01 strict."
626626
(append-nodes *document* ,@body)
627627
*document*))
628628

629+
(defmacro with-html5-document-to-file ((filename) &body body)
630+
"Creates an html-document, writes out the results to filename"
631+
`(let ((*html-compatibility-mode* T))
632+
(write-doc-to-file (with-html5-document ,@body)
633+
,filename)))
634+
629635
(defmacro with-html5-document (&body body)
630636
"(with-html5-document ( a bunch of child nodes of the document )) --> cxml:dom document
631637
Creates an environment in which the special variable *document* is available

src/packages.lisp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#:with-xhtml-document-to-file
3030
#:with-html-document
3131
#:with-html-document-to-file
32+
#:with-html5-document
33+
#:with-html5-document-to-file
34+
#:with-html5-document-to-string
3235
#:append-nodes
3336
#:insert-nodes
3437
#:add-children

src/tags/html5-tags.lisp

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
(in-package :net.acceleration.buildnode)
2+
(cl-interpol:enable-interpol-syntax)
3+
4+
(eval-always
5+
(unless (find-package :net.acceleration.html5)
6+
(defpackage :net.acceleration.html5 (:nicknames :html5) (:use ))))
7+
8+
(pushnew :buildnode-html5 *features* :test #'eql)
9+
10+
(defparameter +html5-namespace+ "http://www.w3.org/1999/xhtml")
11+
12+
(defparameter +html5-tag-spec+
13+
"a – hyperlink CHANGED
14+
abbr – abbreviation
15+
address – contact information
16+
area – image-map hyperlink
17+
article – article NEW
18+
aside – tangential content NEW
19+
audio – audio stream NEW
20+
b – offset text conventionally styled in bold CHANGED
21+
base – base URL
22+
bdi – BiDi isolate NEW
23+
bdo – BiDi override
24+
blockquote – block quotation
25+
body – document body
26+
br – line break
27+
button – button
28+
button type=submit – submit button
29+
button type=reset – reset button
30+
button type=button – button with no additional semantics
31+
canvas – canvas for dynamic graphics NEW
32+
caption – table title
33+
cite – cited title of a work CHANGED
34+
code – code fragment
35+
col – table column
36+
colgroup – table column group
37+
command – command NEW
38+
datalist – predefined options for other controls NEW
39+
dd – description or value
40+
del – deleted text
41+
details – control for additional on-demand information NEW
42+
dfn – defining instance
43+
div – generic flow container
44+
dl – description list
45+
dt – term or name
46+
em – emphatic stress
47+
embed – integration point for plugins NEW
48+
fieldset – set of related form controls
49+
figcaption – figure caption NEW
50+
figure – figure with optional caption NEW
51+
footer – footer NEW
52+
form – user-submittable form
53+
h1 – heading
54+
h2 – heading
55+
h3 – heading
56+
h4 – heading
57+
h5 – heading
58+
h6 – heading
59+
head – document metadata container
60+
header – header NEW
61+
hgroup – heading group NEW
62+
hr – thematic break CHANGED
63+
html – root element
64+
i – offset text conventionally styled in italic CHANGED
65+
iframe – nested browsing context (inline frame)
66+
img – image
67+
input – input control CHANGED
68+
ins – inserted text
69+
kbd – user input
70+
keygen – key-pair generator/input control NEW
71+
label – caption for a form control
72+
legend – title or explanatory caption
73+
li – list item
74+
link – inter-document relationship metadata
75+
map – image-map definition
76+
mark – marked (highlighted) text NEW
77+
menu – list of commands CHANGED
78+
meta – metadata CHANGED
79+
meter – scalar gauge NEW
80+
nav – group of navigational links NEW
81+
noscript – fallback content for script
82+
object – generic external content
83+
ol – ordered list
84+
optgroup – group of options
85+
option – option
86+
output – result of a calculation in a form NEW
87+
p – paragraph
88+
param – initialization parameters for plugins
89+
pre – preformatted text
90+
progress – progress indicator NEW
91+
q – quoted text
92+
rp – ruby parenthesis NEW
93+
rt – ruby text NEW
94+
ruby – ruby annotation NEW
95+
s – struck text CHANGED
96+
samp – (sample) output
97+
script – embedded script
98+
section – section NEW
99+
select – option-selection form control
100+
small – small print CHANGED
101+
source – media source NEW
102+
span – generic span
103+
strong – strong importance
104+
style – style (presentation) information
105+
sub – subscript
106+
summary – summary, caption, or legend for a details control NEW
107+
sup – superscript
108+
table – table
109+
tbody – table row group
110+
td – table cell
111+
textarea – text input area
112+
tfoot – table footer row group
113+
th – table header cell
114+
thead – table heading group
115+
time – date and/or time NEW
116+
title – document title
117+
tr – table row
118+
track – supplementary media track NEW
119+
u – offset text conventionally styled with an underline CHANGED
120+
ul – unordered list
121+
var – variable or placeholder text
122+
video – video NEW
123+
wbr – line-break opportunity")
124+
125+
(iter (for row in (cl-ppcre:split #?r"\n" +html5-tag-spec+))
126+
(for (name doc) = (cl-ppcre:split #?r"" row))
127+
(for sname = (symbol-munger:english->lisp-symbol name :net.acceleration.html5))
128+
(def-tag-node :net.acceleration.html5 `',name +xhtml-namespace+ doc)
129+
(export sname :net.acceleration.html5))

src/tags/tags.lisp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,32 @@
2121
(when (boundp 'swank::*application-hints-tables*)
2222
(pushnew *tags-indentation-hints* swank::*application-hints-tables*))
2323

24+
;; TODO, so hacky, but I had to make it work, please fix this future me I am
25+
;; guessing that originally the evals everywhere were to make sure that
26+
;; everything is evaled once
27+
(defun %do-def-tag-node (package name namespace docstring &optional fn-name)
28+
(let* ((evaled-name (eval name))
29+
(name (or fn-name
30+
(symbol-munger:english->lisp-symbol (eval package))))
31+
(tagname evaled-name))
32+
(eval
33+
`(progn
34+
(CL:defun ,name (&optional attributes &rest children )
35+
,@(when docstring (list docstring))
36+
(declare (special *document*))
37+
(create-complete-element *document*
38+
,namespace
39+
,tagname
40+
attributes
41+
children))
42+
(setf (gethash ',name *tags-indentation-hints*) 1)
43+
))))
2444

2545
(defmacro def-tag-node (package name namespace docstring &optional fn-name )
2646
"Defines a tag function in the package with the name and prefix specified
2747
for example: :net.acceleration.xul \"box\" \"xul\" will create a function #'box in the :net.acceleration.xul
2848
lisp namespace. When this function is called it will create a 'xul:box' node in the xmlns provided in the namespace param"
29-
(let* ((evaled-name (eval name))
30-
(name (or fn-name
31-
(intern (string-upcase evaled-name) (eval package))))
32-
(tagname evaled-name))
33-
`(progn
34-
(CL:defun ,name (&optional attributes &rest children )
35-
,@(when docstring (list docstring))
36-
(declare (special *document*))
37-
(create-complete-element *document*
38-
,namespace
39-
,tagname
40-
attributes
41-
children))
42-
(setf (gethash ',name *tags-indentation-hints*) 1)
43-
)))
49+
`(%do-def-tag-node ,package ,name ,namespace ,docstring ,fn-name))
4450

4551
(defun ?xml-stylesheet (href &optional (type "text/css" ))
4652
"adds an xml-stylesheet processing instruction to the cxml:dom document bound to the

0 commit comments

Comments
 (0)