From mboxrd@z Thu Jan 1 00:00:00 1970 From: feng shu Subject: Re: [PATCH] Add "latex" option to ox-bibtex.el Date: Sat, 13 Jul 2013 07:15:34 +0800 Message-ID: References: <87vc4g83po.fsf@gmail.com> <87ip0f99yq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e012297501b714804e158b058 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxmYr-00028w-4H for emacs-orgmode@gnu.org; Fri, 12 Jul 2013 19:15:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxmYp-0003TZ-Ts for emacs-orgmode@gnu.org; Fri, 12 Jul 2013 19:15:37 -0400 Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]:34204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxmYp-0003SV-L2 for emacs-orgmode@gnu.org; Fri, 12 Jul 2013 19:15:35 -0400 Received: by mail-we0-f182.google.com with SMTP id p60so8445476wes.41 for ; Fri, 12 Jul 2013 16:15:34 -0700 (PDT) In-Reply-To: <87ip0f99yq.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" --089e012297501b714804e158b058 Content-Type: text/plain; charset=UTF-8 I want to add a option which can setting bib for html export and latex export separately, As it for the reason: 1. bibtex2html can't work well with complex bib style, so using a simple style and making it show correctly is reasonable choose, 2. bibtex2html can't find bib style in current dir, for example (./file.sty) , 3. the biblatex user. In my opinion, the solution seemd more hacky than mine for a user, It let my org-mode file more unportable. Could you share you opinion and reason about my approach: Is the idea , separating with a new option, hacky? or my code hacky? . On Fri, Jul 12, 2013 at 9:36 PM, Nicolas Goaziou wrote: > > Really? This problem can be resolved with hooks or filters? Could you > > give me more informations or a example? > > Perhaps something like the following (untested) should do the trick: > > (defun my-bibliography-selector-hook (backend) > (case backend > (latex > (when (save-excursion > (re-search-forward "^[ \t]*\\bibliography\\(?:style\\)?{" > nil t)) > (while (re-search-forward "^[ \t]*#+BIBLIOGRAPHY:.*$" nil t) > (when (eq (org-element-type (save-match-data > (org-element-at-point))) > 'keyword) > (replace-match ""))))) > (html > (when (save-excursion > (re-search-forward "^[ \t]*#+BIBLIOGRAPHY:.*$" nil t)) > (while (re-search-forward "^[ > \t]*\\bibliography\\(?:style\\)?{.*$" nil t) > (replace-match "")))))) > > (add-hook 'org-export-before-parsing-hook 'my-bibliography-selector-hook) > > > Regards, > > -- > Nicolas Goaziou > --089e012297501b714804e158b058 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I want to add a option which can setting bib for html expor= t and latex export separately,
As it for the reaso= n:
1. bibtex2html can't work well with complex= bib style, so using a simple style and making it
=C2=A0=C2=A0=C2=A0 show= correctly is reasonable choose,
<= span class=3D"">2. bibtex2html can't find bib style in current dir, for= example (./file.sty) ,
<= span id=3D"result_box" class=3D"" lang=3D"en">3. the bibla= tex user.


In my opinion, the solution seemd more hacky than mine for a user,=C2=A0 It= let my org-mode file more unportable.

Could you share you opinion and reason about my approach:=C2=A0 Is t= he idea , separating with=C2=A0 a new option, hacky?=C2=A0 or my code ha= cky? .



On Fri, Jul 12, 2013 at 9:36 PM, Nicolas Goaziou <n.goazio= u@gmail.com> wrote:
> Really? =C2=A0This p= roblem can be resolved with hooks or filters? =C2=A0Could you
> give me more informations or a example?

Perhaps something like the following (untested) should do the trick:

=C2=A0 (defun my-bibliography-selector-hook (backend)
=C2=A0 =C2=A0 (case backend
=C2=A0 =C2=A0 =C2=A0 (latex
=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (save-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(re-search-forward &= quot;^[ \t]*\\bibliography\\(?:style\\)?{" nil t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(while (re-search-forward "^[ \t]*#+= BIBLIOGRAPHY:.*$" nil t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (eq (org-element-type (save-= match-data (org-element-at-point)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0'keyword)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(replace-match ""= )))))
=C2=A0 =C2=A0 =C2=A0 (html
=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (save-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(re-search-forward &= quot;^[ \t]*#+BIBLIOGRAPHY:.*$" nil t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(while (re-search-forward "^[ \t]*\\= bibliography\\(?:style\\)?{.*$" nil t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(replace-match ""))))))<= br>
=C2=A0 (add-hook 'org-export-before-parsing-hook 'my-bibliography-s= elector-hook)


Regards,

--
Nicolas Goaziou

--089e012297501b714804e158b058--