0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 11:32:51 +00:00

HTML export: Fix alignment bug

Patch by Stephen Peters.

Stephen writes:

> When creating a table, I was noticing that the
> <colgroup><col>... provides useful alignment information based on
> whether or not the column has numbers in it.  I think, however, that
> there is a mistake in this routine.  Take, for example, the following
> table:
>
> |  Id | Task         | Developer | Estimate | Spent | Remaining | Comp.% | Updated         |
> |-----+--------------+-----------+----------+-------+-----------+--------+-----------------|
> |   1 | Task One     | SLP       |        1 |     0 |         1 |      0 | SLP, 2010-04-27 |
> |   2 | Task Two     | SLP       |        1 |     0 |         1 |      0 | SLP, 2010-04-27 |
> |   3 | Task Three   | SLP       |        2 |     0 |         2 |      0 | SLP, 2010-04-27 |
> |   4 | Task Four    | SLP       |        2 |     0 |         2 |      0 | SLP, 2010-04-27 |
> |   5 | Task Five    | SLP       |      .25 |     0 |      0.25 |      0 | SLP, 2010-04-27 |
> | 5.1 | Another Task | XML team  |        0 |     1 |         0 |      0 | SLP, 2010-04-27 |
> |   6 | Task Six     | SLP       |      .25 |     0 |      0.25 |      0 | SLP, 2010-04-27 |
> | 6.1 | More Tasks   | DB team   |        3 |     0 |         3 |      0 | SLP, 2010-04-27 |
> |   7 | Task Seven   | SLP       |        3 |     0 |         3 |      0 | SLP, 2010-04-27 |
>
> When the colgroup list is created for this table, it reads:
>
> <colgroup><col align="right" /><col align="left" /><col align="left" /><col align="right" /><col align="right" /><col align="left" /><col align="left" /><col align="left" />
> </colgroup>
>
> Note that the first columns are correct, but the last few are not.  It
> should read right, left, left, right, right, right, right, left.
>
> I believe that this is due to the (< i nline) comparison within
> org-format-org-table-html, which is nonsensical because it's trying to
> compare a column number with a number of rows.  I've attached a patch
> for the problem.
This commit is contained in:
Carsten Dominik 2010-04-29 15:01:10 +02:00
parent 7d6013dc41
commit ef51006a8f
2 changed files with 9 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2010-04-29 Carsten Dominik <carsten.dominik@gmail.com>
* org-html.el (org-format-org-table-html): Test all columns
for number content.
2010-04-28 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-treat-sub-super-char): Make

View file

@ -1633,7 +1633,7 @@ lang=\"%s\" xml:lang=\"%s\">
(lambda (x) (string-match "^[ \t]*|-" x))
(cdr lines)))))
(nline 0) fnum i
(nline 0) fnum nfields i
tbopen line fields html gr colgropen rowstart rowend)
(setq caption (and caption (org-html-do-expand caption)))
(if splice (setq head nil))
@ -1651,7 +1651,8 @@ lang=\"%s\" xml:lang=\"%s\">
(throw 'next-line t)))
;; Break the line into fields
(setq fields (org-split-string line "[ \t]*|[ \t]*"))
(unless fnum (setq fnum (make-vector (length fields) 0)))
(unless fnum (setq fnum (make-vector (length fields) 0)
nfields (length fnum)))
(setq nline (1+ nline) i -1
rowstart (eval (car org-export-table-row-tags))
rowend (eval (cdr org-export-table-row-tags)))
@ -1659,7 +1660,7 @@ lang=\"%s\" xml:lang=\"%s\">
(mapconcat
(lambda (x)
(setq i (1+ i))
(if (and (< i nline)
(if (and (< i nfields) ; make sure no rogue line causes an error here
(string-match org-table-number-regexp x))
(incf (aref fnum i)))
(cond