From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Rose Subject: Re: [PATCH] Unwanted #+ATTR_Backend and #+Backend stuff Date: Wed, 30 Jun 2010 14:16:36 +0200 Message-ID: <87tyok67h7.fsf@gmx.de> References: <87ljaa997e.wl%n.goaziou@gmail.com> <87tyosqzfv.wl%dmaus@ictsoc.de> <87ocf0ck7z.fsf@gmx.de> <87631280by.fsf@gmx.de> <87tyokhku9.wl%n.goaziou@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=59132 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTwDV-0006MU-Sj for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 08:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTwDQ-0004Em-Vr for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 08:16:37 -0400 Received: from mail.gmx.net ([213.165.64.20]:57838) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OTwDQ-0004Ee-Hj for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 08:16:32 -0400 In-Reply-To: <87tyokhku9.wl%n.goaziou@gmail.com> (Nicolas Goaziou's message of "Wed, 30 Jun 2010 12:32:30 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Org Mode List Nicolas Goaziou writes: > Hello, >>>>>> Sebastian Rose writes: >> What's the status of this? > > What about the following patch ? I think it should fix it. > > -- Nicolas > > >>From 115a7e9d04fd5463913e1086ad3ff807ae579e16 Mon Sep 17 00:00:00 2001 > From: Nicolas Goaziou > 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 | 22 +++++++++++++++++----- > 1 files changed, 17 insertions(+), 5 deletions(-) > > diff --git a/lisp/org-exp.el b/lisp/org-exp.el > index 54afdac..578e0cf 100644 > --- a/lisp/org-exp.el > +++ b/lisp/org-exp.el > @@ -1526,15 +1526,27 @@ 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)))) > + ;; Handle #+attr_Backend: stuff > + (goto-char (point-min)) > + (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (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)))) > + ;; Handle #+begin_Backend and #+end_Backend stuff > (goto-char (point-min)) > (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt) "\\>.*\n?") > nil t) 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-- Tempolauf style="margin-left:auto;margin-right:auto;text-align:center;"

--8<---------------cut here---------------end--------------->8-- The `style...' part must be trimmed and go inside the `
' tag. Also, in this test: --8<---------------cut here---------------start------------->8-- * Example #+ATTR_HTML: I am removed from ASCII export | THead 1 | THead 2 | #+ATTR_HTML: I am _NOT_ removed from ASCII export | THead 1 | THead 2 | #+CAPTION: removed #+ATTR_HTML: NOT removed | THead 1 | THead 2 | #+CAPTION: removed #+ATTR_HTML: removed | THead 1 | THead 2 | --8<---------------cut here---------------end--------------->8-- the second last `#+CAPTION: removed' is NOT removed. Sebastian