Re: [O] [New Exporter] Parameterized wrapper elements

2013-03-09 Thread Bastien
Hi Rick,

besides Nicolas good suggestions regarding the code, I think
the patch is good and I welcome more flexibility in the HTML
exporter so that HTML5-ready derived backends can be written.

I'll have a careful look next week.

One thing you may double-check in the meantime is: is it
compatible with the org-info.js utility?  The default should
be yes, even if users can replace div by something else
(e.g. for the needs of specific backends.)

In any case, thanks!

-- 
 Bastien



Re: [O] [New Exporter] Parameterized wrapper elements

2013-03-09 Thread Rick Frankel
On Sat, Mar 09, 2013 at 01:46:37AM +0100, Nicolas Goaziou wrote:
 Since I don't use html back-end, it would be better to hear from actual
 users what they think about it.

Sorry, forgot that you are not the keeper of ox-html, just the new
exporter at large ;).

 Anyway, just a few comments:
 

  +(defcustom org-html-divs
  +  '((preamble  div)
  +(content   div)
  +(postamble div))
  +  Alist of the main divs for HTML export.

 Even if this is technically an alist, you don't use it as such, because
 you do not treat ID as keys.
 
 Perhaps something like the following would be better:
 
   '((preamble preamble div)
 (content content div)
 (postamble postamble div))
 
 One advantage is that you don't have to rely on order of associations.
 Another advantage is that you can write:
 
   (nth 1 (assq 'content org-html-divs))

I agree, but couldn't figure out a way to specify a defcustom alist
that requires a fixed set of options. I'm quite new to the
defcustom specification format, so maybe there is a way...

Given what I see is possible w/ custom alists, the code would have to
look like:

 (nth 1 (or (assq 'content org-html-divs)
 (assq 'content org-html-default-divs)))

Not sure this is any better than the nth nth approach. What do you
think?

  +   (if (= 1 (org-export-get-relative-level headline info))
  +   (plist-get info :html-container
 
 Shouldn't you close the div when level is different from 1 here?

Yes, it's a bug. Missing the else part. Will amend the patch and
repost. thanx for finding this.

rick



Re: [O] [New Exporter] Parameterized wrapper elements

2013-03-09 Thread Rick Frankel
On Sat, Mar 09, 2013 at 10:32:11AM +0100, Bastien wrote:
 Hi Rick,

 One thing you may double-check in the meantime is: is it
 compatible with the org-info.js utility?  The default should
 be yes, even if users can replace div by something else
 (e.g. for the needs of specific backends.)

Yes. Checked the code and tested the script. It works on element ids
and not element types, so changing the element type from `div' has no
effect.

The things that will break infojs are changing the following ids:

- content
- postamble
- footnotes
- table-of-contents
- text-table-of-content
- text-{slidenum}
  
Note that the current implementation of `org-html-divs' will
potentially break infojs as well.

Attached is a revised patch with the fixes Nicolas found for the
doc-string and the missing closing element.

rick
From d539863475c4c1432b2b5de175d587f57b317453 Mon Sep 17 00:00:00 2001
From: Rick Frankel r...@rickster.com
Date: Fri, 8 Mar 2013 19:00:21 -0500
Subject: [PATCH] Parameterize some html content containers

* lisp/ox-html.el: (define-backend): Add :html-doctype and
:html-container parameters.
(org-html-doctype): New customization variable for doctype
declaration.
(org-html-container-elemnt): New customization variable for specifying
wrapper container element.
(org-html-div): Change to list of pairs id, element type to allow
setting container element.
(org-html--build-preamble): Modified to use new org-html-div settings.
(org-html--build-postamble): Modified to use new org-html-div settings.
(org-html-template): Modified to use doctype and container-element
settings.
---
 lisp/ox-html.el | 77 +++--
 1 file changed, 58 insertions(+), 19 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 829fe28..b1638e6 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -113,6 +113,8 @@
   (org-open-file (org-html-export-to-html nil s v b)))
   :options-alist
   ((:html-extension nil nil org-html-extension)
+   (:html-doctype HTML_DOCTYPE nil org-html-doctype)
+   (:html-container HTML_CONTAINER nil org-html-container-element)
(: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)
@@ -859,19 +861,44 @@ Use utf-8 as the default value.
   :package-version '(Org . 8.0)
   :type 'coding-system)
 
-(defcustom org-html-divs '(preamble content postamble)
-  The name of the main divs for HTML export.
-This is a list of three strings, the first one for the preamble
-DIV, the second one for the content DIV and the third one for the
-postamble DIV.
+(defcustom org-html-doctype
+  !DOCTYPE html PUBLIC \-//W3C//DTD XHTML 1.0 Strict//EN\
+\http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\;
+  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 '(list
- (string :tag  Div for the preamble:)
- (string :tag   Div for the content:)
- (string :tag Div for the postamble:)))
+  :type 'string)
+
+(defcustom org-html-container-element div
+  Container class to use for wrapping top level sections.
+Can be set with the in-buffer HTML_CONTAINER property or for
+publishing, with :html-container.
+  :group 'org-export-html
+  :version 24.4
+  :package-version '(Org . 8.0)
+  :type 'string)
 
+(defcustom org-html-divs
+  '((preamble  div)
+(content   div)
+(postamble div))
+  Alist of the main divs for HTML export.
+This is a list of three pairs, ID and ELEMENT, the first one
+for the preamble, the second one for the content and the
+third one for the postamble.
+  :group 'org-export-html
+  :version 24.4
+  :package-version '(Org . 8.0)
+  :type '(list
+ (list :tag Preamble
+   (string :tag  id) (string :tag element))
+ (list :tag Content
+   (string :tag  id) (string :tag element))
+ (list :tag Postamble
+   (string :tag  id) (string :tag element
 
  Template :: Mathjax
 
@@ -1482,9 +1509,11 @@ INFO is a plist used as a communication channel.
`((?t . ,title) (?a . ,author)
  (?d . ,date) (?e . ,email
(when (org-string-nw-p preamble-contents)
- (concat (format div id=\%s\\n (nth 0 org-html-divs))
+ (concat (format %s id=\%s\\n
+ (nth 1 (nth 0 org-html-divs))
+ (nth 0 (nth 0 org-html-divs)))
  (org-element-normalize-string preamble-contents)
- /div\n))
+ (format /%s\n (nth 1 (nth 0 org-html-divs)
 
 (defun org-html--build-postamble (info)
   Return document postamble as a string, or nil.
@@ -1534,9 +1563,11 @@ INFO is a plist used as a communication channel.
 

Re: [O] [New Exporter] Parameterized wrapper elements

2013-03-09 Thread Jambunathan K
Rick

I have my reservations in applying this patch - I am not concerned about
the patch, I have not looked at it.  

Any improvements to existing backends should invariably answer the
question - Can this change improve export tools or the parse tree
syntax.

If such a question is never asked and a answer sought, I would blame the
committer - whoever it be - in placing convenience and expediency above
the correct way to do things.

I have not looked at Rick's patch so my comment shouldn't be construed
as disapproval of the patch.  I want the patch to improve exporter tools
and it has potential to improve the existing tools (maybe) in small ways
- an improvement is an improvement.

Jambunathan K.

Rick Frankel r...@rickster.com writes:

 On Sat, Mar 09, 2013 at 10:32:11AM +0100, Bastien wrote:
 Hi Rick,

 One thing you may double-check in the meantime is: is it
 compatible with the org-info.js utility?  The default should
 be yes, even if users can replace div by something else
 (e.g. for the needs of specific backends.)

 Yes. Checked the code and tested the script. It works on element ids
 and not element types, so changing the element type from `div' has no
 effect.

 The things that will break infojs are changing the following ids:

 - content
 - postamble
 - footnotes
 - table-of-contents
 - text-table-of-content
 - text-{slidenum}
   
 Note that the current implementation of `org-html-divs' will
 potentially break infojs as well.

 Attached is a revised patch with the fixes Nicolas found for the
 doc-string and the missing closing element.

 rick


-- 



Re: [O] [New Exporter] Parameterized wrapper elements

2013-03-08 Thread Nicolas Goaziou
Hello,

Rick Frankel r...@rickster.com writes:

 Anyway, attached is a patch which parameterizes the html exporter in a
 way which is useful (for me :) in deriving new backends. It also make
 the exporter more capable of generating HTML5 compatible output
 instead of just XHTML.

Thank you for your patch.

 If you agree with it, i would be happy to apply it (or you can :).

Since I don't use html back-end, it would be better to hear from actual
users what they think about it.

Anyway, just a few comments:

 +(defcustom org-html-container-element div
 +  Container class to use for wrapping top level sections in
 +the exported html file. Can be set with the in-buffer HTML_CONTAINER
 +property or for publishing, with :html-container

First line needs to be a sentence on its own. Also, the docstring has to
end with a full stop.

 +(defcustom org-html-divs
 +  '((preamble  div)
 +(content   div)
 +(postamble div))
 +  Alist of the main divs for HTML export.
 +This is a list of three pairs, ID and ELEMENT, the first one
 +for the preamble, the second one for the content and the
 +third one for the postamble.
 +  :group 'org-export-html
 +  :version 24.4
 +  :package-version '(Org . 8.0)
 +  :type '(list
 +   (list :tag Preamble
 + (string :tag  id) (string :tag element))
 +   (list :tag Content
 + (string :tag  id) (string :tag element))
 +   (list :tag Postamble
 + (string :tag  id) (string :tag element

Even if this is technically an alist, you don't use it as such, because
you do not treat ID as keys.

Perhaps something like the following would be better:

  '((preamble preamble div)
(content content div)
(postamble postamble div))

One advantage is that you don't have to rely on order of associations.
Another advantage is that you can write:

  (nth 1 (assq 'content org-html-divs))

instead of:

  (nth 1 (nth 1 org-html-divs))

which, IMO, is easier to read.

 +   contents)
 + (if (= 1 (org-export-get-relative-level headline info))
 + (plist-get info :html-container

Shouldn't you close the div when level is different from 1 here?


Regards,

-- 
Nicolas Goaziou



Re: [O] [New Exporter] Parameterized wrapper elements

2013-03-08 Thread Jambunathan K
Rick Frankel r...@rickster.com writes:

 (cc'ing list)

 Nicolas-

 The patch Jambunathan sent didn't really make much sense to me, 

That's fine.  I didn't understand what you are saying then.  

Show me examples of how HTML5 code or deck code looks like.  Show me
your backend code (specifics of what function to look and what it does).

I don't understand HTML so you need to be patient.  

Since I took sometime to type out whatever I did, you have every reason
to believe I will do something which will help with your endeavors (not
necessarily the way you see it currently)

 as it didn't provide any added functionality over simply subclassing
 (deriving) from the current html exporter.

 Anyway, attached is a patch which parameterizes the html exporter in a
 way which is useful (for me :) in deriving new backends. It also make
 the exporter more capable of generating HTML5 compatible output
 instead of just XHTML.

I would like to see how these changes are consumed by your backend.
Show me the backend code.

As a generic remark -

Functional composition is more work but provides more flexibility than
what a defcustom can provide.  defcustoms are context agnostic, so I
will rather avoid it.

I have some ideas on how preamble and postamble should be represented in
parse tree.  But it is something that I have to work with Nicolas.  

I can assure you things will proceed slowly, but I can make promise
progress from my end.

 If you agree with it, i would be happy to apply it (or you can :).

Work with me, on or off the list preferably off-the-list.  What you do
is your call.

 rick


--