Add microformats2 tagging

Spec: <http://microformats.org/wiki/microformats2>

This makes it really easy to parse the registries back from the HTML
file in case we somehow lose the original S-expression files.
This commit is contained in:
Lassi Kortela 2020-08-06 11:51:30 +03:00
parent 2cab338eb4
commit ff193eb4f0
1 changed files with 101 additions and 59 deletions

View File

@ -1,4 +1,5 @@
(import (scheme base) (scheme file) (scheme read) (scheme write)) (import (scheme base) (scheme char) (scheme file)
(scheme read) (scheme write))
(import (srfi 132)) (import (srfi 132))
(define (read-all) (define (read-all)
@ -71,10 +72,18 @@
column-headings)) column-headings))
,@(map (lambda (row) ,@(map (lambda (row)
(let ((class (car row)) (let ((class (car row))
(tds (map (lambda (column) `(td ,column)) (tds (map (lambda (column heading)
(cdr row)))) `(td (@ (class
(if class `(tr (@ (class ,class)) ,@tds) ,(string-append
`(tr ,@tds)))) "p-"
(string-downcase heading))))
,column))
(cdr row)
column-headings)))
`(tr (@ (class ,(if class
(string-append "h-x-entry" " " class)
"h-x-entry")))
,@tds)))
rows))) rows)))
(define (the-usual entry) (define (the-usual entry)
@ -82,29 +91,47 @@
`((code ,(symbol->string (assoc1 'id entry))) `((code ,(symbol->string (assoc1 'id entry)))
,(assoc1 'description entry)))) ,(assoc1 'description entry))))
(define (registry registry-title registry-id intro table)
`(section
(@ (class "h-x-registry")
(data-p-id ,registry-id))
(h2 (@ (class "p-title"))
,registry-title)
(p "Registry ID: " (code (@ (class "p-id")) ,registry-id))
,intro
,table))
;; ;;
(define (scheme-id) (define (scheme-id)
`((h2 "Scheme implementations") (registry
(p "Scheme IDs for use in " "Scheme implementations"
"scheme-id"
'(p "Scheme IDs for use in "
(code "features") ", " (code "cond-expand") ", and many other places.") (code "features") ", " (code "cond-expand") ", and many other places.")
,(tabulate (tabulate
'("ID" "Name" "Contact") '("ID" "Name" "Contact")
(map (lambda (entry) (map (lambda (entry)
(append (the-usual entry) (list (assoc1 'contact entry)))) (append (the-usual entry) (list (assoc1 'contact entry))))
(sort-by-id (group-file 'id "scheme-id.scm")))))) (sort-by-id (group-file 'id "scheme-id.scm"))))))
(define (operating-system) (define (operating-system)
`((h2 "Operating systems") (registry
,(tabulate "Operating systems"
'("ID" "Description") "operating-system"
(map the-usual (sort-by-id (group-file 'id "operating-system.scm")))))) '(p)
(tabulate
'("ID" "Description")
(map the-usual (sort-by-id (group-file 'id "operating-system.scm"))))))
(define (machine) (define (machine)
`((h2 "Machines") (registry
,(tabulate "Machines"
'("ID" "Description") "machine"
(map the-usual (sort-by-id (group-file 'id "machine.scm")))))) '(p)
(tabulate
'("ID" "Description")
(map the-usual (sort-by-id (group-file 'id "machine.scm"))))))
(define (splice-implementations) (define (splice-implementations)
(classify "red" (group-file 'id "scheme-id.scm"))) (classify "red" (group-file 'id "scheme-id.scm")))
@ -116,45 +143,60 @@
(classify "blue" (group-file 'id "machine.scm"))) (classify "blue" (group-file 'id "machine.scm")))
(define (feature) (define (feature)
`((h2 "Feature identifiers") (registry
,(tabulate "Feature identifiers"
'("ID" "Description") "features"
(map the-usual (sort-by-id (append (group-file 'id "features.scm") '(p)
(splice-implementations) (tabulate
(splice-operating-systems) '("ID" "Description")
(splice-machines))))))) (map the-usual (sort-by-id (append (group-file 'id "features.scm")
(splice-implementations)
(splice-operating-systems)
(splice-machines)))))))
(define (library-name) (define (library-name)
`((h2 "Library name prefixes") (registry
,(tabulate "Library name prefixes"
'("ID" "Description") "library-name"
(map the-usual (sort-by-id '(p)
(append (group-file 'id "library-name.scm") (tabulate
(splice-implementations))))))) '("ID" "Description")
(map the-usual (sort-by-id
(append (group-file 'id "library-name.scm")
(splice-implementations)))))))
(define (reader-directive) (define (reader-directive)
`((h2 "Reader directives") (registry
,(tabulate "Reader directives"
'("ID" "Description" "Prefixes") "reader-directive"
(map (lambda (entry) '(p)
(append (the-usual entry) (tabulate
(list `(code ,(assoc1 'prefixes entry))))) '("ID" "Description" "Prefixes")
(sort-by-id (group-file 'id "reader-directive.scm")))))) (map (lambda (entry)
(append (the-usual entry)
(list `(code ,(assoc1 'prefixes entry)))))
(sort-by-id (group-file 'id "reader-directive.scm"))))))
(define (foreign-status-set) (define (foreign-status-set)
`((h2 "Foreign status sets") (registry
,(tabulate "Foreign status sets"
'("ID" "Description") "foreign-status-set"
(map the-usual '(p)
(sort-by-id (group-file 'id "foreign-status-set.scm")))))) (tabulate
'("ID" "Description")
(map the-usual
(sort-by-id (group-file 'id "foreign-status-set.scm"))))))
(define (foreign-status-property) (define (foreign-status-property)
`((h2 "Foreign status properties") (registry
,(tabulate "Foreign status properties"
'("ID" "Description" "Type") "foreign-status-property"
(map (lambda (entry) '(p)
(append (the-usual entry) (list (assoc1 'type entry)))) (tabulate
(group-file 'id "foreign-status-property.scm"))))) '("ID" "Description" "Type")
(map (lambda (entry)
(append (the-usual entry) (list (assoc1 'type entry))))
(group-file 'id "foreign-status-property.scm")))))
(define (display-page) (define (display-page)
(display "<!doctype html>") (display "<!doctype html>")
@ -177,13 +219,13 @@
(body (body
(h1 "Scheme Registry") (h1 "Scheme Registry")
(p "The Scheme registry collects identifiers.") (p "The Scheme registry collects identifiers.")
,@(scheme-id) ,(scheme-id)
,@(operating-system) ,(operating-system)
,@(machine) ,(machine)
,@(feature) ,(feature)
,@(library-name) ,(library-name)
,@(reader-directive) ,(reader-directive)
,@(foreign-status-set) ,(foreign-status-set)
,@(foreign-status-property))))) ,(foreign-status-property)))))
(with-output-to-file "index.html" display-page) (with-output-to-file "index.html" display-page)