Skip to content

Instantly share code, notes, and snippets.

@ignacy
Created August 10, 2012 10:26
Show Gist options
  • Select an option

  • Save ignacy/3313246 to your computer and use it in GitHub Desktop.

Select an option

Save ignacy/3313246 to your computer and use it in GitHub Desktop.
(defun html (x)
"Return valid HTML code constructed from passed list"
(if (not (listp x))
x
(let ((tag (car x))
(body (cdr x)))
(if (and (listp (car body)) (string= "attributes" (first (car body))))
(concat "<" tag " " (car (cdr (car body))) ">"
(apply 'concat (mapcar 'html (cdr body)))
"</" tag ">")
(concat "<" tag ">"
(apply 'concat (mapcar 'html body))
"</" tag ">")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment