all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Attributes on HTML tables?
@ 2013-04-07  2:55 François Pinard
  2013-04-07  6:27 ` Bastien
  0 siblings, 1 reply; 27+ messages in thread
From: François Pinard @ 2013-04-07  2:55 UTC (permalink / raw)
  To: emacs-orgmode

Hi, Org people.

I took a few hours today to move the Org generation for a few of my Web
pages to the new exporter, and after a bit of debugging to understand
how some changes were meant, got the impression that it mainly works!
I'll have to wander around when I'll find some more free time, looking
at the generated pages, to check that everything is OK.

There is one little thing that does not seem to work, but I do not
remember if it worked with the old exporter.  The Org manual says:

   12.5.5 Tables
   -------------
   
   Org mode tables are exported to HTML using the table tag defined in
   `org-html-table-tag'.  The default setting makes tables without cell
   borders and frame.  If you would like to change this for individual
   tables, place something like the following before the table:
   
        #+CAPTION: This is a table with lines around and between cells
        #+ATTR_HTML: border="2" rules="all" frame="border"

Captions work indeed, but I do not see that attributes are transported
on the generated <table ...> element.  It seems to be always produced
with the exact value of org-html-table-tag.

François

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-07  2:55 Attributes on HTML tables? François Pinard
@ 2013-04-07  6:27 ` Bastien
  2013-04-07 14:42   ` Christian Moe
  0 siblings, 1 reply; 27+ messages in thread
From: Bastien @ 2013-04-07  6:27 UTC (permalink / raw)
  To: François Pinard; +Cc: emacs-orgmode

Hi François,

François Pinard <pinard@iro.umontreal.ca> writes:

>         #+CAPTION: This is a table with lines around and between cells
>         #+ATTR_HTML: border="2" rules="all" frame="border"

You need to use :options now:

  #+CAPTION: This is a table with lines around and between cells
  #+ATTR_HTML: :options border="2" rules="all" frame="border"

We are in the process of documenting this.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-07  6:27 ` Bastien
@ 2013-04-07 14:42   ` Christian Moe
  2013-04-07 18:46     ` Nicolas Goaziou
  0 siblings, 1 reply; 27+ messages in thread
From: Christian Moe @ 2013-04-07 14:42 UTC (permalink / raw)
  To: Bastien; +Cc: François Pinard, emacs-orgmode


Bastien writes:
> You need to use :options now:
>
>   #+CAPTION: This is a table with lines around and between cells
>   #+ATTR_HTML: :options border="2" rules="all" frame="border"

Oddly, this doesn't work for me at the moment. I'm running
release_8.0-pre-344-g882454, pulled this morning. (It /could/ be just
me; I seem to have some unresolved installation issues.)

When I export, both the defaults /and/ the "options" are applied,
resulting in duplicated attributes, like this:

  <table border="2" cellspacing="0" cellpadding="6" rules="groups"
  frame="hsides" border="2" rules="all" frame="border">

and on Firefox, at least, the values defined the second time are
ignored.

The documentation currently up on Worg
(http://orgmode.org/worg/org-8.0.html#sec-8-3), which seems to say we
should now use plists for HTML attributes. But that currently doesn't
work for me either.

Sorry if you've heard this before, but this doesn't make sense to me as
a new syntax:

  #+ATTR_HTML: :options attribute="value"

It's not just more verbose than the old way, it's redundant to say both
"attr" and "options", since all it does is set attributes. 

Yours,
Christian

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-07 14:42   ` Christian Moe
@ 2013-04-07 18:46     ` Nicolas Goaziou
  2013-04-07 20:39       ` Christian Moe
  0 siblings, 1 reply; 27+ messages in thread
From: Nicolas Goaziou @ 2013-04-07 18:46 UTC (permalink / raw)
  To: Christian Moe; +Cc: Bastien, François Pinard, emacs-orgmode

Hello,

Christian Moe <mail@christianmoe.com> writes:

> Bastien writes:
>> You need to use :options now:
>>
>>   #+CAPTION: This is a table with lines around and between cells
>>   #+ATTR_HTML: :options border="2" rules="all" frame="border"
>
> Oddly, this doesn't work for me at the moment. I'm running
> release_8.0-pre-344-g882454, pulled this morning. (It /could/ be just
> me; I seem to have some unresolved installation issues.)
>
> When I export, both the defaults /and/ the "options" are applied,
> resulting in duplicated attributes, like this:
>
>   <table border="2" cellspacing="0" cellpadding="6" rules="groups"
>   frame="hsides" border="2" rules="all" frame="border">

This is a bug.

> The documentation currently up on Worg
> (http://orgmode.org/worg/org-8.0.html#sec-8-3), which seems to say we
> should now use plists for HTML attributes. But that currently doesn't
> work for me either.
>
> Sorry if you've heard this before, but this doesn't make sense to me as
> a new syntax:
>
>   #+ATTR_HTML: :options attribute="value"
>
> It's not just more verbose than the old way, it's redundant to say both
> "attr" and "options", since all it does is set attributes.

Actually, that's not the spirit. The idea is to define some widely used
attributes that will be written directly like:

  #+attr_html: :border 0 :width 400

Then, :options attribute is used as a bucket for every other attribute,
since we cannot support all of them.

Unfortunately, no attribute is current recognized in table HTML
transcoder. It needs to be improved.

If Someone provides a list of such attributes, I can implement it.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-07 18:46     ` Nicolas Goaziou
@ 2013-04-07 20:39       ` Christian Moe
  2013-04-07 20:48         ` Nicolas Goaziou
  0 siblings, 1 reply; 27+ messages in thread
From: Christian Moe @ 2013-04-07 20:39 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bastien, François Pinard, emacs-orgmode


Nicolas Goaziou writes:
>> When I export, both the defaults /and/ the "options" are applied,
>> resulting in duplicated attributes, like this:
>>
>>   <table border="2" cellspacing="0" cellpadding="6" rules="groups"
>>   frame="hsides" border="2" rules="all" frame="border">
>
> This is a bug.

Ah, good (from my perspective, anyway, I was getting concerned about
my setup).

> The idea is to define some widely used
> attributes that will be written directly like:
>
>   #+attr_html: :border 0 :width 400
>
> Then, :options attribute is used as a bucket for every other attribute,
> since we cannot support all of them.

I'm sorry, you've probably explained this many times before and I should
go read the archives. 

But what is it that nees to be supported, and why couldn't you just pass
through *whatever* :attribute value pair the user puts in attr_html? I
really like the switch to plist style, but I think the combination with
:options and literal syntax is confusing.

> Unfortunately, no attribute is current recognized in table HTML
> transcoder. It needs to be improved.
>
> If Someone provides a list of such attributes, I can implement it.

I'd be happy to, but I need to understand the above. On what basis
should attributes be selected for either plist style or the :options
bucket, and what does the exporter need to know about them in order to
support them?

Yours,
Christian

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-07 20:39       ` Christian Moe
@ 2013-04-07 20:48         ` Nicolas Goaziou
  2013-04-08 21:09           ` Christian Moe
  0 siblings, 1 reply; 27+ messages in thread
From: Nicolas Goaziou @ 2013-04-07 20:48 UTC (permalink / raw)
  To: Christian Moe; +Cc: Bastien, François Pinard, emacs-orgmode

Christian Moe <mail@christianmoe.com> writes:

> But what is it that nees to be supported, and why couldn't you just pass
> through *whatever* :attribute value pair the user puts in attr_html?

Does every possible attribute follow attribute="value" pattern? Aren't
there single keywords? If they are that regular, we can indeed walk the
plist like a list and change

  (:key1 val1 :key2 val2 ...)

into

  key1="val1" key2="val2"

If there are irregular keywords, the export back-end needs to know about
them.

Also, if attributes are provided, I assume defaults should be ignored
altogether. Or do we need to create the union between default values and
provided attributes?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-07 20:48         ` Nicolas Goaziou
@ 2013-04-08 21:09           ` Christian Moe
  2013-04-10 17:44             ` François Pinard
  2013-04-10 19:37             ` Nicolas Goaziou
  0 siblings, 2 replies; 27+ messages in thread
From: Christian Moe @ 2013-04-08 21:09 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bastien, emacs-orgmode


Nicolas Goaziou writes:
> Does every possible attribute follow attribute="value" pattern? Aren't
> there single keywords? 

In XHTML it does, and there aren't. In HTML you can use some "minimized"
attributes, but in XHTML they have their own names as values,
e.g. nowrap="nowrap".

> If they are that regular, we can indeed walk the
> plist like a list and change
>
>   (:key1 val1 :key2 val2 ...)
>
> into
>
>   key1="val1" key2="val2"

...and let the user worry about getting them right. That's my
suggestion, FWIW.

> If there are irregular keywords, the export back-end needs to know about
> them.

XML doesn't do `irregular'. :)

XHTML is also fussy about quoting attribute values, and about escaping
special characters as HTML entities, including the ampersand (&), and
including inside attribute values. I'm guessing the exporter already
does the right thing here.

Since values may legitimately contain double quotes, one thing the
back-end *does* need to know about is to put those in single quotes:

 :title This is a "pop-up" text

  title='This is a "pop-up" text'

> Also, if attributes are provided, I assume defaults should be ignored
> altogether. Or do we need to create the union between default values and
> provided attributes?

If I understand the question correctly, I think the union is the correct
answer, with provided attributes overwriting defaults for the same
attributes.

In the example we started with, the defaults would create

  <table border="2" cellspacing="0" cellpadding="6" rules="groups"
  frame="hsides">

If the user specifies

  #+attr_html: :border 2 :rules all :frame border :title My table

I would expect the result

  <table border="2" cellspacing="0" cellpadding="6" rules="all"
  frame="border" title="My table">

You may want a second opinion on all this -- I'm no (X)HTML guru and
I've never written an exporter. But it seems to me the pure plist form
would less confusing to the user than a split syntax, and easier to
maintain, as well.

Yours,
Christian

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-08 21:09           ` Christian Moe
@ 2013-04-10 17:44             ` François Pinard
  2013-04-12  2:06               ` Eric Abrahamsen
  2013-04-10 19:37             ` Nicolas Goaziou
  1 sibling, 1 reply; 27+ messages in thread
From: François Pinard @ 2013-04-10 17:44 UTC (permalink / raw)
  To: emacs-orgmode

Christian Moe <mail@christianmoe.com> writes:

> XHTML is also fussy about quoting attribute values, and about escaping
> special characters as HTML entities, including the ampersand (&), and
> including inside attribute values.  I'm guessing the exporter already
> does the right thing here.

Org can of course take care of XTHML fussiness, there is likely no
problem there.

While on this subject! :-)

Could Org allow the output of HTML5 rather than XHTML, under the control
of some option?  I've read that some frameworks really expect HTML5 to
work properly, such an option might ease inter-operation between
exported Org and such frameworks.

François

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-08 21:09           ` Christian Moe
  2013-04-10 17:44             ` François Pinard
@ 2013-04-10 19:37             ` Nicolas Goaziou
  2013-04-11  8:28               ` Christian Moe
  1 sibling, 1 reply; 27+ messages in thread
From: Nicolas Goaziou @ 2013-04-10 19:37 UTC (permalink / raw)
  To: Christian Moe; +Cc: Bastien, emacs-orgmode

Hello,

Christian Moe <mail@christianmoe.com> writes:

> If I understand the question correctly, I think the union is the correct
> answer, with provided attributes overwriting defaults for the same
> attributes.
>
> In the example we started with, the defaults would create
>
>   <table border="2" cellspacing="0" cellpadding="6" rules="groups"
>   frame="hsides">
>
> If the user specifies
>
>   #+attr_html: :border 2 :rules all :frame border :title My table
>
> I would expect the result
>
>   <table border="2" cellspacing="0" cellpadding="6" rules="all"
>   frame="border" title="My table">

Thank you for all the information.

I have pushed a patch along these lines.

Caveat: `org-html-table-tag' is now named
`org-html-table-default-attributes' and expect a plist as its value.
Also, a nil value will remove the property from the attributes.

Could you test it and confirm this is now behaving in a desirable way?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-10 19:37             ` Nicolas Goaziou
@ 2013-04-11  8:28               ` Christian Moe
  2013-04-11 10:55                 ` Nicolas Goaziou
  0 siblings, 1 reply; 27+ messages in thread
From: Christian Moe @ 2013-04-11  8:28 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bastien, emacs-orgmode


Nicolas Goaziou writes:
> Caveat: `org-html-table-tag' is now named
> `org-html-table-default-attributes' and expect a plist as its value.
> Also, a nil value will remove the property from the attributes.
>
> Could you test it and confirm this is now behaving in a desirable way?

Hi,

I've run some tests and confirm it works as I'd like it to. Thanks, I
really like this and I hope others like the plist syntax as well.

Late thought, sorry: If we can have this plist syntax as a general rule,
perhaps we should nevertheless keep the :options tag just as a fallback,
to ease the transition for users with a lot of legacy attr_html lines?
It's easier and less catastrophe-prone to do a quick search/replace from

: ^#\+attr_html: 

to

: #+attr_html: :options 

than it is to automatically replace verbatim attribute code with plists,
especially if there are all sorts of html irregularities in there.

Yours,
Christian

PS. Though if everything is nice and conforming to xhtml, one should be
able to batch convert files from verbatim html attributes to plist syntax with
something like the following  -- USE AT OWN RISK, NO WARRANTY IMPLIED:

: perl -i.bak -pe 's/([a-z]+)=([\"\'])(.*?)\2/:\1 \2/g if /^#\+attr_html/i' *.org

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-11  8:28               ` Christian Moe
@ 2013-04-11 10:55                 ` Nicolas Goaziou
  2013-04-11 12:14                   ` Christian Moe
  2013-04-11 15:34                   ` Bastien
  0 siblings, 2 replies; 27+ messages in thread
From: Nicolas Goaziou @ 2013-04-11 10:55 UTC (permalink / raw)
  To: Christian Moe; +Cc: Bastien, emacs-orgmode

Hello,

Christian Moe <mail@christianmoe.com> writes:

> Nicolas Goaziou writes:
>> Caveat: `org-html-table-tag' is now named
>> `org-html-table-default-attributes' and expect a plist as its value.
>> Also, a nil value will remove the property from the attributes.
>>
>> Could you test it and confirm this is now behaving in a desirable way?
>
> I've run some tests and confirm it works as I'd like it to. Thanks, I
> really like this and I hope others like the plist syntax as well.

Great. Thank you again.

> Late thought, sorry: If we can have this plist syntax as a general rule,
> perhaps we should nevertheless keep the :options tag just as a fallback,
> to ease the transition for users with a lot of legacy attr_html lines?
> It's easier and less catastrophe-prone to do a quick search/replace from
>
> : ^#\+attr_html: 
>
> to
>
> : #+attr_html: :options 
>
> than it is to automatically replace verbatim attribute code with plists,
> especially if there are all sorts of html irregularities in there.

I prefer not to mix the two methods as it would be fragile (e.g. what
happens if an attribute is defined both outside and inside the :options
keyword?).

> PS. Though if everything is nice and conforming to xhtml, one should be
> able to batch convert files from verbatim html attributes to plist syntax with
> something like the following  -- USE AT OWN RISK, NO WARRANTY IMPLIED:
>
> : perl -i.bak -pe 's/([a-z]+)=([\"\'])(.*?)\2/:\1 \2/g if /^#\+attr_html/i' *.org

 Would you mind adding it to Worg section about the migration to
Org 8.0? It would be quite useful.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-11 10:55                 ` Nicolas Goaziou
@ 2013-04-11 12:14                   ` Christian Moe
  2013-04-11 15:34                   ` Bastien
  1 sibling, 0 replies; 27+ messages in thread
From: Christian Moe @ 2013-04-11 12:14 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bastien, emacs-orgmode


Nicolas Goaziou writes:
> I prefer not to mix the two methods as it would be fragile (e.g. what
> happens if an attribute is defined both outside and inside the :options
> keyword?).

Perhaps not much. As I reported (the reason :options wasn't working), in
Firefox the second definition of the attribute is simply quietly ignored.
But if you prefer to keep it clean, I'm fine with that.

>> to batch convert files from verbatim html attributes to plist syntax with
>> something like the following  -- USE AT OWN RISK, NO WARRANTY IMPLIED:
>>
>> : perl -i.bak -pe 's/([a-z]+)=([\"\'])(.*?)\2/:\1 \2/g if
>> /^#\+attr_html/i' *.org

Oops, in that message I accidentally copy-pasted a WRONG
version. Hopefully didn't work at all, or it would mess things
up. Sorry. This seems to work well:

: perl -i.bak -pe "s/([a-z]+)=(\"|')(.*?)\2/:\1 \3/g if /^#\+attr_html/i" filename.org

>  Would you mind adding it to Worg section about the migration to
> Org 8.0? It would be quite useful.

Will do.

Yours,
Christian

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-11 10:55                 ` Nicolas Goaziou
  2013-04-11 12:14                   ` Christian Moe
@ 2013-04-11 15:34                   ` Bastien
  2013-04-11 17:29                     ` Nicolas Goaziou
  1 sibling, 1 reply; 27+ messages in thread
From: Bastien @ 2013-04-11 15:34 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Christian Moe

Hi,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

>> than it is to automatically replace verbatim attribute code with plists,
>> especially if there are all sorts of html irregularities in there.
>
> I prefer not to mix the two methods as it would be fragile (e.g. what
> happens if an attribute is defined both outside and inside the :options
> keyword?).

Sorry, catching up in this thread -- my understanding was that
:options was *always* available as a fallback, even with other
attributes set before it.  Am I wrong?  If an attribute is both
outside and inside the :options keywords, the outside version
should take over.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-11 15:34                   ` Bastien
@ 2013-04-11 17:29                     ` Nicolas Goaziou
  0 siblings, 0 replies; 27+ messages in thread
From: Nicolas Goaziou @ 2013-04-11 17:29 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Christian Moe

Hello,

Bastien <bzg@gnu.org> writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>>> than it is to automatically replace verbatim attribute code with plists,
>>> especially if there are all sorts of html irregularities in there.
>>
>> I prefer not to mix the two methods as it would be fragile (e.g. what
>> happens if an attribute is defined both outside and inside the :options
>> keyword?).
>
> Sorry, catching up in this thread -- my understanding was that
> :options was *always* available as a fallback, even with other
> attributes set before it.  Am I wrong?

:options is more or less required in LaTeX export. Other keywords may go
in different locations (optional arguments, mandatory arguments) so the
back-end has to understand the keywords provided. It also means there
will always be keywords it won't understand (i.e. which are not
hardcoded). The :options bucket is a good place for them.

On the other hand, I think we don't need it in HTML export. All
attributes go in the same place, so the backend just transforms the
plist into a string. Since it doesn't need to know about what it
transforms, the bucket becomes useless, maybe confusing.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-10 17:44             ` François Pinard
@ 2013-04-12  2:06               ` Eric Abrahamsen
  2013-04-12  5:42                 ` Bastien
  2013-04-13 17:10                 ` Rick Frankel
  0 siblings, 2 replies; 27+ messages in thread
From: Eric Abrahamsen @ 2013-04-12  2:06 UTC (permalink / raw)
  To: emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> writes:

> Christian Moe <mail@christianmoe.com> writes:
>
>> XHTML is also fussy about quoting attribute values, and about escaping
>> special characters as HTML entities, including the ampersand (&), and
>> including inside attribute values.  I'm guessing the exporter already
>> does the right thing here.
>
> Org can of course take care of XTHML fussiness, there is likely no
> problem there.
>
> While on this subject! :-)
>
> Could Org allow the output of HTML5 rather than XHTML, under the control
> of some option?  I've read that some frameworks really expect HTML5 to
> work properly, such an option might ease inter-operation between
> exported Org and such frameworks.

I'm curious about this possibility as well -- how much work would it be?

E

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-12  2:06               ` Eric Abrahamsen
@ 2013-04-12  5:42                 ` Bastien
  2013-04-12  6:01                   ` Eric Abrahamsen
  2013-04-13 17:10                 ` Rick Frankel
  1 sibling, 1 reply; 27+ messages in thread
From: Bastien @ 2013-04-12  5:42 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

Hi Eric,

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> I'm curious about this possibility as well -- how much work would it
> be?

The easiest way to know is to start working on it ;)

Try creating a derived back-end from 'html one and see.

ox-s5.el and ox-deck.el might be useful to read, they are derived
from the 'html back-end already.

HTH,

PS: Maybe some adjustments could be done later do on ox-html.el
so that it's easier to derive new back-ends from it... but we're
not there yet.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-12  5:42                 ` Bastien
@ 2013-04-12  6:01                   ` Eric Abrahamsen
  2013-04-12  8:46                     ` Bastien
  0 siblings, 1 reply; 27+ messages in thread
From: Eric Abrahamsen @ 2013-04-12  6:01 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg@gnu.org> writes:

> Hi Eric,
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> I'm curious about this possibility as well -- how much work would it
>> be?
>
> The easiest way to know is to start working on it ;)

I was afraid that was the answer!

> Try creating a derived back-end from 'html one and see.
>
> ox-s5.el and ox-deck.el might be useful to read, they are derived
> from the 'html back-end already.
>
> HTH,
>
> PS: Maybe some adjustments could be done later do on ox-html.el
> so that it's easier to derive new back-ends from it... but we're
> not there yet.

The first step is probably to research the differences between xhtml and
html 5. In a perfect world we'd be able to export to html 4, html 5, and
whatever flavor of xhtml is still current.

Bleagh!

E

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-12  6:01                   ` Eric Abrahamsen
@ 2013-04-12  8:46                     ` Bastien
  2013-04-12 14:36                       ` François Pinard
  0 siblings, 1 reply; 27+ messages in thread
From: Bastien @ 2013-04-12  8:46 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> The first step is probably to research the differences between xhtml and
> html 5.

Well, I would even skip this step and just hack something usable.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-12  8:46                     ` Bastien
@ 2013-04-12 14:36                       ` François Pinard
  2013-04-13  3:38                         ` Eric Abrahamsen
  0 siblings, 1 reply; 27+ messages in thread
From: François Pinard @ 2013-04-12 14:36 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg@gnu.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:

>> The first step is probably to research the differences between xhtml and
>> html 5.

> Well, I would even skip this step and just hack something usable.

There are validators out there, that could help us staying on track,
whatever the track :-).

François

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-12 14:36                       ` François Pinard
@ 2013-04-13  3:38                         ` Eric Abrahamsen
  2013-04-13  5:31                           ` Eric Abrahamsen
  0 siblings, 1 reply; 27+ messages in thread
From: Eric Abrahamsen @ 2013-04-13  3:38 UTC (permalink / raw)
  To: emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> writes:

> Bastien <bzg@gnu.org> writes:
>
>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>>> The first step is probably to research the differences between xhtml and
>>> html 5.
>
>> Well, I would even skip this step and just hack something usable.

Okay, I've got a nearly-working patch for this, but I'm falling down
hard on the defcustom. Here's what I thought to do:

#+BEGIN_SRC emacs-lisp
(defconst org-html-doctype-alist
  '((html4 . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">")
    (html4-strict . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">
\"http://www.w3.org/TR/html4/strict.dtd\"")
    (xhtml . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
    (html5 . "<!DOCTYPE HTML>"))
  "An alist mapping (x)html flavors to specific doctypes.")

(defcustom org-html-doctype 'xhtml  
  "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."
  :group 'org-export-html
  :version "24.4"
  :package-version '(Org . "8.0")
  :type 'i-dont-know-how-to-work-this) 
#+END_SRC

The end result I'm after is: the user can either set org-html-doctype to
a symbol from among the cars org-html-doctype-alist, or he/she can set
it directly to the doctype string. I don't know how to represent that in
a defcustom.

And of course, if anyone has any better approaches, then speak now or...
speak later.

Eric

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-13  3:38                         ` Eric Abrahamsen
@ 2013-04-13  5:31                           ` Eric Abrahamsen
  2013-04-13 20:42                             ` Rick Frankel
  0 siblings, 1 reply; 27+ messages in thread
From: Eric Abrahamsen @ 2013-04-13  5:31 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1816 bytes --]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> François Pinard <pinard@iro.umontreal.ca> writes:
>
>> Bastien <bzg@gnu.org> writes:
>>
>>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>
>>>> The first step is probably to research the differences between xhtml and
>>>> html 5.
>>
>>> Well, I would even skip this step and just hack something usable.


I sort of fudged on the below. The upside is that it should be pretty
forgiving now: you can set all kinds of strings as your :html-doctype,
and it will do a reasonably good job of guessing how to handle it.

Barring actual bugs or poor design decisions, what's left to do is:

1. Make sure that inlined script and style chunks are escaped correctly,
I seem to remember reading that the commenting/escaping syntax for these
chunks varies according to html flavor.

2. I'd like to add the possibility to put an arbitrary :html-container
attribute on HTML elements, so that things that would have been wrapped
in "div"s can be wrapped in "article", "section", "nav", and so on and
so forth.

Rick Frankel kindly provided a test file for this, which I've modified
below:

#+BEGIN_SRC emacs-lisp
#+TITLE:  HTML 5 Test
#+DATE:  {{{modification-time(%Y-%m-%d)}}}
#+HTML_DOCTYPE: html5
#+BIND: org-html-divs ((preamble "header" "preamble") (content "section" "content") (postamble "footer" "postamble"))
*  Org HTML5 Test
ok? This should be a paragraph with a \\
line break in it. I think
* How about a table
| col1 | col2 |
|------+------|
| a    |    1 |
| b    |    2 |
Tables can't have attributes in HTML5.
* And a list
- a
- b
- c
* And an image
[[file:1356810947473.jpg]]
* A definiton list
#+ATTR_HTML: :options html-container article
- a :: foo
- b :: bar
#+END_SRC

Please break! I'll provide a properly-written patch when we've sorted it out.

E


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-First-stab-at-exporting-to-various-flavors-of-HTML.patch --]
[-- Type: text/x-patch, Size: 15168 bytes --]

From 296bbf0f74d0c3d49259e146597a174e7c14fda9 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Sat, 13 Apr 2013 13:22:14 +0800
Subject: [PATCH] First stab at exporting to various flavors of HTML.

---
 lisp/ox-html.el | 151 +++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 96 insertions(+), 55 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 0ad3dc3..af80707 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -142,6 +142,15 @@
 (defvar org-html--pre/postamble-class "status"
   "CSS class used for pre/postamble")
 
+(defconst org-html-doctype-alist
+  '(("html4" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">")
+    ("html4-strict" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">
+\"http://www.w3.org/TR/html4/strict.dtd\"")
+    ("xhtml" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
+\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
+    ("html5" . "<!DOCTYPE HTML>"))
+  "An alist mapping (x)html flavors to specific doctypes.")
+
 (defconst org-html-special-string-regexps
   '(("\\\\-" . "&#x00ad;")		; shy
     ("---\\([^-]\\)" . "&#x2014;\\1")	; mdash
@@ -747,7 +756,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")
@@ -855,7 +866,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")
@@ -871,15 +884,14 @@ Use utf-8 as the default value."
   :package-version '(Org . "8.0")
   :type 'coding-system)
 
-(defcustom org-html-doctype
-  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
+(defcustom org-html-doctype "xhtml"  
   "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."
   :group 'org-export-html
   :version "24.4"
   :package-version '(Org . "8.0")
-  :type 'string)
+  :type 'string) 
 
 (defcustom org-html-container-element "div"
   "HTML element to use for wrapping top level sections.
@@ -1034,7 +1046,7 @@ precedence over this variable."
   '(("en" "<p class=\"author\">Author: %a (%e)</p>
 <p class=\"date\">Date: %d</p>
 <p class=\"creator\">%c</p>
-<p class=\"xhtml-validation\">%v</p>"))
+<p class=\"validation\">%v</p>"))
   "Alist of languages and format strings for the HTML postamble.
 
 The first element of each list is the language code, as used for
@@ -1059,7 +1071,7 @@ like that: \"%%\"."
 		:value-type (string :tag "Format string")))
 
 (defcustom org-html-validation-link
-  "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
+  "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
   "Link to HTML validation service."
   :group 'org-export-html
   :type 'string)
@@ -1239,6 +1251,19 @@ CSS classes, then this prefix can be very useful."
 \f
 ;;; Internal Functions
 
+(defun org-html-xhtml-p (info)
+  (let ((dt (downcase (plist-get info :html-doctype))))
+    (string-match-p dt "xhtml")))  
+
+(defun org-html-html5-p (info)
+  (let ((dt (downcase (plist-get info :html-doctype))))
+        (member dt '("html5" "<!doctype html>"))))  
+
+(defun org-html-close-tag (info)
+  (if (org-html-xhtml-p info)
+      "/>"
+    ">"))
+
 (defun org-html--make-attribute-string (attributes)
   "Return a list of attributes, as a string.
 ATTRIBUTES is a plist where values are either strings or nil. An
@@ -1252,7 +1277,7 @@ attributes with a nil value will be omitted from the result."
                              "\"" "&quot;" (org-html-encode-plain-text item))))
                  (setcar output (format "%s=\"%s\"" key value))))))))
 
-(defun org-html-format-inline-image (src &optional
+(defun org-html-format-inline-image (src &optional info
 					 caption label attr standalone-p)
   "Format an inline image from SRC.
 CAPTION, LABEL and ATTR are optional arguments providing the
@@ -1272,12 +1297,14 @@ When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>."
 				   (file-name-nondirectory src)))))))
     (cond
      (standalone-p
-      (let ((img (format "<img src=\"%s\" %s/>" src attr)))
+      (let ((img (format "<img src=\"%s\" %s%s" src attr
+			 (org-html-close-tag info))))
 	(format "\n<div%s class=\"figure\">%s%s\n</div>"
 		id (format "\n<p>%s</p>" img)
 		(if (and caption (not (string= caption "")))
 		    (format "\n<p>%s</p>" caption) ""))))
-     (t (format "<img src=\"%s\" %s/>" src (concat attr id))))))
+     (t (format "<img src=\"%s\" %s%s" src (concat attr id)
+		(org-html-close-tag info))))))
 
 (defun org-html--textarea-block (element)
   "Transcode ELEMENT into a textarea block.
@@ -1426,7 +1453,8 @@ INFO is a plist used as a communication channel."
 		      (let ((auth (plist-get info :author)))
 			(and auth (org-export-data auth info)))))
 	 (description (plist-get info :description))
-	 (keywords (plist-get info :keywords)))
+	 (keywords (plist-get info :keywords))
+	 (close (org-html-close-tag info)))
     (concat
      (format "<title>%s</title>\n" title)
      (format
@@ -1434,17 +1462,18 @@ INFO is a plist used as a communication channel."
 	(format-time-string
 	 (concat "<!-- " org-html-metadata-timestamp-format " -->\n"))))
      (format
-      "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n"
+      "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"%s\n"
       (or (and org-html-coding-system
 	       (fboundp 'coding-system-get)
 	       (coding-system-get org-html-coding-system 'mime-charset))
-	  "iso-8859-1"))
-     (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
-     (and author (format "<meta name=\"author\" content=\"%s\"/>\n" author))
+	  "iso-8859-1") close) 
+     (format "<meta name=\"generator\" content=\"Org-mode\"%s\n" close) 
+     (and author (format "<meta name=\"author\" content=\"%s\"%s\n" author close)) 
      (and description
-	  (format "<meta name=\"description\" content=\"%s\"/>\n" description))
+	  (format "<meta name=\"description\" content=\"%s\"%s\n" description
+		  close))
      (and keywords
-	  (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords)))))
+	  (format "<meta name=\"keywords\" content=\"%s\"%s\n" keywords close))))) 
 
 (defun org-html--build-head (info)
   "Return information for the <head>..</head> of the HTML output.
@@ -1457,8 +1486,8 @@ INFO is a plist used as a communication channel."
     (org-element-normalize-string (plist-get info :html-head-extra))
     (when (and (plist-get info :html-htmlized-css-url)
 	       (eq org-html-htmlize-output-type 'css))
-      (format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" />\n"
-	      (plist-get info :html-htmlized-css-url)))
+      (format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" %s>\n"
+	      (plist-get info :html-htmlized-css-url) (org-html-close-tag info)))
     (when (plist-get info :html-head-include-scripts) org-html-scripts))))
 
 (defun org-html--build-mathjax-config (info)
@@ -1555,7 +1584,7 @@ communication channel."
 		       (format-time-string org-html-metadata-timestamp-format)))
 		    (when (plist-get info :with-creator)
 		      (format "<p class=\"creator\">%s</p>\n" creator))
-		    (format "<p class=\"xhtml-validation\">%s</p>\n"
+		    (format "<p class=\"validation\">%s</p>\n"
 			    validation-link))))
 		(t (format-spec
 		    (or (cadr (assoc
@@ -1597,23 +1626,31 @@ holding export options."
 CONTENTS is the transcoded contents string.  INFO is a plist
 holding export options."
   (concat
-   (format
-    (or (and (stringp org-html-xml-declaration)
-	     org-html-xml-declaration)
-	(cdr (assoc (plist-get info :html-extension)
-		    org-html-xml-declaration))
-	(cdr (assoc "html" org-html-xml-declaration))
-
-	"")
-    (or (and org-html-coding-system
-	     (fboundp 'coding-system-get)
-	     (coding-system-get org-html-coding-system 'mime-charset))
-	"iso-8859-1"))
-   "\n"
-   (plist-get info :html-doctype)
+   (when (org-html-xhtml-p info)
+     (format "%s\n"
+	     (format (or (and (stringp org-html-xml-declaration)
+			      org-html-xml-declaration)
+			 (cdr (assoc (plist-get info :html-extension)
+				     org-html-xml-declaration))
+			 (cdr (assoc "html" org-html-xml-declaration))
+			 
+			 "")
+		     (or (and org-html-coding-system
+			      (fboundp 'coding-system-get)
+			      (coding-system-get org-html-coding-system 'mime-charset))
+			 "iso-8859-1"))))
+   (let* ((dt (plist-get info :html-doctype))
+	  (dt-cons (assoc dt org-html-doctype-alist)))
+     (if dt-cons
+	 (cdr dt-cons)
+       dt))
    "\n"
-   (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
-	   (plist-get info :language) (plist-get info :language))
+   (concat "<html"
+	   (when (org-html-xhtml-p info)
+	     (format
+	      " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
+	      (plist-get info :language) (plist-get info :language)))
+	   ">\n")
    "<head>\n"
    (org-html--build-meta-info info)
    (org-html--build-head info)
@@ -2164,7 +2201,7 @@ holding contextual information."
       ;; Build the real contents of the sub-tree.
       (let* ((type (if numberedp 'ordered 'unordered))
 	     (itemized-body (org-html-format-list-item
-			     contents type nil nil full-text)))
+			     contents type nil info nil full-text)))
 	(concat
 	 (and (org-export-first-sibling-p headline info)
 	      (org-html-begin-plain-list type))
@@ -2222,7 +2259,7 @@ holding contextual information."
 (defun org-html-horizontal-rule (horizontal-rule contents info)
   "Transcode an HORIZONTAL-RULE  object from Org to HTML.
 CONTENTS is nil.  INFO is a plist holding contextual information."
-  "<hr/>")
+  (format "<hr%s" (org-html-close-tag info)))
 
 ;;;; Inline Src Block
 
@@ -2279,11 +2316,12 @@ contextual information."
 	(trans "<code>[-]</code>")
 	(t "")))
 
-(defun org-html-format-list-item (contents type checkbox
+(defun org-html-format-list-item (contents type checkbox info
 					     &optional term-counter-id
 					     headline)
   "Format a list item into HTML."
-  (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " "))))
+  (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " ")))
+	(br (format "<br%s" (org-html-close-tag info))))
     (concat
      (case type
        (ordered
@@ -2291,13 +2329,13 @@ contextual information."
 	       (extra (if counter (format " value=\"%s\"" counter) "")))
 	  (concat
 	   (format "<li%s>" extra)
-	   (when headline (concat headline "<br/>")))))
+	   (when headline (concat headline br))))) 
        (unordered
 	(let* ((id term-counter-id)
 	       (extra (if id (format " id=\"%s\"" id) "")))
 	  (concat
 	   (format "<li%s>" extra)
-	   (when headline (concat headline "<br/>")))))
+	   (when headline (concat headline br))))) 
        (descriptive
 	(let* ((term term-counter-id))
 	  (setq term (or term "(no term)"))
@@ -2323,7 +2361,7 @@ contextual information."
 	 (tag (let ((tag (org-element-property :tag item)))
 		(and tag (org-export-data tag info)))))
     (org-html-format-list-item
-     contents type checkbox (or tag counter))))
+     contents type checkbox info (or tag counter))))
 
 ;;;; Keyword
 
@@ -2382,7 +2420,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	(when (and formula-link
 		   (string-match "file:\\([^]]*\\)" formula-link))
 	  (org-html-format-inline-image
-	   (match-string 1 formula-link) caption label attr t))))
+	   (match-string 1 formula-link) info caption label attr t))))
      (t latex-frag))))
 
 ;;;; Latex Fragment
@@ -2401,7 +2439,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	 (when (and formula-link
 		    (string-match "file:\\([^]]*\\)" formula-link))
 	   (org-html-format-inline-image
-	    (match-string 1 formula-link)))))
+	    (match-string 1 formula-link) info))))
       (t latex-frag))))
 
 ;;;; Line Break
@@ -2409,7 +2447,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 (defun org-html-line-break (line-break contents info)
   "Transcode a LINE-BREAK object from Org to HTML.
 CONTENTS is nil.  INFO is a plist holding contextual information."
-  "<br/>\n")
+  (format "<br%s\n" (org-html-close-tag info)))
 
 ;;;; Link
 
@@ -2434,7 +2472,7 @@ Inline images can have these attributes:
 	 (label (org-element-property :name parent)))
     ;; Return proper string, depending on DISPOSITION.
     (org-html-format-inline-image
-     path caption label
+     path info caption label
      (org-html--make-attribute-string
       (org-export-read-attribute :attr_html parent))
      (org-html-standalone-image-p link info))))
@@ -2755,7 +2793,8 @@ contextual information."
     (when (plist-get info :preserve-breaks)
       (setq output
 	    (replace-regexp-in-string
-	     "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output)))
+	     "\\(\\\\\\\\\\)?[ \t]*\n"
+	     (format "<br%s\n" (org-html-close-tag info)) output)))
     ;; Return value.
     output))
 
@@ -3030,11 +3069,12 @@ contextual information."
      (let* ((label (org-element-property :name table))
 	    (caption (org-export-get-caption table))
 	    (attributes
-	     (org-html--make-attribute-string
-	      (org-combine-plists
-	       (and label (list :id (org-export-solidify-link-text label)))
-	       (plist-get info :html-table-attributes)
-	       (org-export-read-attribute :attr_html table))))
+	     (if (org-html-html5-p info) ""
+	       (org-html--make-attribute-string
+		(org-combine-plists
+		 (and label (list :id (org-export-solidify-link-text label)))
+		 (plist-get info :html-table-attributes)
+		 (org-export-read-attribute :attr_html table)))))
 	    (alignspec
 	     (if (and (boundp 'org-html-format-table-no-css)
 		      org-html-format-table-no-css)
@@ -3114,9 +3154,10 @@ contextual information."
   ;; Replace each newline character with line break.  Also replace
   ;; each blank line with a line break.
   (setq contents (replace-regexp-in-string
-		  "^ *\\\\\\\\$" "<br/>\n"
+		  "^ *\\\\\\\\$" (format "<br%s\n" (org-html-close-tag info))
 		  (replace-regexp-in-string
-		   "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents)))
+		   "\\(\\\\\\\\\\)?[ \t]*\n"
+		   (format " <br%s\n" (org-html-close-tag info)) contents)))
   ;; Replace each white space at beginning of a line with a
   ;; non-breaking space.
   (while (string-match "^[ \t]+" contents)
-- 
1.8.2.1


[-- Attachment #3: Type: text/plain, Size: 1292 bytes --]




> Okay, I've got a nearly-working patch for this, but I'm falling down
> hard on the defcustom. Here's what I thought to do:
>
> #+BEGIN_SRC emacs-lisp
> (defconst org-html-doctype-alist
>   '((html4 . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">")
>     (html4-strict . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">
> \"http://www.w3.org/TR/html4/strict.dtd\"")
>     (xhtml . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
> \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
>     (html5 . "<!DOCTYPE HTML>"))
>   "An alist mapping (x)html flavors to specific doctypes.")
>
> (defcustom org-html-doctype 'xhtml  
>   "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."
>   :group 'org-export-html
>   :version "24.4"
>   :package-version '(Org . "8.0")
>   :type 'i-dont-know-how-to-work-this) 
> #+END_SRC
>
> The end result I'm after is: the user can either set org-html-doctype to
> a symbol from among the cars org-html-doctype-alist, or he/she can set
> it directly to the doctype string. I don't know how to represent that in
> a defcustom.
>
> And of course, if anyone has any better approaches, then speak now or...
> speak later.
>
> Eric

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-12  2:06               ` Eric Abrahamsen
  2013-04-12  5:42                 ` Bastien
@ 2013-04-13 17:10                 ` Rick Frankel
  2013-04-14  8:41                   ` Bastien
  1 sibling, 1 reply; 27+ messages in thread
From: Rick Frankel @ 2013-04-13 17:10 UTC (permalink / raw)
  To: emacs-orgmode

On Fri, Apr 12, 2013 at 10:06:21AM +0800, Eric Abrahamsen wrote:
> François Pinard <pinard@iro.umontreal.ca> writes:
> 
> > Christian Moe <mail@christianmoe.com> writes:
> >
> > While on this subject! :-)
> >
> > Could Org allow the output of HTML5 rather than XHTML, under the control
> > of some option?  I've read that some frameworks really expect HTML5 to
> > work properly, such an option might ease inter-operation between
> > exported Org and such frameworks.
> 
> I'm curious about this possibility as well -- how much work would it be?

Sorry, late to the thread, i've been laid up. Anyway, the xhtml output
from ox-html _should_ be
mostly valid html5 (valid xhtml 1.0 in general should be valid html5).
 
However, you will need to change the html-table-tag to not use
attributes, and remove the xml declaration
(which is a warning and not an error in html5)
 
Here's a sample org file (which changes the divs to be more "html5ish"
as well, not necessary)
which validates as HTML5: (btw, i've remove the scripts and
default-styles just to make the
html output smaller, the file will validate even with them in the
output).
 
rick
 
----- %< ---------
#+TITLE:  HTML 5 Test
#+DATE:  {{{modification-time(%Y-%m-%d)}}}
#+HTML_DOCTYPE: <!DOCTYPE html>
#+BIND: org-html-xml-declaration ""
#+BIND: org-html-head-include-default-style nil
#+BIND: org-html-table-tag "<table>"
#+BIND: org-html-scripts ""
#+BIND: org-html-divs ((preamble "header" "preamble") (content
"section" "content") (postamble "footer" "postamble"))
* Org HTML5 Test
ok?
* How about a table
| col1 | col2 |
|------+------|
| a    |    1 |
| b    |    2 |
* And a list
- a
- b
- c
* A definiton list
 - a :: foo
- b :: bar
 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-13  5:31                           ` Eric Abrahamsen
@ 2013-04-13 20:42                             ` Rick Frankel
  2013-04-14 10:13                               ` Eric Abrahamsen
  0 siblings, 1 reply; 27+ messages in thread
From: Rick Frankel @ 2013-04-13 20:42 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

On Sat, Apr 13, 2013 at 01:31:17PM +0800, Eric Abrahamsen wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> 
> > François Pinard <pinard@iro.umontreal.ca> writes:
> >
> >> Bastien <bzg@gnu.org> writes:
> >>
> >>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> >>
> >>>> The first step is probably to research the differences between xhtml and
> >>>> html 5.
> >>
> >>> Well, I would even skip this step and just hack something usable.
> 
> 
> I sort of fudged on the below. The upside is that it should be pretty
> forgiving now: you can set all kinds of strings as your :html-doctype,
> and it will do a reasonably good job of guessing how to handle it.
> 
> Barring actual bugs or poor design decisions, what's left to do is:
> 
> 1. Make sure that inlined script and style chunks are escaped correctly,
> I seem to remember reading that the commenting/escaping syntax for these
> chunks varies according to html flavor.
> 
> 2. I'd like to add the possibility to put an arbitrary :html-container

> #+BEGIN_SRC emacs-lisp
> #+TITLE:  HTML 5 Test
> #+DATE:  {{{modification-time(%Y-%m-%d)}}}
> #+HTML_DOCTYPE: html5
> #+BIND: org-html-divs ((preamble "header" "preamble") (content "section" "content") (postamble "footer" "postamble"))
> *  Org HTML5 Test
> #+ATTR_HTML: :options html-container article

note that you just just set #+HTML_CONTAINER: article in the head of the
file if you want all the containers to be "article"s.

> +(defconst org-html-doctype-alist
> +  '(("html4" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">")
> +    ("html4-strict" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">
> +\"http://www.w3.org/TR/html4/strict.dtd\"")
> +    ("xhtml" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
> +\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
> +    ("html5" . "<!DOCTYPE HTML>"))

I believe that should be (note the lowercase "html"):

  ("xhtml" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
> +\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
  ("html5" . "<!DOCTYPE html>")

See http://www.w3schools.com/tags/tag_doctype.asp for a fairly
complete list of valid doctypes.

rick

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-13 17:10                 ` Rick Frankel
@ 2013-04-14  8:41                   ` Bastien
  0 siblings, 0 replies; 27+ messages in thread
From: Bastien @ 2013-04-14  8:41 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode

Hi Rick,

Rick Frankel <rick@rickster.com> writes:

> However, you will need to change the html-table-tag to not use
> attributes, and remove the xml declaration
> (which is a warning and not an error in html5)

(Note that `org-html-table-tag' has been deleted, you need to check
`org-html-table-default-attributes' instead.)

The HTML5 validation is good news and your example is great.
Would be nice to have this in worg/org-faq.org!

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-13 20:42                             ` Rick Frankel
@ 2013-04-14 10:13                               ` Eric Abrahamsen
  2013-04-14 18:01                                 ` Rick Frankel
  2013-04-15 18:03                                 ` Rick Frankel
  0 siblings, 2 replies; 27+ messages in thread
From: Eric Abrahamsen @ 2013-04-14 10:13 UTC (permalink / raw)
  To: emacs-orgmode

Rick Frankel <rick@rickster.com> writes:

> On Sat, Apr 13, 2013 at 01:31:17PM +0800, Eric Abrahamsen wrote:
>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>> 
>> > François Pinard <pinard@iro.umontreal.ca> writes:
>> >
>> >> Bastien <bzg@gnu.org> writes:
>> >>
>> >>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>> >>
>> >>>> The first step is probably to research the differences between xhtml and
>> >>>> html 5.
>> >>
>> >>> Well, I would even skip this step and just hack something usable.
>> 
>> 
>> I sort of fudged on the below. The upside is that it should be pretty
>> forgiving now: you can set all kinds of strings as your :html-doctype,
>> and it will do a reasonably good job of guessing how to handle it.
>> 
>> Barring actual bugs or poor design decisions, what's left to do is:
>> 
>> 1. Make sure that inlined script and style chunks are escaped correctly,
>> I seem to remember reading that the commenting/escaping syntax for these
>> chunks varies according to html flavor.
>> 
>> 2. I'd like to add the possibility to put an arbitrary :html-container
>
>> #+BEGIN_SRC emacs-lisp
>> #+TITLE:  HTML 5 Test
>> #+DATE:  {{{modification-time(%Y-%m-%d)}}}
>> #+HTML_DOCTYPE: html5
>> #+BIND: org-html-divs ((preamble "header" "preamble") (content "section" "content") (postamble "footer" "postamble"))
>> *  Org HTML5 Test
>> #+ATTR_HTML: :options html-container article
>
> note that you just just set #+HTML_CONTAINER: article in the head of the
> file if you want all the containers to be "article"s.

That would be pretty drastic, though -- it would wrap "article" around a
whole bunch of stuff that shouldn't be an article! I think ultimately
the HTML exporter should grow a slightly more flexible system for
wrapping document sections in containers, but this patch definitely
shouldn't get hung up on that.

>> +(defconst org-html-doctype-alist
>> +  '(("html4" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">")
>> +    ("html4-strict" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">
>> +\"http://www.w3.org/TR/html4/strict.dtd\"")
>> +    ("xhtml" . "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
>> +\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
>> +    ("html5" . "<!DOCTYPE HTML>"))
>
> I believe that should be (note the lowercase "html"):
>
>   ("xhtml" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
>> +\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
>   ("html5" . "<!DOCTYPE html>")
>
> See http://www.w3schools.com/tags/tag_doctype.asp for a fairly
> complete list of valid doctypes.

Cool, thanks for the reference. If the approach of this patch seems
generally acceptable I'll try to add most of the commonly-used doctypes
in there. I'm waffling on XHTML5, though -- from what I can tell it's a
spec everyone sort of thought ought to be in there, but no one is
actually using.

E

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-14 10:13                               ` Eric Abrahamsen
@ 2013-04-14 18:01                                 ` Rick Frankel
  2013-04-15 18:03                                 ` Rick Frankel
  1 sibling, 0 replies; 27+ messages in thread
From: Rick Frankel @ 2013-04-14 18:01 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

On Sun, Apr 14, 2013 at 06:13:40PM +0800, Eric Abrahamsen wrote:
> Rick Frankel <rick@rickster.com> writes:
> 
> > On Sat, Apr 13, 2013 at 01:31:17PM +0800, Eric Abrahamsen wrote:
> >> *  Org HTML5 Test
> >> #+ATTR_HTML: :options html-container article
> >> - a :: foo
> >> - b :: bar

> > note that you just just set #+HTML_CONTAINER: article in the head of the
> > file if you want all the containers to be "article"s.
> 
> That would be pretty drastic, though -- it would wrap "article" around a
> whole bunch of stuff that shouldn't be an article! I think ultimately
> the HTML exporter should grow a slightly more flexible system for
> wrapping document sections in containers, but this patch definitely
> shouldn't get hung up on that.

It specifies the element for the top-level container---by default,
something like:

          <div id="outline-container-sec-1" class="outline-2">

In the case of e.g., a blog or slideshow, <article> is an appropriate
top-level wrapper lelement.

Regardless, I'm not sure which object you are expecting the
#+ATTR_HTML to apply to in the example above. Here's the html the
above section generates:

#+BEGIN_HTML
<div id="outline-container-sec-5" class="outline-2">
  <h2 id="sec-5"><span class="section-number-2">5</span> A definiton list</h2>
  <div class="outline-text-2" id="text-5">
    <dl class="org-dl">
      <dt> a </dt><dd>foo
      </dd>
      <dt> b </dt><dd>bar
      </dd>
    </dl>
  </div>
</div>

Where the 'outline-text-2' div is actually around the entire body of
the section, not just the definition list (there is no explicit
wrapper around the definition list).

I would argue that to set the element type fro the outer
(outline-container) div or the inner (outline-text) div, a property
setting would make more sense. I can see using a (headline level)
:HTML_CONTAINER property to set the container on a given headline
(which i think i will impliment as it is very low impact), and perhaps
either an :HTML_CHILD_CONTAINER or :HTML_TEXT_CONTAINER to specify the
wrapper on the inner section.

rick

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Attributes on HTML tables?
  2013-04-14 10:13                               ` Eric Abrahamsen
  2013-04-14 18:01                                 ` Rick Frankel
@ 2013-04-15 18:03                                 ` Rick Frankel
  1 sibling, 0 replies; 27+ messages in thread
From: Rick Frankel @ 2013-04-15 18:03 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

Eric-

> Rick Frankel <rick@rickster.com> writes:

> I would argue that to set the element type fro the outer
> (outline-container) div or the inner (outline-text) div, a property
> setting would make more sense. I can see using a (headline level)
> :HTML_CONTAINER property to set the container on a given headline
> (which i think i will impliment as it is very low impact), and perhaps
> either an :HTML_CHILD_CONTAINER or :HTML_TEXT_CONTAINER to specify the
> wrapper on the inner section.

I have pushed to master the abilty to set the :HTML_CONTAINER property
on any headline and have that value override the default
(:html-container for level 1 headines, "div" for the rest).

Note that this is not an inherited property so only affect the
headline it is specified on, not it's children.

rick

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2013-04-15 18:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-07  2:55 Attributes on HTML tables? François Pinard
2013-04-07  6:27 ` Bastien
2013-04-07 14:42   ` Christian Moe
2013-04-07 18:46     ` Nicolas Goaziou
2013-04-07 20:39       ` Christian Moe
2013-04-07 20:48         ` Nicolas Goaziou
2013-04-08 21:09           ` Christian Moe
2013-04-10 17:44             ` François Pinard
2013-04-12  2:06               ` Eric Abrahamsen
2013-04-12  5:42                 ` Bastien
2013-04-12  6:01                   ` Eric Abrahamsen
2013-04-12  8:46                     ` Bastien
2013-04-12 14:36                       ` François Pinard
2013-04-13  3:38                         ` Eric Abrahamsen
2013-04-13  5:31                           ` Eric Abrahamsen
2013-04-13 20:42                             ` Rick Frankel
2013-04-14 10:13                               ` Eric Abrahamsen
2013-04-14 18:01                                 ` Rick Frankel
2013-04-15 18:03                                 ` Rick Frankel
2013-04-13 17:10                 ` Rick Frankel
2013-04-14  8:41                   ` Bastien
2013-04-10 19:37             ` Nicolas Goaziou
2013-04-11  8:28               ` Christian Moe
2013-04-11 10:55                 ` Nicolas Goaziou
2013-04-11 12:14                   ` Christian Moe
2013-04-11 15:34                   ` Bastien
2013-04-11 17:29                     ` Nicolas Goaziou

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.