Re: [O] [PATCH] org-html.el: Fix export of table.el tables.

2011-04-26 Thread Manuel Giraud

Hi,

I've tried your patch and the output is prettier afterward. I'm not a
HTML tables expert but all those nbsp; in output seems scary. But
AFAIU, with org-export-prefer-native-exporter-for-tables to nil, simple
table stays in HTML, no?

Best regards,
-- 
Manuel Giraud



Re: [O] [PATCH] org-html.el: Fix export of table.el tables.

2011-04-26 Thread Manuel Giraud
Manuel Giraud manuel.gir...@univ-nantes.fr writes:

 But AFAIU, with org-export-prefer-native-exporter-for-tables to nil,
 simple table stays  in HTML, no?
 
 simple
-- 
Manuel Giraud



Re: [O] [PATCH] org-html.el: Fix export of table.el tables.

2011-04-26 Thread Manuel Giraud
Jambunathan K kjambunat...@gmail.com writes:

 Our understanding matches. For the sake of clarity, here it is:

 For simple tables,
 1. org-export-prefer-native-exporter-for-tables = Non-nil = Use the
HTML code generator in table.el = HTML *source code* has Lots of
nbsp

 2. org-export-prefer-native-exporter-for-tables = nil = Use Org's own
code generator = HTML *source code* is easy to look at.

Yes. The rendered HTML output is prettier with your patch. It is just
the HTML source that is full of nbsp;. But now, I understand that it
comes from table.el.

 [snip]
 May be you are exporting a different table.el table? Can you post your
 example? 

No, I've used your example to test your patch.

 With point within a simple table.el-table, the elisp form down
 below should eval to false. Is it any different in your setting? 

 #+begin_src emacs-lisp
 (let* ((dim (table-query-dimension))
(c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
   (not (= (* c r) cells)))
 #+end_src

Yes. It is false for simple table without spanning so I guess it's ok.

 It is possible that I have misunderstood how table-query-dimension API
 works ...

No, it's ok and it is my fault: I was worried about the complex HTML
output but now I understood that it is so for spanning table that are
rendered by table.el (and as I said I'm no HTML table expert so I guess
that table.el is the right thing when it comes to complex tables).

Best,
-- 
Manuel Giraud



[O] [PATCH] org-html.el: Fix export of table.el tables.

2011-04-24 Thread Jambunathan K

Changelog
-

org-html.el: Fix export of table.el tables.

* lisp/org-html.el (org-export-as-html): Don't expand non-data
lines of table.el tables.
(org-html-expand): Removed the (buggy) test for non-data lines
in table.el tables. The test is now done as part of
org-export-as-html.
(org-format-table-table-html-using-table-generate-source):
Added test for spanning of cells in table.el tables using
table.el's own library routine. Optionlly Suppress export of
simple table.el tables.
(org-format-table-html): Removed the (buggy) test for spanned
table.el tables. The test is now done as part of
org-format-table-table-html-using-table-generate-source.


From 3c8ff02efa0d2a4a08fe5341b9faa1de193048e9 Mon Sep 17 00:00:00 2001
From: Jambunathan K kjambunat...@gmail.com
Date: Mon, 25 Apr 2011 03:35:03 +0530
Subject: [PATCH] org-html: Fix export of table.el tables.

* lisp/org-html.el (org-export-as-html): Don't expand non-data
lines of table.el tables.
(org-html-expand): Removed the (buggy) test for non-data lines
in table.el tables. The test is now done as part of
org-export-as-html.
(org-format-table-table-html-using-table-generate-source):
Added test for spanning of cells in table.el tables using
table.el's own library routine. Optionlly Suppress export of
simple table.el tables.
(org-format-table-html): Removed the (buggy) test for spanned
table.el tables. The test is now done as part of
org-format-table-table-html-using-table-generate-source.
---
 lisp/org-html.el |   72 +++--
 1 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/lisp/org-html.el b/lisp/org-html.el
index 7a4564d..29bb825 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1543,6 +1543,7 @@ lang=\%s\ xml:lang=\%s\
 	  ;; handle @.. HTML tags (replace @gt;..lt; by ..)
 	  ;; Also handle sub_superscripts and checkboxes
 	  (or (string-match org-table-hline-regexp line)
+	  (string-match ^[ \t]*\\([+]-\\||[ ]\\)[-+ |]*[+|][ \t]*$ line)
 	  (setq line (org-html-expand line)))
 
 	  ;; Format the links
@@ -1888,24 +1889,13 @@ NO-CSS is passed to the exporter.
   (if (string-match ^[ \t]*| (car lines))
   ;; A normal org table
   (org-format-org-table-html lines nil no-css)
-;; Table made by table.el - test for spanning
-(let* ((hlines (delq nil (mapcar
-			  (lambda (x)
-(if (string-match ^[ \t]*\\+- x) x
-  nil))
-			  lines)))
-	   (first (car hlines))
-	   (ll (and (string-match \\S-+ first)
-		(match-string 0 first)))
-	   (re (concat ^[ \t]* (regexp-quote ll)))
-	   (spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
-   hlines
-  (if (and (not spanning)
-	   (not org-export-prefer-native-exporter-for-tables))
-	  ;; We can use my own converter with HTML conversions
-	  (org-format-table-table-html lines)
-	;; Need to use the code generator in table.el, with the original text.
-	(org-format-table-table-html-using-table-generate-source olines)
+;; Table made by table.el 
+(or (org-format-table-table-html-using-table-generate-source
+	 olines (not org-export-prefer-native-exporter-for-tables))
+	;; We are here only when table.el table has NO col or row
+	;; spanning and the user prefers using org's own converter for
+	;; exporting of such simple table.el tables.
+	(org-format-table-table-html lines
 
 (defvar org-table-number-fraction) ; defined in org-table.el
 (defun org-format-org-table-html (lines optional splice no-css)
@@ -2116,10 +2106,20 @@ But it has the disadvantage, that no cell- or row-spanning is allowed.
 (setq html (concat html /table\n))
 html))
 
-(defun org-format-table-table-html-using-table-generate-source (lines)
+(defun org-format-table-table-html-using-table-generate-source (lines
+optional
+spanned-only)
   Format a table into html, using `table-generate-source' from table.el.
-This has the advantage that cell- or row-spanning is allowed.
-But it has the disadvantage, that Org-mode's HTML conversions cannot be used.
+Use SPANNED-ONLY to suppress exporting of simple table.el tables.
+
+When SPANNED-ONLY is nil, all table.el tables are exported.  When
+SPANNED-ONLY is non-nil, only tables with either row or column
+spans are exported.
+
+This routine returns the generated source or nil as appropriate.
+
+Refer docstring of `org-export-prefer-native-exporter-for-tables'
+for further information.
   (require 'table)
   (with-current-buffer (get-buffer-create  org-tmp1 )
 (erase-buffer)
@@ -2128,10 +2128,14 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used.
 (if (not (re-search-forward |[^+] nil t))
 	(error Error processing table))
 (table-recognize-table)
-(with-current-buffer (get-buffer-create  org-tmp2 ) (erase-buffer))
-(table-generate-source 'html  org-tmp2 )
-(set-buffer  org-tmp2 )
-(buffer-substring (point-min) (point-max
+(when (or (not spanned-only)
+	  (let* 

Re: [O] [PATCH] org-html.el: Fix export of table.el tables.

2011-04-24 Thread Jambunathan K

 org-html.el: Fix export of table.el tables.

The original mail contains an org file as an attachment which contains
sample table.el tables used for sanitizing the patch.

Forgot to add this note to my earlier mail.

Jambunathan K.

--