forked from mirrors/org-mode
Parse and store both col align and col width spec for later use
* lisp/org-exp.el (org-store-forced-table-alignment): Parse the column cookie for both alignment and width specification. Store the resulting value in `org-col-cookies' property. Retire the previously used `org-forced-aligns' property for consistency. Renamed local variable `aligns' to `cookies'. * lisp/org-html.el (org-format-org-table-html): Use `org-col-cookies'. Renamed local variable forced-aligns to col-cookies. This is a preparatory patch. A backend can look at the colwidth specification and (at it's discretion) use it to control relative sizes of individual columns in a table. At this moment, it is unclear whether the widths used to control the display of table in Org buffer can be overloaded to also control the formatting of table in a backend. Refer following discussion with Matt Price: http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg01053.html
This commit is contained in:
parent
4f2f222c00
commit
2e93c951e5
|
@ -2002,23 +2002,28 @@ When it is nil, all comments will be removed."
|
|||
|
||||
(defun org-store-forced-table-alignment ()
|
||||
"Find table lines which force alignment, store the results in properties."
|
||||
(let (line cnt aligns)
|
||||
(let (line cnt cookies)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "|[ \t]*<[lrc][0-9]*>[ \t]*|" nil t)
|
||||
(while (re-search-forward "|[ \t]*<\\([lrc]?[0-9]+\\|[lrc]\\)>[ \t]*|"
|
||||
nil t)
|
||||
;; OK, this looks like a table line with an alignment cookie
|
||||
(org-if-unprotected
|
||||
(setq line (buffer-substring (point-at-bol) (point-at-eol)))
|
||||
(when (and (org-at-table-p)
|
||||
(org-table-cookie-line-p line))
|
||||
(setq cnt 0 aligns nil)
|
||||
(setq cnt 0 cookies nil)
|
||||
(mapc
|
||||
(lambda (x)
|
||||
(setq cnt (1+ cnt))
|
||||
(if (string-match "\\`<\\([lrc]\\)" x)
|
||||
(push (cons cnt (downcase (match-string 1 x))) aligns)))
|
||||
(when (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'" x)
|
||||
(let ((align (and (match-end 1)
|
||||
(downcase (match-string 1 x))))
|
||||
(width (and (match-end 2)
|
||||
(string-to-number (match-string 2 x)))))
|
||||
(push (cons cnt (list align width)) cookies))))
|
||||
(org-split-string line "[ \t]*|[ \t]*"))
|
||||
(add-text-properties (org-table-begin) (org-table-end)
|
||||
(list 'org-forced-aligns aligns))))
|
||||
(list 'org-col-cookies cookies))))
|
||||
(goto-char (point-at-eol)))))
|
||||
|
||||
(defun org-export-remove-special-table-lines ()
|
||||
|
|
|
@ -1980,8 +1980,8 @@ for formatting. This is required for the DocBook exporter."
|
|||
|
||||
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
|
||||
(label (org-find-text-property-in-string 'org-label (car lines)))
|
||||
(forced-aligns (org-find-text-property-in-string 'org-forced-aligns
|
||||
(car lines)))
|
||||
(col-cookies (org-find-text-property-in-string 'org-col-cookies
|
||||
(car lines)))
|
||||
(attributes (org-find-text-property-in-string 'org-attributes
|
||||
(car lines)))
|
||||
(html-table-tag (org-export-splice-attributes
|
||||
|
@ -1994,9 +1994,9 @@ for formatting. This is required for the DocBook exporter."
|
|||
tbopen line fields html gr colgropen rowstart rowend
|
||||
ali align aligns n)
|
||||
(setq caption (and caption (org-html-do-expand caption)))
|
||||
(when (and forced-aligns org-table-clean-did-remove-column)
|
||||
(setq forced-aligns
|
||||
(mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns)))
|
||||
(when (and col-cookies org-table-clean-did-remove-column)
|
||||
(setq col-cookies
|
||||
(mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies)))
|
||||
(if splice (setq head nil))
|
||||
(unless splice (push (if head "<thead>" "<tbody>") html))
|
||||
(setq tbopen t)
|
||||
|
@ -2057,8 +2057,8 @@ for formatting. This is required for the DocBook exporter."
|
|||
(lambda (x)
|
||||
(setq gr (pop org-table-colgroup-info)
|
||||
i (1+ i)
|
||||
align (if (assoc i forced-aligns)
|
||||
(cdr (assoc (cdr (assoc i forced-aligns))
|
||||
align (if (nth 1 (assoc i col-cookies))
|
||||
(cdr (assoc (nth 1 (assoc i col-cookies))
|
||||
'(("l" . "left") ("r" . "right")
|
||||
("c" . "center"))))
|
||||
(if (> (/ (float x) nline)
|
||||
|
|
Loading…
Reference in New Issue