Browse Source

HTML export: Fix problems with colgroup tags

Special lines with <, >, and <> in tables should trigger colgroup tags.
Carsten Dominik 15 years ago
parent
commit
d56f2f4fa5
2 changed files with 24 additions and 12 deletions
  1. 4 0
      lisp/ChangeLog
  2. 20 12
      lisp/org-html.el

+ 4 - 0
lisp/ChangeLog

@@ -1,3 +1,7 @@
+2009-07-26  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-html.el (org-format-org-table-html): Fix colgroup tags.
+
 2009-07-23  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org.el (org-cycle-internal-local): Improved version of finding

+ 20 - 12
lisp/org-html.el

@@ -1624,19 +1624,27 @@ lang=\"%s\" xml:lang=\"%s\">
     (unless splice (push "</table>\n" html))
     (setq html (nreverse html))
     (unless splice
-      ;; Put in col tags with the alignment (unfortunately often ignored...)
-      (push (concat
-	     "<colgroup>"
-	     (mapconcat
-	      (lambda (x)
-		(setq gr (pop org-table-colgroup-info))
-		(format "<col align=\"%s\" />"
-			(if (> (/ (float x) nline) org-table-number-fraction)
-			    "right" "left")))
-	      fnum "")
-	     "</colgroup>")
+      ;; Put in col tags with the alignment (unfortuntely often ignored...)
+      (unless (car org-table-colgroup-info)
+	(setq org-table-colgroup-info
+	      (cons :start (cdr org-table-colgroup-info))))
+      (push (mapconcat
+	     (lambda (x)
+	       (setq gr (pop org-table-colgroup-info))
+	       (format "%s<col align=\"%s\"></col>%s"
+		       (if (memq gr '(:start :startend))
+			   (prog1
+			       (if colgropen "</colgroup>\n<colgroup>" "<colgroup>")
+			     (setq colgropen t))
+			 "")
+		       (if (> (/ (float x) nline) org-table-number-fraction)
+			   "right" "left")
+		       (if (memq gr '(:end :startend))
+			   (progn (setq colgropen nil) "</colgroup>")
+			 "")))
+	     fnum "")
 	    html)
-
+      (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html)))))
       ;; Since the output of HTML table formatter can also be used in
       ;; DocBook document, we want to always include the caption to make
       ;; DocBook XML file valid.