Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for XHTML5 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adding support for XHTML5
- Allow a distinction between the XML/HTML style tags and the doctype
- Implement the methods necessary for XHTML5.
  • Loading branch information
fiddlerwoaroof committed Sep 10, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0b4beb6156af2a7d3901a04fa4c644081e82bb84
12 changes: 11 additions & 1 deletion src/markup.lisp
Original file line number Diff line number Diff line change
@@ -83,13 +83,19 @@
(:xml "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
(:html "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">")
(:html5 "<!DOCTYPE html>")
(:xhtml5 "<!DOCTYPE html>")
(:xhtml "<?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\">")
(t "")))

(defun lang-for-doctype (lang)
(case lang
(:xhtml5 :xml)
(t lang)))

(defmacro with-doctype (lang &body body)
`(prog2
(eval-when (:compile-toplevel :load-toplevel :execute)
(setq *markup-language* ,lang))
(setq *markup-language* ,(lang-for-doctype lang)))
(%write-strings
,(doctype lang)
,@(let ((*markup-language* lang))
@@ -106,6 +112,10 @@
(defun markup* (&rest tags)
(eval `(markup ,@tags)))

(defmacro xhtml5 (&rest tags)
`(with-doctype :xhtml5
(tag->string (append '(:html :xmlns "http://www.w3.org/1999/xhtml") ',tags))))

(defmacro html5 (&rest tags)
`(with-doctype :html5
(tag->string (cons :html ',tags))))
2 changes: 1 addition & 1 deletion src/package.lisp
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
(defpackage cl-markup
(:nicknames :markup)
(:use :cl)
(:export :markup :html :html5 :xhtml :xml
(:export :markup :html :html5 :xhtml :xml :xhtml5
:markup*
:doctype
:escape-string :raw :esc