From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: [PATCH] export to various flavors of (X)HTML Date: Fri, 26 Apr 2013 10:14:17 -0700 Message-ID: <87li85tdsm.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> <871u9ytihc.fsf@ericabrahamsen.net> <8f433f7c2e7d4892d6286afc9524d9a6@mail.rickster.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:60077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVm8C-0003WS-Gx for emacs-orgmode@gnu.org; Fri, 26 Apr 2013 13:08:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVm84-0003X5-FF for emacs-orgmode@gnu.org; Fri, 26 Apr 2013 13:08:20 -0400 Received: from plane.gmane.org ([80.91.229.3]:56997) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVm84-0003Ws-02 for emacs-orgmode@gnu.org; Fri, 26 Apr 2013 13:08:12 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UVm7z-0004zF-9i for emacs-orgmode@gnu.org; Fri, 26 Apr 2013 19:08:07 +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 ; Fri, 26 Apr 2013 19:08:07 +0200 Received: from eric by 63.226.249.211 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 26 Apr 2013 19:08:07 +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 Rick Frankel writes: > On 25.04.2013 17:20, Eric Abrahamsen wrote: >> 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. > > Overall, looks good, but again, i would _strongly_ argue that html5 > should generate valid xhtml. > If it doesn't, it will really break my post-processing workflow... > > Therefore, `org-html-close-tag' should check that the doctype is not a > flavor of html4 rather than a flavor of xhtml. An alternative would be > to add ("xhtml5" . "") to the doctype alist, and the > appropriate testing for being html5 and xhtml. > > See the discussions of polyglot markup @ > http://en.wikipedia.org/wiki/Polyglot_markup > and > http://www.w3.org/TR/2011/WD-html-polyglot-20110405/#dfn-polyglot-markup > for the rationale. Ah, those were interesting links, I hadn't considered those issues. Luckily, your second option was a three-line change to the existing patch: using "xhtml5" now produces the same output as "html5", except that self-closing tags are self-closed, and there's a xmlns declaration in the element. Best of all worlds, I hope. E --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0011-ox-html.el-Export-to-various-flavors-of-X-HTML.patch >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 - " +