From 12472f7fe52848a011cc218e36b01416cfa6c146 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Fri, 26 Apr 2013 10:04:47 -0700 Subject: [PATCH 11/11] ox-html.el: Export to various flavors of (X)HTML lisp/ox-html.el (org-html-doctype-alist): New variable holding an alist of (X)HTML doctypes (org-html-xhtml-p): New function (org-html-html5-p): New function (org-html-close-tag): New function Significant changes to `org-html-format-inline-image', `org-html--build-meta-info', `org-html--build-head', `org-html--build-pre/postable', `org-html-template', `org-html-horizontal-rule', `org-html-format-list-item', `org-html-line-break', `org-html-table', and `org-html-verse-block'. doc/org.texi: Document the above --- doc/org.texi | 43 ++++++++++++- lisp/ox-html.el | 188 +++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 166 insertions(+), 65 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 3f2d1b8..0815c49 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -596,6 +596,7 @@ Exporting HTML export * HTML Export commands:: How to invoke HTML export +* HTML doctypes:: Org can export to various (X)HTML flavors * HTML preamble and postamble:: How to insert a preamble and a postamble * Quoting HTML tags:: Using direct HTML in Org mode * Links in HTML export:: How links will be interpreted and formatted @@ -10959,6 +10960,7 @@ language, but with additional support for tables. @menu * HTML Export commands:: How to invoke HTML export +* HTML doctypes:: Org can export to various (X)HTML flavors * HTML preamble and postamble:: How to insert a preamble and a postamble * Quoting HTML tags:: Using direct HTML in Org mode * Links in HTML export:: How links will be interpreted and formatted @@ -10970,7 +10972,7 @@ language, but with additional support for tables. * JavaScript support:: Info and Folding in a web browser @end menu -@node HTML Export commands, HTML preamble and postamble, HTML export, HTML export +@node HTML Export commands, HTML doctypes, HTML export, HTML export @subsection HTML export commands @table @kbd @@ -10998,7 +11000,44 @@ Export to a temporary buffer. Do not create a file. @c @noindent @c creates two levels of headings and does the rest as items. -@node HTML preamble and postamble, Quoting HTML tags, HTML Export commands, HTML export +@node HTML doctypes, HTML preamble and postamble, HTML Export commands, HTML export +@subsection HTML doctypes +@vindex org-html-doctype +@vindex org-html-doctype-alist + +Org can export to various (X)HTML flavors. + +Setting the variable @var{org-html-doctype} allows you to export to different +(X)HTML variants. The exported HTML will be adjusted according to the sytax +requirements of that variant. You can either set this variable to a doctype +string directly, in which case the exporter will try to adjust the syntax +automatically, or you can use a ready-made doctype. The ready-made options +are: + +@itemize +@item +``html4-strict'' +@item +``html4-transitional'' +@item +``html4-frameset'' +@item +``xhtml-strict'' +@item +``xhtml-transitional'' +@item +``xhtml-frameset'' +@item +``xhtml-11'' +@item +``html5'' +@item +``xhtml5'' +@end itemize + +See the variable @var{org-html-doctype-alist} for details. The default is ``xhtml-strict''. + +@node HTML preamble and postamble, Quoting HTML tags, HTML doctypes, HTML export @subsection HTML preamble and postamble @vindex org-html-preamble @vindex org-html-postamble diff --git a/lisp/ox-html.el b/lisp/ox-html.el index ef7d15a..8223a18 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -143,6 +143,27 @@ (defvar org-html--pre/postamble-class "status" "CSS class used for pre/postamble") +(defconst org-html-doctype-alist + '(("html4-strict" . "") + ("html4-transitional" . "") + ("html4-frameset" . "") + + ("xhtml-strict" . "") + ("xhtml-transitional" . "") + ("xhtml-framset" . "") + ("xhtml-11" . "") + + ("html5" . "") + ("xhtml5" . "")) + "An alist mapping (x)html flavors to specific doctypes.") + (defconst org-html-special-string-regexps '(("\\\\-" . "­") ; shy ("---\\([^-]\\)" . "—\\1") ; mdash @@ -748,7 +769,9 @@ in all modes you want. Then, use the command '(:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") "Default attributes and values which will be used in table tags. This is a plist where attributes are symbols, starting with -colons, and values are strings." +colons, and values are strings. + +When exporting to HTML5, these values will be disregarded." :group 'org-export-html :version "24.4" :package-version '(Org . "8.0") @@ -856,7 +879,9 @@ CSS classes, then this prefix can be very useful." "The extension for exported HTML files. %s will be replaced with the charset of the exported file. This may be a string, or an alist with export extensions -and corresponding declarations." +and corresponding declarations. + +This declaration only applies when exporting to XHTML." :group 'org-export-html :type '(choice (string :tag "Single declaration") @@ -872,8 +897,7 @@ Use utf-8 as the default value." :package-version '(Org . "8.0") :type 'coding-system) -(defcustom org-html-doctype - "" +(defcustom org-html-doctype "xhtml-strict" "Document type definition to use for exported HTML files. Can be set with the in-buffer HTML_DOCTYPE property or for publishing, with :html-doctype." @@ -962,7 +986,8 @@ You can also customize this for each buffer, using something like (const :format " " mathml) (boolean)))) (defcustom org-html-mathjax-template - " +