forked from mirrors/org-mode
HTML export: Make better use of labels
This commit is contained in:
parent
313f01d297
commit
aed051cf8c
|
@ -1,3 +1,7 @@
|
|||
2010-03-29 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (Images and tables): Document how to reference labels.
|
||||
|
||||
2010-03-28 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.texi (Index entries): New section.
|
||||
|
|
|
@ -8418,7 +8418,8 @@ Both the native Org mode tables (@pxref{Tables}) and tables formatted with
|
|||
the @file{table.el} package will be exported properly. For Org mode tables,
|
||||
the lines before the first horizontal separator line will become table header
|
||||
lines. You can use the following lines somewhere before the table to assign
|
||||
a caption and a label for cross references:
|
||||
a caption and a label for cross references, and in the text you can refer to
|
||||
the object with @code{\ref@{tab:basic-data@}}:
|
||||
|
||||
@example
|
||||
#+CAPTION: This is the caption for the next table (or link)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
2010-03-29 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-html.el (org-export-html-preprocess): Replace \ref macros
|
||||
with a link.
|
||||
(org-format-org-table-html): Add the label as an anchor.
|
||||
|
||||
* org-docbook.el (org-export-docbook-format-image): Do some
|
||||
formatting on captions.
|
||||
|
||||
|
|
|
@ -434,7 +434,16 @@ This may also be a function, building and inserting the postamble.")
|
|||
(file-name-nondirectory
|
||||
org-current-export-file)))
|
||||
org-current-export-dir nil "Creating LaTeX image %s"))
|
||||
(message "Exporting..."))
|
||||
(goto-char (point-min))
|
||||
(let (label l1)
|
||||
(while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
|
||||
(org-if-unprotected-at (match-beginning 1)
|
||||
(setq label (match-string 1))
|
||||
(save-match-data
|
||||
(if (string-match "\\`[a-z]\\{1,10\\}:\\(.+\\)" label)
|
||||
(setq l1 (substring label (match-beginning 1)))
|
||||
(setq l1 label)))
|
||||
(replace-match (format "[[#%s][l1]]" label l1) t t)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-export-as-html-and-open (arg)
|
||||
|
@ -1600,16 +1609,10 @@ lang=\"%s\" xml:lang=\"%s\">
|
|||
;; column and the special lines
|
||||
(setq lines (org-table-clean-before-export lines)))
|
||||
|
||||
(let* ((caption (or (get-text-property 0 'org-caption (car lines))
|
||||
(get-text-property (or (next-single-property-change
|
||||
0 'org-caption (car lines))
|
||||
0)
|
||||
'org-caption (car lines))))
|
||||
(attributes (or (get-text-property 0 'org-attributes (car lines))
|
||||
(get-text-property (or (next-single-property-change
|
||||
0 'org-attributes (car lines))
|
||||
0)
|
||||
'org-attributes (car lines))))
|
||||
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
|
||||
(label (org-find-text-property-in-string 'org-label (car lines)))
|
||||
(attributes (org-find-text-property-in-string 'org-attributes
|
||||
(car lines)))
|
||||
(html-table-tag (org-export-splice-attributes
|
||||
html-table-tag attributes))
|
||||
(head (and org-export-highlight-first-table-line
|
||||
|
@ -1692,6 +1695,8 @@ lang=\"%s\" xml:lang=\"%s\">
|
|||
;; DocBook document, we want to always include the caption to make
|
||||
;; DocBook XML file valid.
|
||||
(push (format "<caption>%s</caption>" (or caption "")) html)
|
||||
(when label (push (format "<a name=\"%s\" id=\"%s\"></a>" label label)
|
||||
html))
|
||||
(push html-table-tag html))
|
||||
(concat (mapconcat 'identity html "\n") "\n")))
|
||||
|
||||
|
|
Loading…
Reference in New Issue