* [PATCH] org-html.el: Fix export of table.el tables.
@ 2011-04-24 22:42 Jambunathan K
2011-04-24 22:47 ` Jambunathan K
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jambunathan K @ 2011-04-24 22:42 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-html.el.patch --]
[-- Type: text/x-patch, Size: 5823 bytes --]
From 3c8ff02efa0d2a4a08fe5341b9faa1de193048e9 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@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 "@>..<" 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* ((dim (table-query-dimension))
+ (c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
+ (not (= (* c r) cells))))
+ (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)))))
(defun org-export-splice-style (style extra)
"Splice EXTRA into STYLE, just before \"</style>\"."
@@ -2234,16 +2238,14 @@ If there are links in the string, don't modify these."
(let* ((re (concat org-bracket-link-regexp "\\|"
(org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
m s l res)
- (if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string)
- string
- (while (setq m (string-match re string))
- (setq s (substring string 0 m)
- l (match-string 0 string)
- string (substring string (match-end 0)))
- (push (org-html-do-expand s) res)
- (push l res))
- (push (org-html-do-expand string) res)
- (apply 'concat (nreverse res)))))
+ (while (setq m (string-match re string))
+ (setq s (substring string 0 m)
+ l (match-string 0 string)
+ string (substring string (match-end 0)))
+ (push (org-html-do-expand s) res)
+ (push l res))
+ (push (org-html-do-expand string) res)
+ (apply 'concat (nreverse res))))
(defun org-html-do-expand (s)
"Apply all active conversions to translate special ASCII to HTML."
--
1.7.2.3
[-- Attachment #3: table-export.org --]
[-- Type: text/plain, Size: 14183 bytes --]
* Table.el Table with no Spanning
# See org-export-prefer-native-exporter-for-tables
+---------------+---------------+
|Term |Percentage |
+---------------+---------------+
|Quarter |25% |
|One-Fourth | |
+---------------+---------------+
|Half |50% |
|One-by-Two | |
+---------------+---------------+
|Three-Quarters |75% |
|Three-Fourths | |
+---------------+---------------+
|Full |100% |
|Whole | |
+---------------+---------------+
* Table.el Table with Spanning
+----------+---------------------+----------+
|Name |cmd calls |Percentage|
+----------+ +----------+
|rgb |93 534 |46% |
+----------+ +----------+
|Xah |82 090 |40% |
+----------+ +----------+
|total |203 118 |100% |
+----------+---------------------+----------+
* Another Table.el Table with Spanning
+-----------+----------+
| R1C1 | R1C2 |
+-----------+----------+
| R2C1 R2C2 |
+-----------+----------+
| R3C1 | R3C2 |
| +----------+
| R4C1 | R4C2 |
+-----------+----------+
* buggy export (pre-patch)
** org-export-prefer-native-exporter-for-tables is nil
#+begin_src html
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Table.el Table with no Spanning </h2>
<div class="outline-text-2" id="text-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<tr><th scope="col">Term</th>
<th scope="col">Percentage</th></tr>
<tr><td>Quarter<br/>One-Fourth</td>
<td>25%<br/></td></tr>
<tr><td>Half<br/>One-by-Two</td>
<td>50%<br/></td></tr>
<tr><td>Three-Quarters<br/>Three-Fourths</td>
<td>75%<br/></td></tr>
<tr><td>Full<br/>Whole</td>
<td>100%<br/></td></tr>
</table>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Table.el Table with Spanning </h2>
<div class="outline-text-2" id="text-2">
<p>
<del>-———</del> <del>-———</del>
<del>-———</del> <del>-———</del>
<del>-———</del> <del>-———</del>
</p><table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<tr><th scope="col">Name<br/>rgb<br/>Xah<br/>total</th>
<th scope="col">cmd calls<br/>93 534<br/>82 090<br/>203 118</th>
<th scope="col">Percentage<br/>46%<br/>40%<br/>100%</th></tr>
</table>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Another Table.el Table with Spanning </h2>
<div class="outline-text-2" id="text-3">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<tr><th scope="col">R1C1</th>
<th scope="col">R1C2</th></tr>
<tr><td>R2C1 R2C2</td></tr>
<tr><td>R3C1<br/><del>-———</del><br/>R4C1</td>
<td>R3C2<br/><br/>R4C2</td></tr>
</table>
</div>
</div>
#+end_src
* correct export (post-patch)
** org-export-prefer-native-exporter-for-tables is t
#+begin_src html
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Table.el Table with no Spanning </h2>
<div class="outline-text-2" id="text-1">
<!-- This HTML table template is generated by emacs 24.0.50.1 -->
<table border="1">
<tr>
<td align="left" valign="top">
Term
</td>
<td align="left" valign="top">
Percentage
</td>
</tr>
<tr>
<td align="left" valign="top">
Quarter <br />
One-Fourth
</td>
<td align="left" valign="top">
25% <br />
</td>
</tr>
<tr>
<td align="left" valign="top">
Half <br />
One-by-Two
</td>
<td align="left" valign="top">
50% <br />
</td>
</tr>
<tr>
<td align="left" valign="top">
Three-Quarters <br />
Three-Fourths
</td>
<td align="left" valign="top">
75% <br />
</td>
</tr>
<tr>
<td align="left" valign="top">
Full <br />
Whole
</td>
<td align="left" valign="top">
100% <br />
</td>
</tr>
</table>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Table.el Table with Spanning </h2>
<div class="outline-text-2" id="text-2">
<!-- This HTML table template is generated by emacs 24.0.50.1 -->
<table border="1">
<tr>
<td align="left" valign="top">
Name
</td>
<td rowspan="4" align="left" valign="top">
cmd calls <br />
<br />
93 534 <br />
<br />
82 090 <br />
<br />
203 118
</td>
<td align="left" valign="top">
Percentage
</td>
</tr>
<tr>
<td align="left" valign="top">
rgb
</td>
<td align="left" valign="top">
46%
</td>
</tr>
<tr>
<td align="left" valign="top">
Xah
</td>
<td align="left" valign="top">
40%
</td>
</tr>
<tr>
<td align="left" valign="top">
total
</td>
<td align="left" valign="top">
100%
</td>
</tr>
</table>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Another Table.el Table with Spanning </h2>
<div class="outline-text-2" id="text-3">
<!-- This HTML table template is generated by emacs 24.0.50.1 -->
<table border="1">
<tr>
<td align="center" valign="top">
R1C1
</td>
<td align="center" valign="top">
R1C2
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="top">
R2C1 R2C2
</td>
</tr>
<tr>
<td rowspan="2" align="center" valign="top">
R3C1 <br />
<br />
R4C1
</td>
<td align="center" valign="top">
R3C2
</td>
</tr>
<tr>
<td align="center" valign="top">
R4C2
</td>
</tr>
</table>
</div>
</div>
#+end_src
** org-export-prefer-native-exporter-for-tables is nil
#+begin_src html
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Table.el Table with no Spanning </h2>
<div class="outline-text-2" id="text-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<tr><th scope="col">Term</th>
<th scope="col">Percentage</th></tr>
<tr><td>Quarter<br/>One-Fourth</td>
<td>25%<br/></td></tr>
<tr><td>Half<br/>One-by-Two</td>
<td>50%<br/></td></tr>
<tr><td>Three-Quarters<br/>Three-Fourths</td>
<td>75%<br/></td></tr>
<tr><td>Full<br/>Whole</td>
<td>100%<br/></td></tr>
</table>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Table.el Table with Spanning </h2>
<div class="outline-text-2" id="text-2">
<!-- This HTML table template is generated by emacs 24.0.50.1 -->
<table border="1">
<tr>
<td align="left" valign="top">
Name
</td>
<td rowspan="4" align="left" valign="top">
cmd calls <br />
<br />
93 534 <br />
<br />
82 090 <br />
<br />
203 118
</td>
<td align="left" valign="top">
Percentage
</td>
</tr>
<tr>
<td align="left" valign="top">
rgb
</td>
<td align="left" valign="top">
46%
</td>
</tr>
<tr>
<td align="left" valign="top">
Xah
</td>
<td align="left" valign="top">
40%
</td>
</tr>
<tr>
<td align="left" valign="top">
total
</td>
<td align="left" valign="top">
100%
</td>
</tr>
</table>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Another Table.el Table with Spanning </h2>
<div class="outline-text-2" id="text-3">
<!-- This HTML table template is generated by emacs 24.0.50.1 -->
<table border="1">
<tr>
<td align="center" valign="top">
R1C1
</td>
<td align="center" valign="top">
R1C2
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="top">
R2C1 R2C2
</td>
</tr>
<tr>
<td rowspan="2" align="center" valign="top">
R3C1 <br />
<br />
R4C1
</td>
<td align="center" valign="top">
R3C2
</td>
</tr>
<tr>
<td align="center" valign="top">
R4C2
</td>
</tr>
</table>
</div>
</div>
#+end_src
[-- Attachment #4: Type: text/plain, Size: 5 bytes --]
--
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] org-html.el: Fix export of table.el tables.
2011-04-24 22:42 [PATCH] org-html.el: Fix export of table.el tables Jambunathan K
@ 2011-04-24 22:47 ` Jambunathan K
2011-04-26 12:55 ` Manuel Giraud
2011-05-24 13:06 ` [Accepted] " Carsten Dominik
2 siblings, 0 replies; 7+ messages in thread
From: Jambunathan K @ 2011-04-24 22:47 UTC (permalink / raw)
To: emacs-orgmode
> 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.
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] org-html.el: Fix export of table.el tables.
2011-04-24 22:42 [PATCH] org-html.el: Fix export of table.el tables Jambunathan K
2011-04-24 22:47 ` Jambunathan K
@ 2011-04-26 12:55 ` Manuel Giraud
2011-04-26 12:57 ` Manuel Giraud
2011-05-24 13:06 ` [Accepted] " Carsten Dominik
2 siblings, 1 reply; 7+ messages in thread
From: Manuel Giraud @ 2011-04-26 12:55 UTC (permalink / raw)
To: Jambunathan K; +Cc: emacs-orgmode
Hi,
I've tried your patch and the output is prettier afterward. I'm not a
HTML tables expert but all those 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] org-html.el: Fix export of table.el tables.
2011-04-26 12:55 ` Manuel Giraud
@ 2011-04-26 12:57 ` Manuel Giraud
2011-04-26 13:49 ` Jambunathan K
0 siblings, 1 reply; 7+ messages in thread
From: Manuel Giraud @ 2011-04-26 12:57 UTC (permalink / raw)
To: Jambunathan K; +Cc: emacs-orgmode
Manuel Giraud <manuel.giraud@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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] org-html.el: Fix export of table.el tables.
2011-04-26 12:57 ` Manuel Giraud
@ 2011-04-26 13:49 ` Jambunathan K
2011-04-26 15:14 ` Manuel Giraud
0 siblings, 1 reply; 7+ messages in thread
From: Jambunathan K @ 2011-04-26 13:49 UTC (permalink / raw)
To: Manuel Giraud; +Cc: emacs-orgmode
Manuel Giraud <manuel.giraud@univ-nantes.fr> writes:
> Manuel Giraud <manuel.giraud@univ-nantes.fr> writes:
>
>> But AFAIU, with org-export-prefer-native-exporter-for-tables to nil,
>> simple table stays in HTML, no?
> ^^^^
> simple
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
 
2. org-export-prefer-native-exporter-for-tables => nil => Use Org's own
code generator => HTML *source code* is easy to look at.
If I consult my patch, I see that the outputs I have included for the
simple table.el table (with both the on/off options for
org-export-prefer-native-exporter-for-tables) is consistent with what is
set forth in the previous paragraph.
May be you are exporting a different table.el table? Can you post your
example? 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
It is possible that I have misunderstood how table-query-dimension API
works ...
Footnotes:
[1] http://patchwork.newartisans.com/patch/764/
Tip: Search for post-patch, Table.el Table with no Spanning,
org-export-prefer-native-exporter-for-tables
Jambunathan K.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] org-html.el: Fix export of table.el tables.
2011-04-26 13:49 ` Jambunathan K
@ 2011-04-26 15:14 ` Manuel Giraud
0 siblings, 0 replies; 7+ messages in thread
From: Manuel Giraud @ 2011-04-26 15:14 UTC (permalink / raw)
To: Jambunathan K; +Cc: emacs-orgmode
Jambunathan K <kjambunathan@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
>  
>
> 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 . 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Accepted] org-html.el: Fix export of table.el tables.
2011-04-24 22:42 [PATCH] org-html.el: Fix export of table.el tables Jambunathan K
2011-04-24 22:47 ` Jambunathan K
2011-04-26 12:55 ` Manuel Giraud
@ 2011-05-24 13:06 ` Carsten Dominik
2 siblings, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2011-05-24 13:06 UTC (permalink / raw)
To: emacs-orgmode
Patch 764 (http://patchwork.newartisans.com/patch/764/) is now "Accepted".
Maintainer comment: none
This relates to the following submission:
http://mid.gmane.org/%3C81hb9nclv4.fsf%40gmail.com%3E
Here is the original message containing the patch:
> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] org-html.el: Fix export of table.el tables.
> Date: Mon, 25 Apr 2011 03:42:23 -0000
> From: Jambunathan K <kjambunathan@gmail.com>
> X-Patchwork-Id: 764
> Message-Id: <81hb9nclv4.fsf@gmail.com>
> To: emacs-orgmode@gnu.org
>
> 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.
> * Table.el Table with no Spanning
> # See org-export-prefer-native-exporter-for-tables
>
> +---------------+---------------+
> |Term |Percentage |
> +---------------+---------------+
> |Quarter |25% |
> |One-Fourth | |
> +---------------+---------------+
> |Half |50% |
> |One-by-Two | |
> +---------------+---------------+
> |Three-Quarters |75% |
> |Three-Fourths | |
> +---------------+---------------+
> |Full |100% |
> |Whole | |
> +---------------+---------------+
>
> * Table.el Table with Spanning
>
> +----------+---------------------+----------+
> |Name |cmd calls |Percentage|
> +----------+ +----------+
> |rgb |93 534 |46% |
> +----------+ +----------+
> |Xah |82 090 |40% |
> +----------+ +----------+
> |total |203 118 |100% |
> +----------+---------------------+----------+
>
> * Another Table.el Table with Spanning
>
> +-----------+----------+
> | R1C1 | R1C2 |
> +-----------+----------+
> | R2C1 R2C2 |
> +-----------+----------+
> | R3C1 | R3C2 |
> | +----------+
> | R4C1 | R4C2 |
> +-----------+----------+
>
> * buggy export (pre-patch)
>
> ** org-export-prefer-native-exporter-for-tables is nil
>
> #+begin_src html
> <div id="outline-container-1" class="outline-2">
> <h2 id="sec-1"><span class="section-number-2">1</span> Table.el Table with no Spanning </h2>
> <div class="outline-text-2" id="text-1">
>
>
> <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
> <tr><th scope="col">Term</th>
> <th scope="col">Percentage</th></tr>
> <tr><td>Quarter<br/>One-Fourth</td>
> <td>25%<br/></td></tr>
> <tr><td>Half<br/>One-by-Two</td>
> <td>50%<br/></td></tr>
> <tr><td>Three-Quarters<br/>Three-Fourths</td>
> <td>75%<br/></td></tr>
> <tr><td>Full<br/>Whole</td>
> <td>100%<br/></td></tr>
> </table>
>
> </div>
>
> </div>
>
> <div id="outline-container-2" class="outline-2">
> <h2 id="sec-2"><span class="section-number-2">2</span> Table.el Table with Spanning </h2>
> <div class="outline-text-2" id="text-2">
>
>
> <p>
> <del>-———</del> <del>-———</del>
> <del>-———</del> <del>-———</del>
> <del>-———</del> <del>-———</del>
> </p><table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
> <tr><th scope="col">Name<br/>rgb<br/>Xah<br/>total</th>
> <th scope="col">cmd calls<br/>93 534<br/>82 090<br/>203 118</th>
> <th scope="col">Percentage<br/>46%<br/>40%<br/>100%</th></tr>
> </table>
>
> </div>
>
> </div>
>
> <div id="outline-container-3" class="outline-2">
> <h2 id="sec-3"><span class="section-number-2">3</span> Another Table.el Table with Spanning </h2>
> <div class="outline-text-2" id="text-3">
>
>
> <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
> <tr><th scope="col">R1C1</th>
> <th scope="col">R1C2</th></tr>
> <tr><td>R2C1 R2C2</td></tr>
> <tr><td>R3C1<br/><del>-———</del><br/>R4C1</td>
> <td>R3C2<br/><br/>R4C2</td></tr>
> </table>
> </div>
> </div>
> #+end_src
>
>
> * correct export (post-patch)
> ** org-export-prefer-native-exporter-for-tables is t
> #+begin_src html
> <div id="outline-container-1" class="outline-2">
> <h2 id="sec-1"><span class="section-number-2">1</span> Table.el Table with no Spanning </h2>
> <div class="outline-text-2" id="text-1">
>
>
> <!-- This HTML table template is generated by emacs 24.0.50.1 -->
> <table border="1">
> <tr>
> <td align="left" valign="top">
> Term
> </td>
> <td align="left" valign="top">
> Percentage
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> Quarter <br />
> One-Fourth
> </td>
> <td align="left" valign="top">
> 25% <br />
>
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> Half <br />
> One-by-Two
> </td>
> <td align="left" valign="top">
> 50% <br />
>
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> Three-Quarters <br />
> Three-Fourths
> </td>
> <td align="left" valign="top">
> 75% <br />
>
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> Full <br />
> Whole
> </td>
> <td align="left" valign="top">
> 100% <br />
>
> </td>
> </tr>
> </table>
>
> </div>
>
> </div>
>
> <div id="outline-container-2" class="outline-2">
> <h2 id="sec-2"><span class="section-number-2">2</span> Table.el Table with Spanning </h2>
> <div class="outline-text-2" id="text-2">
>
>
> <!-- This HTML table template is generated by emacs 24.0.50.1 -->
> <table border="1">
> <tr>
> <td align="left" valign="top">
> Name
> </td>
> <td rowspan="4" align="left" valign="top">
> cmd calls <br />
> <br />
> 93 534 <br />
> <br />
> 82 090 <br />
> <br />
> 203 118
> </td>
> <td align="left" valign="top">
> Percentage
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> rgb
> </td>
> <td align="left" valign="top">
> 46%
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> Xah
> </td>
> <td align="left" valign="top">
> 40%
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> total
> </td>
> <td align="left" valign="top">
> 100%
> </td>
> </tr>
> </table>
>
> </div>
>
> </div>
>
> <div id="outline-container-3" class="outline-2">
> <h2 id="sec-3"><span class="section-number-2">3</span> Another Table.el Table with Spanning </h2>
> <div class="outline-text-2" id="text-3">
>
>
> <!-- This HTML table template is generated by emacs 24.0.50.1 -->
> <table border="1">
> <tr>
> <td align="center" valign="top">
> R1C1
> </td>
> <td align="center" valign="top">
> R1C2
> </td>
> </tr>
> <tr>
> <td colspan="2" align="center" valign="top">
> R2C1 R2C2
> </td>
> </tr>
> <tr>
> <td rowspan="2" align="center" valign="top">
> R3C1 <br />
> <br />
> R4C1
> </td>
> <td align="center" valign="top">
> R3C2
> </td>
> </tr>
> <tr>
> <td align="center" valign="top">
> R4C2
> </td>
> </tr>
> </table>
> </div>
> </div>
> #+end_src
>
> ** org-export-prefer-native-exporter-for-tables is nil
>
> #+begin_src html
> <div id="outline-container-1" class="outline-2">
> <h2 id="sec-1"><span class="section-number-2">1</span> Table.el Table with no Spanning </h2>
> <div class="outline-text-2" id="text-1">
>
>
> <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
> <tr><th scope="col">Term</th>
> <th scope="col">Percentage</th></tr>
> <tr><td>Quarter<br/>One-Fourth</td>
> <td>25%<br/></td></tr>
> <tr><td>Half<br/>One-by-Two</td>
> <td>50%<br/></td></tr>
> <tr><td>Three-Quarters<br/>Three-Fourths</td>
> <td>75%<br/></td></tr>
> <tr><td>Full<br/>Whole</td>
> <td>100%<br/></td></tr>
> </table>
>
> </div>
>
> </div>
>
> <div id="outline-container-2" class="outline-2">
> <h2 id="sec-2"><span class="section-number-2">2</span> Table.el Table with Spanning </h2>
> <div class="outline-text-2" id="text-2">
>
>
> <!-- This HTML table template is generated by emacs 24.0.50.1 -->
> <table border="1">
> <tr>
> <td align="left" valign="top">
> Name
> </td>
> <td rowspan="4" align="left" valign="top">
> cmd calls <br />
> <br />
> 93 534 <br />
> <br />
> 82 090 <br />
> <br />
> 203 118
> </td>
> <td align="left" valign="top">
> Percentage
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> rgb
> </td>
> <td align="left" valign="top">
> 46%
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> Xah
> </td>
> <td align="left" valign="top">
> 40%
> </td>
> </tr>
> <tr>
> <td align="left" valign="top">
> total
> </td>
> <td align="left" valign="top">
> 100%
> </td>
> </tr>
> </table>
>
> </div>
>
> </div>
>
> <div id="outline-container-3" class="outline-2">
> <h2 id="sec-3"><span class="section-number-2">3</span> Another Table.el Table with Spanning </h2>
> <div class="outline-text-2" id="text-3">
>
>
> <!-- This HTML table template is generated by emacs 24.0.50.1 -->
> <table border="1">
> <tr>
> <td align="center" valign="top">
> R1C1
> </td>
> <td align="center" valign="top">
> R1C2
> </td>
> </tr>
> <tr>
> <td colspan="2" align="center" valign="top">
> R2C1 R2C2
> </td>
> </tr>
> <tr>
> <td rowspan="2" align="center" valign="top">
> R3C1 <br />
> <br />
> R4C1
> </td>
> <td align="center" valign="top">
> R3C2
> </td>
> </tr>
> <tr>
> <td align="center" valign="top">
> R4C2
> </td>
> </tr>
> </table>
> </div>
> </div>
> #+end_src
>
> ---
>
>
> >From 3c8ff02efa0d2a4a08fe5341b9faa1de193048e9 Mon Sep 17 00:00:00 2001
> From: Jambunathan K <kjambunathan@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 "@>..<" 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* ((dim (table-query-dimension))
> + (c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
> + (not (= (* c r) cells))))
> + (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)))))
>
> (defun org-export-splice-style (style extra)
> "Splice EXTRA into STYLE, just before \"</style>\"."
> @@ -2234,16 +2238,14 @@ If there are links in the string, don't modify these."
> (let* ((re (concat org-bracket-link-regexp "\\|"
> (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
> m s l res)
> - (if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string)
> - string
> - (while (setq m (string-match re string))
> - (setq s (substring string 0 m)
> - l (match-string 0 string)
> - string (substring string (match-end 0)))
> - (push (org-html-do-expand s) res)
> - (push l res))
> - (push (org-html-do-expand string) res)
> - (apply 'concat (nreverse res)))))
> + (while (setq m (string-match re string))
> + (setq s (substring string 0 m)
> + l (match-string 0 string)
> + string (substring string (match-end 0)))
> + (push (org-html-do-expand s) res)
> + (push l res))
> + (push (org-html-do-expand string) res)
> + (apply 'concat (nreverse res))))
>
> (defun org-html-do-expand (s)
> "Apply all active conversions to translate special ASCII to HTML."
> --
> 1.7.2.3
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-05-24 13:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-24 22:42 [PATCH] org-html.el: Fix export of table.el tables Jambunathan K
2011-04-24 22:47 ` Jambunathan K
2011-04-26 12:55 ` Manuel Giraud
2011-04-26 12:57 ` Manuel Giraud
2011-04-26 13:49 ` Jambunathan K
2011-04-26 15:14 ` Manuel Giraud
2011-05-24 13:06 ` [Accepted] " Carsten Dominik
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).