comparison lisp/org/org-exp.el @ 100448:cea079b68b76

2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-refile): Avoid refiling to within the region to be refiled. * org-export-latex.el (org-export-latex-special-chars): Replace special characters also in tables. * org-agenda.el (org-agenda-change-all-lines): New argument FORCE-TAGS. (org-agenda-set-tags): Cet the new tags and pas them to `org-format-agenda-item'. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-classes): Add longable as a default package to all classes. (org-export-latex-tables): Handle the longtable attribute and the align attribute. * org-table.el (orgtbl-to-generic): Handle tables that start with a hline. * org-export-latex.el (org-export-latex-emphasis-alist): Switch to \verb for colde-like snippets. (org-export-as-latex): Fix issues with region export. * org.el (org-up-heading-safe): Speed up function by using a direct regexp search. (org-olpa): New variable. (org-get-outline-path): Speed-up path constructions in cases where this is possible because the entire hierarchy is scanned anyway. (org-refile-get-location): Don't compare the truenames of files, this is too slow. (org-goto-max-level): New option. (org-goto): Use `org-goto-max-level'. 2008-12-16 Tassilo Horn <tassilo@member.fsf.org> * org-gnus.el (org-gnus-article-link, org-gnus-article-link): Strip angle brackets from message-ids in the former and don't do it in the latter. (org-gnus-follow-link): Open summary reliable, even if the last messages were deleted, and handle empty groups, too. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-emphasis-alist): Use \verb instead of \texttt for the =...= and ~===~ emphasis environments. (org-export-as-latex): Remove any old :org-license-to-kill text properties. (org-export-as-latex): Pass RBEG to `org-export-latex-first-lines'. (org-export-latex-make-header): Add some hard space after the table of contents. (org-export-latex-first-lines): Accept RBEG argument. Mark exported text so that it will be excuded in further steps. * org-table.el (org-table-get-specials): Make @0 reference the last line in a table. (org-table-recalculate): Improve docstring. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-log-done): Fix docstring. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-format-image): Fix bugs. * org-export-latex.el (org-export-latex-tables) (org-export-latex-links): Implement attribute, label, and caption handling. * org-exp.el (org-export-html-style-default): Add style definitions for the figure div. (org-export-preprocess-string, org-export-as-html): Implement attribute, label, and caption handling. (org-export-attach-captions-and-attributes): New function. (org-export-html-format-image): New function. (org-format-org-table-html): Implement attribute, label, and caption handling. * org.el (org-find-text-property-in-string): New function. (org-extract-attributes): Use the property org-attr instead of org-attrobutes, because this property is now set with the #+ATTR lines. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-substring-no-properties): Fix for XEmacs, for the case that FROM is nil. * org.el (org-before-first-heading-p): New function. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-as-html): Do not add a space before enforces line breaks. (org-export-as-html): Close paragraph before blockquote and verse tags. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-id.el (org-id-locations-file): Wrap file name with `convert-standard-filename'. (org-id-files): New variable. (org-id-use-hash): New option. (org-id-update-id-locations): Also search in all files current listed in `org-id-files'. Convert the resulting alist to a hash if the user customation says so. (org-id-locations-save): Handle he case if `org-id-locations' is a hash. (org-id-locations-load): Convert the alist to a hash. (org-id-add-location): Handle the hast case. (kill-emacs-hook): Make sure id locations are saved when Emacs is exited. (org-id-hash-to-alist, org-id-alist-to-hash) (org-id-paste-tracker): New functions.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 16 Dec 2008 13:28:37 +0000
parents 032aa24b2125
children ba23e35d3eaf
comparison
equal deleted inserted replaced
100447:f84c0729a0e9 100448:cea079b68b76
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5 ;; Author: Carsten Dominik <carsten at orgmode dot org> 5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Keywords: outlines, hypermedia, calendar, wp 6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage: http://orgmode.org 7 ;; Homepage: http://orgmode.org
8 ;; Version: 6.14 8 ;; Version: 6.15a
9 ;; 9 ;;
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 ;; 11 ;;
12 ;; GNU Emacs is free software: you can redistribute it and/or modify 12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
543 overflow:auto; 543 overflow:auto;
544 } 544 }
545 table { border-collapse: collapse; } 545 table { border-collapse: collapse; }
546 td, th { vertical-align: top; } 546 td, th { vertical-align: top; }
547 dt { font-weight: bold; } 547 dt { font-weight: bold; }
548 548 div.figure { padding: 0.5em; }
549 div.figure p { text-align: center; }
549 .org-info-js_info-navigation { border-style:none; } 550 .org-info-js_info-navigation { border-style:none; }
550 #org-info-js_console-label { font-size:10px; font-weight:bold; 551 #org-info-js_console-label { font-size:10px; font-weight:bold;
551 white-space:nowrap; } 552 white-space:nowrap; }
552 .org-info-js_search-highlight {background-color:#ffff00; color:#000000; 553 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
553 font-weight:bold; } 554 font-weight:bold; }
1430 on this string to produce the exported version." 1431 on this string to produce the exported version."
1431 (interactive) 1432 (interactive)
1432 (let* ((htmlp (plist-get parameters :for-html)) 1433 (let* ((htmlp (plist-get parameters :for-html))
1433 (asciip (plist-get parameters :for-ascii)) 1434 (asciip (plist-get parameters :for-ascii))
1434 (latexp (plist-get parameters :for-LaTeX)) 1435 (latexp (plist-get parameters :for-LaTeX))
1436 (backend (cond (htmlp 'html) (latexp 'latex) (asciip 'ascii)))
1437
1435 (archived-trees (plist-get parameters :archived-trees)) 1438 (archived-trees (plist-get parameters :archived-trees))
1436 (inhibit-read-only t) 1439 (inhibit-read-only t)
1437 (drawers org-drawers) 1440 (drawers org-drawers)
1438 (outline-regexp "\\*+ ") 1441 (outline-regexp "\\*+ ")
1439 target-alist rtn) 1442 target-alist rtn)
1463 (org-export-handle-export-tags (plist-get parameters :select-tags) 1466 (org-export-handle-export-tags (plist-get parameters :select-tags)
1464 (plist-get parameters :exclude-tags)) 1467 (plist-get parameters :exclude-tags))
1465 1468
1466 ;; Handle source code snippets 1469 ;; Handle source code snippets
1467 (org-export-replace-src-segments) 1470 (org-export-replace-src-segments)
1471
1472 ;; Find all headings and compute the targets for them
1473 (setq target-alist (org-export-define-heading-targets target-alist))
1468 1474
1469 ;; Get rid of drawers 1475 ;; Get rid of drawers
1470 (org-export-remove-or-extract-drawers drawers 1476 (org-export-remove-or-extract-drawers drawers
1471 (plist-get parameters :drawers)) 1477 (plist-get parameters :drawers))
1472 1478
1485 (org-export-remove-archived-trees archived-trees) 1491 (org-export-remove-archived-trees archived-trees)
1486 1492
1487 ;; Remove todo-keywords before exporting, if the user has requested so 1493 ;; Remove todo-keywords before exporting, if the user has requested so
1488 (org-export-remove-headline-metadata parameters) 1494 (org-export-remove-headline-metadata parameters)
1489 1495
1490 ;; Find all headings and compute the targets for them
1491 (setq target-alist (org-export-define-heading-targets target-alist))
1492
1493 ;; Find targets in comments and move them out of comments, 1496 ;; Find targets in comments and move them out of comments,
1494 ;; but mark them as targets that should be invisible 1497 ;; but mark them as targets that should be invisible
1495 (setq target-alist (org-export-handle-invisible-targets target-alist)) 1498 (setq target-alist (org-export-handle-invisible-targets target-alist))
1496 1499
1497 ;; Protect examples 1500 ;; Protect examples
1498 (org-export-protect-examples (if asciip 'indent nil)) 1501 (org-export-protect-examples (if asciip 'indent nil))
1499 1502
1500 ;; Protect backend specific stuff, throw away the others. 1503 ;; Protect backend specific stuff, throw away the others.
1501 (org-export-select-backend-specific-text 1504 (org-export-select-backend-specific-text backend)
1502 (cond (htmlp 'html) (latexp 'latex) (asciip 'ascii)))
1503 1505
1504 ;; Protect quoted subtrees 1506 ;; Protect quoted subtrees
1505 (org-export-protect-quoted-subtrees) 1507 (org-export-protect-quoted-subtrees)
1506 1508
1507 ;; Protect verbatim elements 1509 ;; Protect verbatim elements
1508 (org-export-protect-verbatim) 1510 (org-export-protect-verbatim)
1509 1511
1510 ;; Blockquotes and verse 1512 ;; Blockquotes and verse
1511 (org-export-mark-blockquote-and-verse) 1513 (org-export-mark-blockquote-and-verse)
1512 1514
1515 ;; Attach captions to the correct opject
1516 (setq target-alist (org-export-attach-captions-and-attributes
1517 backend target-alist))
1518
1513 ;; Remove comment environment and comment subtrees 1519 ;; Remove comment environment and comment subtrees
1514 (org-export-remove-comment-blocks-and-subtrees) 1520 (org-export-remove-comment-blocks-and-subtrees)
1515
1516 1521
1517 ;; Find matches for radio targets and turn them into internal links 1522 ;; Find matches for radio targets and turn them into internal links
1518 (org-export-mark-radio-links) 1523 (org-export-mark-radio-links)
1519 1524
1520 ;; Find all links that contain a newline and put them into a single line 1525 ;; Find all links that contain a newline and put them into a single line
1569 (defun org-export-define-heading-targets (target-alist) 1574 (defun org-export-define-heading-targets (target-alist)
1570 "Find all headings and define the targets for them. 1575 "Find all headings and define the targets for them.
1571 The new targets are added to TARGET-ALIST, which is also returned." 1576 The new targets are added to TARGET-ALIST, which is also returned."
1572 (goto-char (point-min)) 1577 (goto-char (point-min))
1573 (org-init-section-numbers) 1578 (org-init-section-numbers)
1574 (let ((re (concat "^" org-outline-regexp)) 1579 (let ((re (concat "^" org-outline-regexp
1580 "\\| [ \t]*:ID:[ \t]*\\([^ \t\r\n]+\\)"))
1575 level target) 1581 level target)
1576 (while (re-search-forward re nil t) 1582 (while (re-search-forward re nil t)
1577 (setq level (org-reduced-level 1583 (if (match-end 1)
1578 (save-excursion (goto-char (point-at-bol)) 1584 (push (cons (org-match-string-no-properties 1)
1579 (org-outline-level)))) 1585 target) target-alist)
1580 (setq target (org-solidify-link-text 1586 (setq level (org-reduced-level
1581 (format "sec-%s" (org-section-number level)))) 1587 (save-excursion (goto-char (point-at-bol))
1582 (push (cons target target) target-alist) 1588 (org-outline-level))))
1583 (add-text-properties 1589 (setq target (org-solidify-link-text
1584 (point-at-bol) (point-at-eol) 1590 (format "sec-%s" (org-section-number level))))
1585 (list 'target target)))) 1591 (push (cons target target) target-alist)
1592 (add-text-properties
1593 (point-at-bol) (point-at-eol)
1594 (list 'target target)))))
1586 target-alist) 1595 target-alist)
1587 1596
1588 (defun org-export-handle-invisible-targets (target-alist) 1597 (defun org-export-handle-invisible-targets (target-alist)
1589 "Find targets in comments and move them out of comments. 1598 "Find targets in comments and move them out of comments.
1590 Mark them as invisible targets." 1599 Mark them as invisible targets."
1609 ;; Make an invisible target 1618 ;; Make an invisible target
1610 (replace-match "\\1(INVISIBLE)")))) 1619 (replace-match "\\1(INVISIBLE)"))))
1611 target-alist) 1620 target-alist)
1612 1621
1613 (defun org-export-target-internal-links (target-alist) 1622 (defun org-export-target-internal-links (target-alist)
1614 "Find all internal links and assign target to them. 1623 "Find all internal links and assign targets to them.
1615 If a link has a fuzzy match (i.e. not a *dedicated* target match), 1624 If a link has a fuzzy match (i.e. not a *dedicated* target match),
1616 let the link point to the corresponding section." 1625 let the link point to the corresponding section.
1626 This function also handles the id links, if they have a match in
1627 the current file."
1617 (goto-char (point-min)) 1628 (goto-char (point-min))
1618 (while (re-search-forward org-bracket-link-regexp nil t) 1629 (while (re-search-forward org-bracket-link-regexp nil t)
1619 (org-if-unprotected 1630 (org-if-unprotected
1620 (let* ((md (match-data)) 1631 (let* ((md (match-data))
1621 (desc (match-end 2)) 1632 (desc (match-end 2))
1623 (slink (org-solidify-link-text link)) 1634 (slink (org-solidify-link-text link))
1624 found props pos 1635 found props pos
1625 (target 1636 (target
1626 (cond 1637 (cond
1627 ((cdr (assoc slink target-alist))) 1638 ((cdr (assoc slink target-alist)))
1639 ((and (string-match "^id:" link)
1640 (cdr (assoc (substring link 3) target-alist))))
1628 ((string-match org-link-types-re link) nil) 1641 ((string-match org-link-types-re link) nil)
1629 ((or (file-name-absolute-p link) 1642 ((or (file-name-absolute-p link)
1630 (string-match "^\\." link)) 1643 (string-match "^\\." link))
1631 nil) 1644 nil)
1632 (t 1645 (t
1746 "Remove meta data from the headline, according to user options." 1759 "Remove meta data from the headline, according to user options."
1747 (let ((re org-complex-heading-regexp) 1760 (let ((re org-complex-heading-regexp)
1748 (todo (plist-get opts :todo-keywords)) 1761 (todo (plist-get opts :todo-keywords))
1749 (tags (plist-get opts :tags)) 1762 (tags (plist-get opts :tags))
1750 (pri (plist-get opts :priority)) 1763 (pri (plist-get opts :priority))
1751 rpl) 1764 (elts '(1 2 3 4 5))
1765 rpl props)
1766 (setq elts (delq nil (list 1 (if todo 2) (if pri 3) 4 (if tags 5))))
1752 (when (or (not todo) (not tags) (not pri)) 1767 (when (or (not todo) (not tags) (not pri))
1753 ;; OK, something needs to be removed
1754 (setq rpl (concat "\\1"
1755 (if todo " \\2" "")
1756 (if pri " \\3" "")
1757 " \\4"
1758 (if tags " \\5" "")))
1759 (goto-char (point-min)) 1768 (goto-char (point-min))
1760 (while (re-search-forward re nil t) 1769 (while (re-search-forward re nil t)
1761 (replace-match rpl t nil))))) 1770 (setq rpl (mapconcat (lambda (i) (if (match-end i) (match-string i) ""))
1771 elts " "))
1772 (replace-match rpl t t)))))
1762 1773
1763 (defun org-export-protect-quoted-subtrees () 1774 (defun org-export-protect-quoted-subtrees ()
1764 "Mark quoted subtrees with the protection property." 1775 "Mark quoted subtrees with the protection property."
1765 (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))) 1776 (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
1766 (goto-char (point-min)) 1777 (goto-char (point-min))
1835 (goto-char (point-min)) 1846 (goto-char (point-min))
1836 (while (re-search-forward "^#\\+\\(begin\\|end\\)_verse\\>.*" nil t) 1847 (while (re-search-forward "^#\\+\\(begin\\|end\\)_verse\\>.*" nil t)
1837 (replace-match (if (equal (downcase (match-string 1)) "end") 1848 (replace-match (if (equal (downcase (match-string 1)) "end")
1838 "ORG-VERSE-END" "ORG-VERSE-START") 1849 "ORG-VERSE-END" "ORG-VERSE-START")
1839 t t))) 1850 t t)))
1851
1852 (defun org-export-attach-captions-and-attributes (backend target-alist)
1853 "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
1854 If the next thing following is a table, add the text properties to the first
1855 table line. If it is a link, add it to the line containing the link."
1856 (goto-char (point-min))
1857 (remove-text-properties (point-min) (point-max)
1858 '(org-caption nil org-attributes nil))
1859 (let ((case-fold-search t)
1860 (re (concat "^#\\+caption:[ \t]+\\(.*\\)"
1861 "\\|"
1862 "^#\\+attr_" (symbol-name backend) ":[ \t]+\\(.*\\)"
1863 "\\|"
1864 "^#\\+label:[ \t]+\\(.*\\)"
1865 "\\|"
1866 "^[ \t]*|[^-]"
1867 "\\|"
1868 "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
1869 cap attr label)
1870 (while (re-search-forward re nil t)
1871 (cond
1872 ((match-end 1)
1873 (setq cap (concat cap (if cap " " "") (org-trim (match-string 1)))))
1874 ((match-end 2)
1875 (setq attr (concat attr (if attr " " "") (org-trim (match-string 2)))))
1876 ((match-end 3)
1877 (setq label (org-trim (match-string 3))))
1878 (t
1879 (add-text-properties (point-at-bol) (point-at-eol)
1880 (list 'org-caption cap
1881 'org-attributes attr
1882 'org-label label))
1883 (if label (push (cons label label) target-alist))
1884 (setq cap nil attr nil label nil)))))
1885 target-alist)
1840 1886
1841 (defun org-export-remove-comment-blocks-and-subtrees () 1887 (defun org-export-remove-comment-blocks-and-subtrees ()
1842 "Remove the comment environment, and also commented subtrees." 1888 "Remove the comment environment, and also commented subtrees."
1843 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")) 1889 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
1844 (case-fold-search nil)) 1890 (case-fold-search nil))
3204 (insert "\n<hr/>\n")) 3250 (insert "\n<hr/>\n"))
3205 (throw 'nextline nil)) 3251 (throw 'nextline nil))
3206 3252
3207 ;; Blockquotes and verse 3253 ;; Blockquotes and verse
3208 (when (equal "ORG-BLOCKQUOTE-START" line) 3254 (when (equal "ORG-BLOCKQUOTE-START" line)
3255 (org-close-par-maybe)
3209 (insert "<blockquote>\n<p>\n") 3256 (insert "<blockquote>\n<p>\n")
3210 (throw 'nextline nil)) 3257 (throw 'nextline nil))
3211 (when (equal "ORG-BLOCKQUOTE-END" line) 3258 (when (equal "ORG-BLOCKQUOTE-END" line)
3212 (insert "</p>\n</blockquote>\n") 3259 (insert "</p>\n</blockquote>\n")
3213 (throw 'nextline nil)) 3260 (throw 'nextline nil))
3214 (when (equal "ORG-VERSE-START" line) 3261 (when (equal "ORG-VERSE-START" line)
3262 (org-close-par-maybe)
3215 (insert "\n<p class=\"verse\">\n") 3263 (insert "\n<p class=\"verse\">\n")
3216 (setq inverse t) 3264 (setq inverse t)
3217 (throw 'nextline nil)) 3265 (throw 'nextline nil))
3218 (when (equal "ORG-VERSE-END" line) 3266 (when (equal "ORG-VERSE-END" line)
3219 (insert "</p>\n") 3267 (insert "</p>\n")
3223 (let ((i (org-get-string-indentation line))) 3271 (let ((i (org-get-string-indentation line)))
3224 (if (> i 0) 3272 (if (> i 0)
3225 (setq line (concat (mapconcat 'identity 3273 (setq line (concat (mapconcat 'identity
3226 (make-list (* 2 i) "\\nbsp") "") 3274 (make-list (* 2 i) "\\nbsp") "")
3227 " " (org-trim line)))) 3275 " " (org-trim line))))
3228 (setq line (concat line " \\\\")))) 3276 (setq line (concat line "\\\\"))))
3229 3277
3230 ;; make targets to anchors 3278 ;; make targets to anchors
3231 (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line) 3279 (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)
3232 (cond 3280 (cond
3233 ((match-end 2) 3281 ((match-end 2)
3269 ((save-match-data 3317 ((save-match-data
3270 (or (file-name-absolute-p path) 3318 (or (file-name-absolute-p path)
3271 (string-match "^\\.\\.?/" path))) 3319 (string-match "^\\.\\.?/" path)))
3272 "file") 3320 "file")
3273 (t "internal"))) 3321 (t "internal")))
3274 (setq path (org-extract-attributes path)) 3322 (setq path (org-extract-attributes (org-link-unescape path)))
3275 (setq attr (org-attributes-to-string 3323 (setq attr (get-text-property 0 'org-attributes path))
3276 (get-text-property 0 'org-attributes path)))
3277 (setq desc1 (if (match-end 5) (match-string 5 line)) 3324 (setq desc1 (if (match-end 5) (match-string 5 line))
3278 desc2 (if (match-end 2) (concat type ":" path) path) 3325 desc2 (if (match-end 2) (concat type ":" path) path)
3279 descp (and desc1 (not (equal desc1 desc2))) 3326 descp (and desc1 (not (equal desc1 desc2)))
3280 desc (or desc1 desc2)) 3327 desc (or desc1 desc2))
3281 ;; Make an image out of the description if that is so wanted 3328 ;; Make an image out of the description if that is so wanted
3300 ((member type '("http" "https")) 3347 ((member type '("http" "https"))
3301 ;; standard URL, just check if we need to inline an image 3348 ;; standard URL, just check if we need to inline an image
3302 (if (and (or (eq t org-export-html-inline-images) 3349 (if (and (or (eq t org-export-html-inline-images)
3303 (and org-export-html-inline-images (not descp))) 3350 (and org-export-html-inline-images (not descp)))
3304 (org-file-image-p path)) 3351 (org-file-image-p path))
3305 (setq rpl (concat "<img src=\"" type ":" path "\"" 3352 (setq rpl (org-export-html-format-image
3306 (if (string-match "\\<alt=" attr) 3353 (concat type ":" path)))
3307 attr (concat attr " alt=\"" path "\""))
3308 "/>"))
3309 (setq link (concat type ":" path)) 3354 (setq link (concat type ":" path))
3310 (setq rpl (concat "<a href=\"" 3355 (setq rpl (concat "<a href=\""
3311 (org-export-html-format-href link) 3356 (org-export-html-format-href link)
3312 "\"" attr ">" 3357 "\"" attr ">"
3313 (org-export-html-format-desc desc) 3358 (org-export-html-format-desc desc)
3361 (setq desc (replace-match "" t t desc)))))) 3406 (setq desc (replace-match "" t t desc))))))
3362 (setq rpl (if (and file-is-image-p 3407 (setq rpl (if (and file-is-image-p
3363 (or (eq t org-export-html-inline-images) 3408 (or (eq t org-export-html-inline-images)
3364 (and org-export-html-inline-images 3409 (and org-export-html-inline-images
3365 (not descp)))) 3410 (not descp))))
3366 (concat "<img src=\"" thefile "\"" 3411 (org-export-html-format-image thefile)
3367 (if (string-match "alt=" attr)
3368 attr
3369 (concat attr " alt=\""
3370 thefile "\"")) "/>")
3371 (concat "<a href=\"" thefile "\"" attr ">" 3412 (concat "<a href=\"" thefile "\"" attr ">"
3372 (org-export-html-format-desc desc) 3413 (org-export-html-format-desc desc)
3373 "</a>"))) 3414 "</a>")))
3374 (if (not valid) (setq rpl desc)))) 3415 (if (not valid) (setq rpl desc))))
3375 3416
3666 (if (and s (not (get-text-property 1 'org-protected s))) 3707 (if (and s (not (get-text-property 1 'org-protected s)))
3667 (save-match-data 3708 (save-match-data
3668 (org-html-do-expand s)) 3709 (org-html-do-expand s))
3669 s)) 3710 s))
3670 3711
3712 (defun org-export-html-format-image (src)
3713 "Create image tag with source and attributes."
3714 (save-match-data
3715 (let* ((caption (org-find-text-property-in-string 'org-caption src))
3716 (attr (org-find-text-property-in-string 'org-attributes src))
3717 (label (org-find-text-property-in-string 'org-label src)))
3718 (format "<div %sclass=\"figure\">
3719 <p><img src=\"%s\"%s></p>%s
3720 </div>"
3721 (if label (format "id=\"%s\" " label) "")
3722 src
3723 (if (string-match "\\<alt=" (or attr ""))
3724 (concat " " attr )
3725 (concat " " attr " alt=\"" src "\""))
3726 (if caption (concat "\n<p>" caption "</p>") "")))))
3727
3671 (defvar org-table-colgroup-info nil) 3728 (defvar org-table-colgroup-info nil)
3672 (defun org-format-table-ascii (lines) 3729 (defun org-format-table-ascii (lines)
3673 "Format a table for ascii export." 3730 "Format a table for ascii export."
3674 (if (stringp lines) 3731 (if (stringp lines)
3675 (setq lines (org-split-string lines "\n"))) 3732 (setq lines (org-split-string lines "\n")))
3752 (when org-export-table-remove-special-lines 3809 (when org-export-table-remove-special-lines
3753 ;; Check if the table has a marking column. If yes remove the 3810 ;; Check if the table has a marking column. If yes remove the
3754 ;; column and the special lines 3811 ;; column and the special lines
3755 (setq lines (org-table-clean-before-export lines))) 3812 (setq lines (org-table-clean-before-export lines)))
3756 3813
3757 (let ((head (and org-export-highlight-first-table-line 3814 (let ((caption (or (get-text-property 0 'org-caption (car lines))
3815 (get-text-property (or (next-single-property-change
3816 0 'org-caption (car lines))
3817 0)
3818 'org-caption (car lines))))
3819 (head (and org-export-highlight-first-table-line
3758 (delq nil (mapcar 3820 (delq nil (mapcar
3759 (lambda (x) (string-match "^[ \t]*|-" x)) 3821 (lambda (x) (string-match "^[ \t]*|-" x))
3760 (cdr lines))))) 3822 (cdr lines)))))
3823
3761 (nlines 0) fnum i 3824 (nlines 0) fnum i
3762 tbopen line fields html gr colgropen) 3825 tbopen line fields html gr colgropen)
3763 (if splice (setq head nil)) 3826 (if splice (setq head nil))
3764 (unless splice (push (if head "<thead>" "<tbody>") html)) 3827 (unless splice (push (if head "<thead>" "<tbody>") html))
3765 (setq tbopen t) 3828 (setq tbopen t)
3812 (progn (setq colgropen nil) "</colgroup>") 3875 (progn (setq colgropen nil) "</colgroup>")
3813 ""))) 3876 "")))
3814 fnum "") 3877 fnum "")
3815 html) 3878 html)
3816 (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html))))) 3879 (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html)))))
3880 (if caption (push (format "<caption>%s</caption>" caption) html))
3817 (push html-table-tag html)) 3881 (push html-table-tag html))
3818 (concat (mapconcat 'identity html "\n") "\n"))) 3882 (concat (mapconcat 'identity html "\n") "\n")))
3819 3883
3820 (defun org-table-clean-before-export (lines) 3884 (defun org-table-clean-before-export (lines)
3821 "Check if the table has a marking column. 3885 "Check if the table has a marking column.