From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: [PATCH] export to various flavors of (X)HTML Date: Sun, 28 Apr 2013 23:02:22 -0700 Message-ID: <87bo8xeuxd.fsf@ericabrahamsen.net> References: <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> <87li85tdsm.fsf@ericabrahamsen.net> <20130426184949.GB79236@BigDog.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:43974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWh4T-00043W-E0 for emacs-orgmode@gnu.org; Mon, 29 Apr 2013 01:56:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWh4R-0006rk-CG for emacs-orgmode@gnu.org; Mon, 29 Apr 2013 01:56:17 -0400 Received: from plane.gmane.org ([80.91.229.3]:56750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWh4Q-0006rY-Tp for emacs-orgmode@gnu.org; Mon, 29 Apr 2013 01:56:15 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UWh4O-0005F1-IJ for emacs-orgmode@gnu.org; Mon, 29 Apr 2013 07:56:12 +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 ; Mon, 29 Apr 2013 07:56:12 +0200 Received: from eric by 63.226.249.211 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 29 Apr 2013 07:56:12 +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 Fri, Apr 26, 2013 at 10:14:17AM -0700, Eric Abrahamsen wrote: >> Rick Frankel writes: >> > >> > 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. > > Brilliant! I will apply the patch and try it later this weekend... So here's the fun part -- using the new bits of HTML5. The attached patch builds on the last one (and corrects a couple of documentation formatting errors), and touches on the following: 1. There's a new export option, org-html-html5-fancy/HTML_HTML5_FANCY, which defaults to 'nil, making most of the following opt-in only. 2. The meat of the change is in `org-html-special-block'. If it comes across a special block #+BEGIN_FOO where "foo" is a member of `org-html-html5-elements', it will format it as "" rather than "
". So #+BEGIN_ASIDE will create an "
") id (format "\n

%s

" img) (if (and caption (not (string= caption ""))) - (format "\n

%s

" caption) "")))) + (format (if html5-fancy + "\n
%s
" + "\n

%s

") caption) "")))) (t (org-html-close-tag "img" (concat attr id) info))))) (defun org-html--textarea-block (element) @@ -2927,9 +2960,25 @@ contextual information." "Transcode a SPECIAL-BLOCK element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (format "
\n%s\n
" - (downcase (org-element-property :type special-block)) - contents)) + (let* ((block-type (downcase + (org-element-property :type special-block))) + (contents (or contents "")) + (html5-fancy (and (org-html-html5-p info) + (plist-get info :html-html5-fancy) + (member block-type org-html-html5-elements))) + (attributes (org-export-read-attribute :attr_html special-block))) + (unless html5-fancy + (let ((class (plist-get attributes :class))) + (setq attributes (plist-put attributes :class + (if class (concat class " " block-type) + block-type))))) + (setq attributes (org-html--make-attribute-string attributes)) + (when (not (equal attributes "")) + (setq attributes (concat " " attributes))) + (if html5-fancy + (format "<%s%s>\n%s" block-type attributes + contents block-type) + (format "\n%s\n" attributes contents)))) ;;;; Src Block -- 1.8.2.2 --=-=-= Content-Type: text/plain [1]: https://code.google.com/p/html5shiv/ --=-=-=--