Skip to content

Commit e52357d

Browse files
committed
Misc cleanup as I figured out the previous commit.
1 parent e62ed22 commit e52357d

File tree

2 files changed

+53
-57
lines changed

2 files changed

+53
-57
lines changed

_ref/arc/html.arc

+17-12
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,24 @@
176176

177177
(def tag-options (spec options)
178178
(if (no options)
179-
'()
180-
(let ((opt val) . rest) options
181-
(let meth (if (is opt 'style) opstring (opmeth spec opt))
182-
(if meth
183-
(if val
184-
(cons (if (precomputable-tagopt val)
185-
(tostring (eval (meth opt val)))
186-
(meth opt val))
187-
(tag-options spec rest))
179+
'()
180+
(let ((opt val) . rest) options
181+
(let meth (if (in opt 'style 'class)
182+
opstring
183+
(is opt 'id)
184+
opsym
185+
'else
186+
(opmeth spec opt))
187+
(if meth
188+
(if val
189+
(cons (if (precomputable-tagopt val)
190+
(tostring (eval (meth opt val)))
191+
(meth opt val))
188192
(tag-options spec rest))
189-
(do
190-
(pr "<!-- ignoring " opt " for " spec "-->")
191-
(tag-options spec rest)))))))
193+
(tag-options spec rest))
194+
(do
195+
(pr "<!-- ignoring " opt " for " spec "-->")
196+
(tag-options spec rest)))))))
192197

193198
(def precomputable-tagopt (val)
194199
(and (literal val)

_ref/template.arc

+36-45
Original file line numberDiff line numberDiff line change
@@ -261,65 +261,56 @@
261261
result))
262262

263263
(def readtop (filename)
264-
; (index* foo.tem) == (prev.tem this.tem next.tem)
264+
; (index* foo.tem) == (title prev.tem this.tem next.tem)
265+
(= index* (table))
266+
(let temlinks (gettemlinks filename)
265267
; pagelist* == ("page1.tem" "page2.tem" ...)
266-
(= index* (table))
267-
(let temlinks (gettemlinks filename)
268-
(= pagelist* (map [_ 1] temlinks))
269-
(each (title link) temlinks
270-
(= (index* link) title)) ; (index* foo.tem) = title
271-
(each trip (triples (+ '(nil) pagelist* '(nil)))
272-
(= (index* (trip 1)) (cons (index* (trip 1)) trip))
273-
)))
268+
(= pagelist* (map [_ 1] temlinks))
269+
(each (title link) temlinks
270+
(= (index* link) title))
271+
(each trip (triples (+ '(nil) pagelist* '(nil)))
272+
(if trip
273+
(= (index* trip.1) (cons (index* trip.1) trip)))
274+
)))
274275

275276
(def htmllink (href text) (prn "<a href=\"" href "\">" text "</a>"))
276277

277278
; Convert foo.tem to foo.html
278279
(def htmlname(x) (subst ".html" ".tem" x))
279280

280281
(def getlinks (tem)
281-
(let info (index* tem)
282-
(if info
283-
(with (text (info 0) prev (info 1) this (info 2) next (info 3))
284-
(tostring (pr "<div class=\"links\">")
285-
(when prev
286-
(pr "Previous: ")
287-
(htmllink (htmlname prev) ((index* prev) 0)))
288-
(pr "Up: ")
289-
(htmllink "index.html" "Contents")
290-
(when next
291-
(pr "Next: ")
292-
(htmllink (htmlname next) ((index* next) 0)))
293-
(pr "</div>")
294-
)
295-
))))
296-
297-
(= index* nil)
282+
(aif index*.tem
283+
(let (_ prev this next) it
284+
(tostring
285+
(tag (div class "links")
286+
(when prev
287+
(pr "Previous: ")
288+
(htmllink (htmlname prev) ((index* prev) 0)))
289+
(pr "Up: ")
290+
(htmllink "index.html" "Contents")
291+
(when next
292+
(pr "Next: ")
293+
(htmllink (htmlname next) ((index* next) 0))))))))
298294

299295
; Generate html from a template
300296
(def run (filename)
301-
(= current-file* filename)
302-
(= out-file-name* (+ "html/" (subst "" ".tem" filename) ".html"))
303-
(= page* "")
304-
(= out-file* (outfile out-file-name*))
305-
(when (no index*)
306-
(prn "Reading top.tem")
307-
(readtop "top.tem"))
308-
(= links* (getlinks filename))
309-
(doit (sread (infile filename) 'eof))
310-
out-file-name*
311-
)
297+
(= current-file* filename)
298+
(= out-file-name* (+ "html/" (subst "" ".tem" filename) ".html"))
299+
(= page* "")
300+
(= out-file* (outfile out-file-name*))
301+
(= links* (getlinks filename))
302+
(doit (sread (infile filename) 'eof))
303+
out-file-name*)
312304

313305
; Run through all the templates listed in the top file.
314306
(def runall ((o topname "docs/index.html"))
315-
(= all-links* '())
316-
(readtop topname)
317-
(= update-links* t)
318-
(on filename pagelist*
319-
(prn "Doing file " filename)
320-
(run filename))
321-
(= update-links* nil)
322-
)
307+
(= all-links* '())
308+
(readtop topname)
309+
(= update-links* t)
310+
(on filename pagelist*
311+
(prn "Doing file " filename)
312+
(run filename))
313+
(= update-links* nil))
323314

324315
(def tem () (load "template.arc"))
325316

0 commit comments

Comments
 (0)