ox-html: Fix org-html-table-row wrt lexical binding
* lisp/ox-html.el (org-html-table-row-open-tag): (org-html-table-row-close-tag): New variables. (org-html-table-row-tags): Remove variable. (org-html-table-row): Use new variables.
This commit is contained in:
parent
cd9856cc76
commit
6af83e0aa7
10
etc/ORG-NEWS
10
etc/ORG-NEWS
|
@ -248,10 +248,12 @@ plain list.
|
||||||
fixltx2e is obsolete, see LaTeX News 22.
|
fixltx2e is obsolete, see LaTeX News 22.
|
||||||
** Miscellaneous
|
** Miscellaneous
|
||||||
*** Beamer export back-ends uses ~org-latex-prefer-user-labels~
|
*** Beamer export back-ends uses ~org-latex-prefer-user-labels~
|
||||||
|
|
||||||
*** ~:preparation-function~ called earlier during publishing
|
*** ~:preparation-function~ called earlier during publishing
|
||||||
Functions in this list are called before any file is associated to the
|
Functions in this list are called before any file is associated to the
|
||||||
current projet. Thus, they can be used to generate to be published
|
current projet. Thus, they can be used to generate to be published
|
||||||
Org files.
|
Org files.
|
||||||
|
|
||||||
*** Function ~org-remove-indentation~ changes.
|
*** Function ~org-remove-indentation~ changes.
|
||||||
The new algorithm doesn't remove TAB characters not used for
|
The new algorithm doesn't remove TAB characters not used for
|
||||||
indentation.
|
indentation.
|
||||||
|
@ -267,12 +269,20 @@ Note that only ~%(...)~ placeholders initially present in the
|
||||||
template, or introduced using a file placeholder, i.e., ~%[...]~ are
|
template, or introduced using a file placeholder, i.e., ~%[...]~ are
|
||||||
expanded. This prevents evaluating potentially malicious code when
|
expanded. This prevents evaluating potentially malicious code when
|
||||||
another placeholder, e.g., ~%i~ expands to a S-exp.
|
another placeholder, e.g., ~%i~ expands to a S-exp.
|
||||||
|
|
||||||
*** Links stored by ~org-gnus-store-link~ in nnir groups
|
*** Links stored by ~org-gnus-store-link~ in nnir groups
|
||||||
Since gnus nnir groups are temporary, ~org-gnus-store-link~ now refers
|
Since gnus nnir groups are temporary, ~org-gnus-store-link~ now refers
|
||||||
to the article's original group.
|
to the article's original group.
|
||||||
|
|
||||||
*** ~org-babel-check-confirm-evaluate~ is now a function instead of a macro
|
*** ~org-babel-check-confirm-evaluate~ is now a function instead of a macro
|
||||||
The calling convention has changed.
|
The calling convention has changed.
|
||||||
|
|
||||||
|
*** HTML export table row customization changes
|
||||||
|
Variable ~org-html-table-row-tags~ has been split into
|
||||||
|
~org-html-table-row-open-tag~ and ~org-html-table-row-close-tag~.
|
||||||
|
Both new variables can be either a string or a function which will be
|
||||||
|
called with 6 parameters.
|
||||||
|
|
||||||
* Version 8.3
|
* Version 8.3
|
||||||
|
|
||||||
** Incompatible changes
|
** Incompatible changes
|
||||||
|
|
121
lisp/ox-html.el
121
lisp/ox-html.el
|
@ -170,7 +170,8 @@
|
||||||
(:html-viewport nil nil org-html-viewport)
|
(:html-viewport nil nil org-html-viewport)
|
||||||
(:html-inline-images nil nil org-html-inline-images)
|
(:html-inline-images nil nil org-html-inline-images)
|
||||||
(:html-table-attributes nil nil org-html-table-default-attributes)
|
(:html-table-attributes nil nil org-html-table-default-attributes)
|
||||||
(:html-table-row-tags nil nil org-html-table-row-tags)
|
(:html-table-row-open-tag nil nil org-html-table-row-open-tag)
|
||||||
|
(:html-table-row-close-tag nil nil org-html-table-row-close-tag)
|
||||||
(:html-xml-declaration nil nil org-html-xml-declaration)
|
(:html-xml-declaration nil nil org-html-xml-declaration)
|
||||||
(:infojs-opt "INFOJS_OPT" nil nil)
|
(:infojs-opt "INFOJS_OPT" nil nil)
|
||||||
;; Redefine regular options.
|
;; Redefine regular options.
|
||||||
|
@ -859,43 +860,50 @@ See also the variable `org-html-table-align-individual-fields'."
|
||||||
:group 'org-export-html
|
:group 'org-export-html
|
||||||
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
|
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
|
||||||
|
|
||||||
(defcustom org-html-table-row-tags '("<tr>" . "</tr>")
|
(defcustom org-html-table-row-open-tag "<tr>"
|
||||||
"The opening and ending tags for table rows.
|
"The opening tag for table rows.
|
||||||
This is customizable so that alignment options can be specified.
|
This is customizable so that alignment options can be specified.
|
||||||
Instead of strings, these can be Lisp forms that will be
|
Instead of strings, these can be a Lisp function that will be
|
||||||
evaluated for each row in order to construct the table row tags.
|
evaluated for each row in order to construct the table row tags.
|
||||||
|
|
||||||
During evaluation, these variables will be dynamically bound so that
|
The function will be called with these arguments:
|
||||||
you can reuse them:
|
|
||||||
|
|
||||||
`row-number': row number (0 is the first row)
|
`number': row number (0 is the first row)
|
||||||
`rowgroup-number': group number of current row
|
`group-number': group number of current row
|
||||||
`start-rowgroup-p': non-nil means the row starts a group
|
`start-group-p': non-nil means the row starts a group
|
||||||
`end-rowgroup-p': non-nil means the row ends a group
|
`end-group-p': non-nil means the row ends a group
|
||||||
`top-row-p': non-nil means this is the top row
|
`topp': non-nil means this is the top row
|
||||||
`bottom-row-p': non-nil means this is the bottom row
|
`bottomp': non-nil means this is the bottom row
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
\(setq org-html-table-row-tags
|
\(setq org-html-table-row-open-tag
|
||||||
(cons \\='(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
|
\(lambda (number group-number start-group-p end-group-p topp bottomp)
|
||||||
(bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
|
\(cond (topp \"<tr class=\\\"tr-top\\\">\")
|
||||||
(t (if (= (mod row-number 2) 1)
|
\(bottomp \"<tr class=\\\"tr-bottom\\\">\")
|
||||||
\"<tr class=\\\"tr-odd\\\">\"
|
\(t (if (= (mod number 2) 1)
|
||||||
\"<tr class=\\\"tr-even\\\">\")))
|
\"<tr class=\\\"tr-odd\\\">\"
|
||||||
\"</tr>\"))
|
\"<tr class=\\\"tr-even\\\">\")))))
|
||||||
|
|
||||||
will use the \"tr-top\" and \"tr-bottom\" classes for the top row
|
will use the \"tr-top\" and \"tr-bottom\" classes for the top row
|
||||||
and the bottom row, and otherwise alternate between \"tr-odd\" and
|
and the bottom row, and otherwise alternate between \"tr-odd\" and
|
||||||
\"tr-even\" for odd and even rows."
|
\"tr-even\" for odd and even rows."
|
||||||
:group 'org-export-html
|
:group 'org-export-html
|
||||||
:type '(cons
|
:type '(choice :tag "Opening tag"
|
||||||
(choice :tag "Opening tag"
|
(string :tag "Specify")
|
||||||
(string :tag "Specify")
|
(function)))
|
||||||
(sexp))
|
|
||||||
(choice :tag "Closing tag"
|
(defcustom org-html-table-row-close-tag "</tr>"
|
||||||
(string :tag "Specify")
|
"The closing tag for table rows.
|
||||||
(sexp))))
|
This is customizable so that alignment options can be specified.
|
||||||
|
Instead of strings, this can be a Lisp function that will be
|
||||||
|
evaluated for each row in order to construct the table row tags.
|
||||||
|
|
||||||
|
See documentation of `org-html-table-row-open-tag'."
|
||||||
|
:group 'org-export-html
|
||||||
|
:type '(choice :tag "Closing tag"
|
||||||
|
(string :tag "Specify")
|
||||||
|
(function)))
|
||||||
|
|
||||||
(defcustom org-html-table-align-individual-fields t
|
(defcustom org-html-table-align-individual-fields t
|
||||||
"Non-nil means attach style attributes for alignment to each table field.
|
"Non-nil means attach style attributes for alignment to each table field.
|
||||||
|
@ -3302,42 +3310,45 @@ communication channel."
|
||||||
;; Rules are ignored since table separators are deduced from
|
;; Rules are ignored since table separators are deduced from
|
||||||
;; borders of the current row.
|
;; borders of the current row.
|
||||||
(when (eq (org-element-property :type table-row) 'standard)
|
(when (eq (org-element-property :type table-row) 'standard)
|
||||||
(let* ((rowgroup-number (org-export-table-row-group table-row info))
|
(let* ((group (org-export-table-row-group table-row info))
|
||||||
(row-number (org-export-table-row-number table-row info))
|
(number (org-export-table-row-number table-row info))
|
||||||
(start-rowgroup-p
|
(start-group-p
|
||||||
(org-export-table-row-starts-rowgroup-p table-row info))
|
(org-export-table-row-starts-rowgroup-p table-row info))
|
||||||
(end-rowgroup-p
|
(end-group-p
|
||||||
(org-export-table-row-ends-rowgroup-p table-row info))
|
(org-export-table-row-ends-rowgroup-p table-row info))
|
||||||
;; `top-row-p' and `end-rowgroup-p' are not used directly
|
(topp (and (equal start-group-p '(top))
|
||||||
;; but should be set so that `org-html-table-row-tags' can
|
(equal end-group-p '(below top))))
|
||||||
;; use them (see the docstring of this variable.)
|
(bottomp (and (equal start-group-p '(above))
|
||||||
(top-row-p (and (equal start-rowgroup-p '(top))
|
(equal end-group-p '(bottom above))))
|
||||||
(equal end-rowgroup-p '(below top))))
|
(row-open-tag
|
||||||
(bottom-row-p (and (equal start-rowgroup-p '(above))
|
(pcase (plist-get info :html-table-row-open-tag)
|
||||||
(equal end-rowgroup-p '(bottom above))))
|
((and accessor (pred functionp))
|
||||||
(rowgroup-tags
|
(funcall accessor
|
||||||
|
number group start-group-p end-group-p topp bottomp))
|
||||||
|
(accessor accessor)))
|
||||||
|
(row-close-tag
|
||||||
|
(pcase (plist-get info :html-table-row-close-tag)
|
||||||
|
((and accessor (pred functionp))
|
||||||
|
(funcall accessor
|
||||||
|
number group start-group-p end-group-p topp bottomp))
|
||||||
|
(accessor accessor)))
|
||||||
|
(group-tags
|
||||||
(cond
|
(cond
|
||||||
;; Case 1: Row belongs to second or subsequent rowgroups.
|
;; Row belongs to second or subsequent groups.
|
||||||
((not (= 1 rowgroup-number))
|
((not (= 1 group)) '("<tbody>" . "\n</tbody>"))
|
||||||
'("<tbody>" . "\n</tbody>"))
|
;; Row is from first group. Table has >=1 groups.
|
||||||
;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
|
|
||||||
((org-export-table-has-header-p
|
((org-export-table-has-header-p
|
||||||
(org-export-get-parent-table table-row) info)
|
(org-export-get-parent-table table-row) info)
|
||||||
'("<thead>" . "\n</thead>"))
|
'("<thead>" . "\n</thead>"))
|
||||||
;; Case 2: Row is from first and only row group.
|
;; Row is from first and only group.
|
||||||
(t '("<tbody>" . "\n</tbody>")))))
|
(t '("<tbody>" . "\n</tbody>")))))
|
||||||
;; Silence byte-compiler.
|
(concat (and start-group-p (car group-tags))
|
||||||
bottom-row-p top-row-p row-number
|
(concat "\n"
|
||||||
(concat
|
row-open-tag
|
||||||
;; Begin a rowgroup?
|
contents
|
||||||
(when start-rowgroup-p (car rowgroup-tags))
|
"\n"
|
||||||
;; Actual table row.
|
row-close-tag)
|
||||||
(concat "\n" (eval (car (plist-get info :html-table-row-tags)) t)
|
(and end-group-p (cdr group-tags))))))
|
||||||
contents
|
|
||||||
"\n"
|
|
||||||
(eval (cdr (plist-get info :html-table-row-tags)) t))
|
|
||||||
;; End a rowgroup?
|
|
||||||
(when end-rowgroup-p (cdr rowgroup-tags))))))
|
|
||||||
|
|
||||||
;;;; Table
|
;;;; Table
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue