emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Sebastian Rose <sebastian_rose@gmx.de>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Unwanted #+ATTR_Backend and #+Backend stuff (v.2)
Date: Wed, 30 Jun 2010 15:18:30 +0200	[thread overview]
Message-ID: <87oceshd5l.wl%n.goaziou@gmail.com> (raw)
In-Reply-To: <87tyok67h7.fsf@gmx.de>

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

>>>>> Sebastian Rose writes:
> Ahhh - it nearly does!

> But look at this:

>  --8<---------------cut here---------------start------------->8--
>          *Tempolauf*
>         #+ATTR_HTML: style="margin-left:auto;margin-right:auto;text-align:center;"
>  |  Z | Station          | Meter | Etappe |  Zeit |  Rnd. | Pace Rnd. | Pace |
>  |----+------------------+-------+--------+-------+-------+-----------+------|
>  --8<---------------cut here---------------end--------------->8--

> Becomes:

>  --8<---------------cut here---------------start------------->8--
> <b>Tempolauf</b>
>         style="margin-left:auto;margin-right:auto;text-align:center;"
> </p><table border="0" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
>  --8<---------------cut here---------------end--------------->8--

> The `style...' part must be trimmed and go inside the `<table>' tag.

Yes, my patch was a bit aggressive. See my next try.


> Also, in this test:
> [...]
> the second last `#+CAPTION: removed' is NOT removed.

That, my first patch about captions should have taken care of it.

Here is another try on this one. Please tell me if it is working. It
contains both fixes (captions and attr) so there shouldn't be the need
of a previous patch.

Regards,

-- Nicolas


[-- Attachment #2: 0001-Remove-unwanted-ATTR_Backend-and-Backend-during-expo.patch --]
[-- Type: text/plain, Size: 2941 bytes --]

From 76840002404838757a6a31bbfb1e2bdc2564045a Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Wed, 30 Jun 2010 12:28:32 +0200
Subject: [PATCH] Remove unwanted #+ATTR_Backend and #+Backend during export.

* lisp/org-exp.el: (org-export-select-backend-specific-text) Properly
  get rid of #+Backend and #+ATTR_Backend specifics to backends not
  matching the one we're exporting to.
---
 lisp/org-exp.el |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 54afdac..d7a9e19 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1526,15 +1526,25 @@ from the buffer."
 
     (while formatters
       (setq fmt (pop formatters))
-      (when (eq (car fmt) backend)
-	;; This is selected code, put it into the file for real
-	(goto-char (point-min))
-	(while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt)
-					  ":[ \t]*\\(.*\\)") nil t)
+      ;; Handle #+Backend: stuff
+      (goto-char (point-min))
+      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt)
+					":[ \t]*\\(.*\\)") nil t)
+	(if (not (eq (car fmt) backend))
+	    (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
 	  (replace-match "\\1\\2" t)
 	  (add-text-properties
 	   (point-at-bol) (min (1+ (point-at-eol)) (point-max))
 	   '(org-protected t))))
+      ;; Delete #+attr_Backend: stuff of another backend. Those
+      ;; matching the current backend will be taken care of by
+      ;; `org-export-attach-captions-and-attributes'
+      (goto-char (point-min))
+      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (cadr fmt)
+					":[ \t]*\\(.*\\)") nil t)
+	(when (not (eq (car fmt) backend))
+	  (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
+      ;; Handle #+begin_Backend and #+end_Backend stuff
       (goto-char (point-min))
       (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt) "\\>.*\n?")
 				nil t)
@@ -1598,11 +1608,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) (min (1+ (point-at-eol)) (point-max)))))
        ((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) (min (1+ (point-at-eol)) (point-max)))))
        ((match-end 3)
-	(setq label (org-trim (match-string 3))))
+	(progn
+	  (setq label (org-trim (match-string 3)))
+	  (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
        (t
 	(setq end (if (match-end 4)
 		      (let ((ee (org-table-end)))
-- 
1.7.1.1


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



[-- Attachment #4: 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

  reply	other threads:[~2010-06-30 13:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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           ` Nicolas Goaziou [this message]
2010-06-30 13:53             ` [PATCH] Unwanted #+ATTR_Backend and #+Backend stuff (v.2) Sebastian Rose
2010-06-30 10:55   ` [PATCH] orphaned captions and labels Nicolas Goaziou
2010-07-02 15:12     ` David Maus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oceshd5l.wl%n.goaziou@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=sebastian_rose@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).