emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] export to various flavors of (X)HTML


From: Eric Abrahamsen
Subject: Re: [O] [PATCH] export to various flavors of (X)HTML
Date: Sun, 28 Apr 2013 23:02:22 -0700
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3 (gnu/linux)

Rick Frankel <address@hidden> writes:

> On Fri, Apr 26, 2013 at 10:14:17AM -0700, Eric Abrahamsen wrote:
>> Rick Frankel <address@hidden> 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" . "<!DOCTYPE html>") 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 <html> 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 "<foo>" rather than
"<div class="foo">". So #+BEGIN_ASIDE will create an "<aside>" element.

Attributes are now parsed (this change applies to all HTML flavors), so
this:

#+ATTR_HTML :controls controls :width 350
#+BEGIN_VIDEO
#+HTML: <source src="movie.mp4" type="video/mp4">
#+END_VIDEO

becomes:

<video controls="controls" width="350">
  <source src="movie.mp4" type="video/mp4">
</video>

3. Standalone images are formatted as <figure> with <figcaption>.

4. Things like timestamps could be expressed as <time> elements, but I
haven't done that here. The relevant attributes still seem to be up in
the air, and it would be complicated.

5. It's generally accepted that one should use some variety of the
html5shiv[1] to make IE <9 render new HTML5 elements correctly. I've
dropped a note to this effect in the docstring of
`org-html-html5-fancy', but I suppose it's possible we could take a more
interventionist stance, perhaps including hosting a version of the shiv
on orgmode.org, and linking to it automatically. I guess I'm in favor of
leaving it to the user, though.

Tangential coding question: I've noticed that setting HTML_HTML5_FANCY
to nil at the top of the export file results in `(plist-get info
:html-html5-fancy)' returning the string "nil", ie true. Not right,
obviously, and it makes it impossible to set it to 'nil per-file if the
global value is 't. Am I handling this wrong?


E

Attachment: 0010-ox-html.el-Give-access-to-new-elements-in-HTML5.patch
Description: Text Data



[1]: https://code.google.com/p/html5shiv/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]