From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: [PATCH] export to various flavors of (X)HTML Date: Thu, 25 Apr 2013 14:20:47 -0700 Message-ID: <871u9ytihc.fsf@ericabrahamsen.net> References: <878v4elu5h.fsf@ericabrahamsen.net> <87y5cdkiuj.fsf@ericabrahamsen.net> <20130423010019.GA65517@BigDog.local> <87sj2h3m3s.fsf@ericabrahamsen.net> <86wqrtwisf.fsf@iro.umontreal.ca> <517732AF.6080308@gmail.com> <86y5c82hxy.fsf@iro.umontreal.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVTV6-0006hN-5Z for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 17:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVTV3-0001VE-IW for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 17:14:44 -0400 Received: from plane.gmane.org ([80.91.229.3]:33082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVTV3-0001Uy-2O for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 17:14:41 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UVTUx-0005Y5-HV for emacs-orgmode@gnu.org; Thu, 25 Apr 2013 23:14:35 +0200 Received: from 63.226.249.211 ([63.226.249.211]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Apr 2013 23:14:35 +0200 Received: from eric by 63.226.249.211 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Apr 2013 23:14:35 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit François Pinard writes: > Christian Wittern writes: > >> On 2013-04-23 21:09, François Pinard wrote: > >>> If I remember well [...] > >> Well, in this case you are misremembering, empty elements, aka as >> self-closing tags are one of the innovations of XML. Just my nit to pick, > > A friendly nit-picking is always a good way to get one another to > improve. Thanks! Who knew this would turn out to be such a fraught issue! All I wanted was that little green checkmark from the W3C... Here's what I think should be an acceptable final patch. I dropped the CDATA mess, and came up with a slightly different implementation for handling self-closing tags. It's maybe a little /bulkier/ than the previous implementation, but not so hacky, and may continue to be useful in the future. There's also a documentation patch. Hope this works, E --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0011-ox-html.el-Export-to-various-flavors-of-X-HTML.patch >From d3af8f41480eea27e0165e4dcd594ce3475e56cd Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Thu, 25 Apr 2013 14:00:24 -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 | 41 ++++++++++++- lisp/ox-html.el | 187 +++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 163 insertions(+), 65 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 3f2d1b8..c7fae6d 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,42 @@ 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'' +@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..eddc122 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -143,6 +143,26 @@ (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" . "")) + "An alist mapping (x)html flavors to specific doctypes.") + (defconst org-html-special-string-regexps '(("\\\\-" . "­") ; shy ("---\\([^-]\\)" . "—\\1") ; mdash @@ -748,7 +768,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 +878,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 +896,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 +985,8 @@ You can also customize this for each buffer, using something like (const :format " " mathml) (boolean)))) (defcustom org-html-mathjax-template - " +