emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] orphaned captions and labels
@ 2010-06-19 18:19 Nicolas Goaziou
  2010-06-24 14:26 ` David Maus
  0 siblings, 1 reply; 10+ messages in thread
From: Nicolas Goaziou @ 2010-06-19 18:19 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

Hello,

This patch corrects the following problem :

-----------------------------------------
#+caption: I'm not removed from export
#+label: also-not-removed
| A | B |
| 1 | 2 |
-----------------------------------------

Since org-handle-comments is only removing comments, #+caption, #+label
and friends were left in the export file.

Regards,

-- Nicolas


[-- Attachment #2: 0001-captions-labels-are-now-properly-cleaned-before-expo.patch --]
[-- Type: application/octet-stream, Size: 2868 bytes --]

From 47bd77def15189e0a87af2b4fa66e9e8bd0d70c8 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Sat, 19 Jun 2010 20:07:50 +0200
Subject: [PATCH] captions, labels are now properly cleaned before export.

* lisp/org-exp.el: captions, labels and others attributes are deleted
  at the right time, and no more as a side-effect during comments
  removal.
---
 lisp/org-exp.el |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 029e4d7..6a80cf0 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1108,8 +1108,8 @@ on this string to produce the exported version."
       (unless (plist-get parameters :timestamps)
 	(org-export-remove-timestamps))
 
-      ;; Attach captions to the correct object
-      (setq target-alist (org-export-attach-captions-and-attributes
+      ;; Attach captions to the correct object and removes them
+      (setq target-alist (org-export-handle-captions-and-attributes
 			  backend target-alist))
 
       ;; Find matches for radio targets and turn them into internal links
@@ -1576,10 +1576,12 @@ These special cookies will later be interpreted by the backend."
 	(delete-region beg end)
 	(insert (org-add-props content nil 'original-indentation ind))))))
 
-(defun org-export-attach-captions-and-attributes (backend target-alist)
+(defun org-export-handle-captions-and-attributes (backend target-alist)
   "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
-If the next thing following is a table, add the text properties to the first
-table line.  If it is a link, add it to the line containing the link."
+If the next thing following is a table, add the text properties
+to the first table line. If it is a link, add it to the line
+containing the link. #+CAPTION, #+ATTR_BACKEND and #+LABEL
+lines are removed in the process."
   (goto-char (point-min))
   (remove-text-properties (point-min) (point-max)
 			  '(org-caption nil org-attributes nil))
@@ -1597,11 +1599,17 @@ table line.  If it is a link, add it to the line containing the link."
     (while (re-search-forward re nil t)
       (cond
        ((match-end 1)
-	(setq cap (concat cap (if cap " " "") (org-trim (match-string 1)))))
+	(progn
+	  (setq cap (concat cap (if cap " " "") (org-trim (match-string 1))))
+	  (delete-region (point-at-bol) (point))))
        ((match-end 2)
-	(setq attr (concat attr (if attr " " "") (org-trim (match-string 2)))))
+	(progn
+	  (setq attr (concat attr (if attr " " "") (org-trim (match-string 2))))
+	  (delete-region (point-at-bol) (point))))
        ((match-end 3)
-	(setq label (org-trim (match-string 3))))
+	(progn
+	  (setq label (org-trim (match-string 3)))
+	  (delete-region (point-at-bol) (point))))
        (t
 	(setq end (if (match-end 4)
 		      (let ((ee (org-table-end)))
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-07-02 15:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-19 18:19 [PATCH] orphaned captions and labels Nicolas Goaziou
2010-06-24 14:26 ` David Maus
2010-06-24 19:18   ` Sebastian Rose
2010-06-29 12:55     ` Sebastian Rose
2010-06-30 10:32       ` [PATCH] Unwanted #+ATTR_Backend and #+Backend stuff Nicolas Goaziou
2010-06-30 12:16         ` Sebastian Rose
2010-06-30 13:18           ` [PATCH] Unwanted #+ATTR_Backend and #+Backend stuff (v.2) Nicolas Goaziou
2010-06-30 13:53             ` Sebastian Rose
2010-06-30 10:55   ` [PATCH] orphaned captions and labels Nicolas Goaziou
2010-07-02 15:12     ` David Maus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).