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, 02 May 2013 14:07:38 -0700 Message-ID: <87k3nhqeed.fsf@ericabrahamsen.net> References: <86wqrtwisf.fsf@iro.umontreal.ca> <517732AF.6080308@gmail.com> <86y5c82hxy.fsf@iro.umontreal.ca> <871u9ytihc.fsf@ericabrahamsen.net> <8f433f7c2e7d4892d6286afc9524d9a6@mail.rickster.com> <87li85tdsm.fsf@ericabrahamsen.net> <20130426184949.GB79236@BigDog.local> <87bo8xeuxd.fsf@ericabrahamsen.net> <87zjwfnzwj.fsf@ericabrahamsen.net> <20130501115503.GB83182@BigDog.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:47381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UY0ge-00058n-43 for emacs-orgmode@gnu.org; Thu, 02 May 2013 17:05:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UY0ga-0001PM-Uw for emacs-orgmode@gnu.org; Thu, 02 May 2013 17:05:08 -0400 Received: from plane.gmane.org ([80.91.229.3]:56692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UY0ga-0001Mc-98 for emacs-orgmode@gnu.org; Thu, 02 May 2013 17:05:04 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UY0gZ-0000Ya-Ek for emacs-orgmode@gnu.org; Thu, 02 May 2013 23:05:03 +0200 Received: from c-76-28-195-250.hsd1.wa.comcast.net ([76.28.195.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 May 2013 23:05:03 +0200 Received: from eric by c-76-28-195-250.hsd1.wa.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 May 2013 23:05:03 +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 Tue, Apr 30, 2013 at 08:26:52PM -0700, Eric Abrahamsen wrote: >> Rick Frankel writes: >> >> > Whoops. Wrong key. Patch actually attached to this email... >> > rick >> >> Great, I'll consolidate all these -- would it be better to mush them >> into one big patch, or to keep them separate (I suppose for ease of >> rollback, if something goes wrong)? > > Probably squashing them into one patch would be the best. But Carsten > or Bastien might disagree :). > > rick Okay, there it is: one big patch (including your xml declaration fix). I didn't add any more refined handling of the html5-fancy option. As a second-order option it didn't seem worthy of an #+OPTIONS entry, and I didn't bother checking for an empty string, either. It can always be #+BINDed if necessary, and if it ever annoys anyone I can fix it further. E --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ox-html.el-Export-to-different-X-HTML-flavors-includ.patch >From 9224f289801c7f1193718fe7f2ca351e26d7534b Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Thu, 2 May 2013 13:40:58 -0700 Subject: [PATCH] ox-html.el Export to different (X)HTML flavors, including HTML5 * 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 (org-html-html5-fancy): New export option, determining whether or not to use HTML5-specific elements. (org-html-html5-elements): New variable, new HTML5 elements. (org-html-special-block): Export special blocks to new HTML5 elements. (org-html-format-inline-image): Use
and
for standalone images. 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 | 97 +++++++++++++++++++++- lisp/ox-html.el | 251 ++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 277 insertions(+), 71 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 7437451..c294ea6 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 @@ -10969,6 +10970,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 @@ -10980,7 +10982,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 @@ -11008,7 +11010,98 @@ 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 @code{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 @code{org-html-doctype-alist} for details. The default is +``xhtml-strict''. + +@subsubheading Fancy HTML5 export +@vindex org-html-html5-fancy +@vindex org-html-html5-elements + +HTML5 introduces several new element types. By default, Org will not make +use of these element types, but you can set @code{org-html-html5-fancy} to +@code{t} (or use the corresponding @code{HTML_HTML5_FANCY} export option), to +enable a few new block-level elements. These are created using arbitrary +#+BEGIN and #+END blocks. For instance: + +@example +#+BEGIN_ASIDE +Lorem ipsum +#+END_ASIDE +@end example + +Will export to: + +@example + +@end example + +While this: + +@example +#+ATTR_HTML: :controls controls :width 350 +#+BEGIN_VIDEO +#+HTML: +#+HTML: +Your browser does not support the video tag. +#+END_VIDEO +@end example + +Becomes: + +@example + +@end example + +Special blocks that do not correspond to HTML5 elements (see +@code{org-html-html5-elements}) will revert to the usual behavior, +i.e. #+BEGIN_LEDERHOSEN will still export to
. + +Headlines cannot appear within special blocks. To wrap a headline and its +contents in e.g.
or
tags, set the @code{HTML_CONTAINER} +property on the headline itself. + +@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..05b99bf 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -116,6 +116,7 @@ (:html-link-org-as-html nil nil org-html-link-org-files-as-html) (:html-doctype "HTML_DOCTYPE" nil org-html-doctype) (:html-container "HTML_CONTAINER" nil org-html-container-element) + (:html-html5-fancy "HTML_HTML5_FANCY" nil org-html-html5-fancy) (:html-link-home "HTML_LINK_HOME" nil org-html-link-home) (:html-link-up "HTML_LINK_UP" nil org-html-link-up) (:html-mathjax "HTML_MATHJAX" nil "" space) @@ -143,6 +144,38 @@ (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-html5-elements + '("article" "aside" "audio" "canvas" "details" "figcaption" + "figure" "footer" "header" "menu" "meter" "nav" "output" + "progress" "section" "video") + "New elements in html5. + +
is not included because it's currently impossible to +wrap special blocks around multiple headlines. For other blocks +that should contain headlines, use the HTML_CONTAINER property on +the headline itself.") + (defconst org-html-special-string-regexps '(("\\\\-" . "­") ; shy ("---\\([^-]\\)" . "—\\1") ; mdash @@ -748,7 +781,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 +891,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 +909,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." @@ -882,6 +918,21 @@ publishing, with :html-doctype." :package-version '(Org . "8.0") :type 'string) +(defcustom org-html-html5-fancy nil + "When exporting to HTML5, set this to t to use new HTML5 + elements. This variable is ignored for anything other than + HTML5. + +For compatibility with Internet Explorer, it's probably a good +idea to download some form of the html5shiv (for instance +https://code.google.com/p/html5shiv/) and add it to your +HTML_HEAD_EXTRA, so that your pages don't break for users of IE +versions 8 and below." + :group 'org-export-html + :version "24.4" + :package-version '(Org . "8.0") + :type 'boolean) + (defcustom org-html-container-element "div" "HTML element to use for wrapping top level sections. Can be set with the in-buffer HTML_CONTAINER property or for @@ -962,7 +1013,8 @@ You can also customize this for each buffer, using something like (const :format " " mathml) (boolean)))) (defcustom org-html-mathjax-template - " +