From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thibault Marin Subject: Re: Multiple bibliography files with ox-bibtex and html export Date: Tue, 06 Sep 2016 22:46:57 -0500 Message-ID: <871t0wl6by.fsf@dell-desktop.WORKGROUP> References: <87k2f6x0q6.fsf@dell-desktop.WORKGROUP> <87vay9v1h1.fsf@saiph.selenimh> Reply-To: thibault.marin@gmx.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhTpT-0004pA-G1 for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 23:47:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhTpO-0001T2-Hq for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 23:47:15 -0400 Received: from mout.gmx.net ([212.227.15.18]:63108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhTpO-0001SQ-30 for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 23:47:10 -0400 In-reply-to: <87vay9v1h1.fsf@saiph.selenimh> 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" To: Nicolas Goaziou Cc: emacs-orgmode --=-=-= Content-Type: text/plain Nicolas Goaziou writes: > Hello, > > Thibault Marin writes: > >> I would like to use ox-bibtex to export a bibliography to html with >> multiple bibliography files, as follows: >> >> #+BIBLIOGRAPHY: bibtex_1.bib,bibtex_2.bib plain option:-d option:-noabstract limit:t >> >> This works with latex export but not with html (I get a "Executing >> bibtex2html failed"). It appears that bibtex2html can only process a >> single file. >> >> I am attaching a patch which allows me to use multiple files with html >> export. It creates a combined bibliography file and call bibtex2html on >> it. I am not sure this is the best way to address this, so any >> suggestion would be welcome. >> >> Does this look like something that could be merged? > > Apparently no objection was raised, so I think this can be merged. Some > minor comments below. > >> + (let ((files (org-split-string file ","))) > > I think `split-string' is sufficient here. > >> + (when (< 1 (length files)) >> + (let ((combined-bib-file >> + (concat >> + (file-name-sans-extension >> + (file-name-nondirectory >> + (buffer-file-name))) "-combined.bib"))) >> + (with-temp-file combined-bib-file >> + (dolist (bib files) >> + (insert-file-contents >> + (if (equal (file-name-extension bib) "bib") >> + bib >> + (concat bib ".bib") >> + ) >> + ) >> + ) >> + ) >> + (setq file combined-bib-file) >> + ) >> + ) >> + ) > > There should be no dangling parenthesis in Lisp. > > Could you send an updated patch? > > Thank you. > > > Regards, Thanks for the review, here is an updated patch. Best, thibault --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-contrib-lisp-ox-bibtex.el-org-bibtex-process-bib-fil.patch >From cb07ff936587a456f1e6599d216efe9463431d3f Mon Sep 17 00:00:00 2001 From: thibault Date: Tue, 6 Sep 2016 22:42:39 -0500 Subject: [PATCH] * contrib/lisp/ox-bibtex.el (org-bibtex-process-bib-files): Add support for multiple bibliography files with html export. Combine comma-separated bibliography files into a single one and process it using bibtex2html. This matches the behavior already present for latex export. --- contrib/lisp/ox-bibtex.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/ox-bibtex.el b/contrib/lisp/ox-bibtex.el index 56dec38..b46cb76 100644 --- a/contrib/lisp/ox-bibtex.el +++ b/contrib/lisp/ox-bibtex.el @@ -191,13 +191,27 @@ Return new parse tree." (file (org-bibtex-get-file keyword)) temp-file out-file) + (let ((files (split-string file ","))) + (when (< 1 (length files)) + (let ((combined-bib-file + (concat + (file-name-sans-extension + (file-name-nondirectory + (buffer-file-name))) "-combined.bib"))) + (with-temp-file combined-bib-file + (dolist (bib files) + (insert-file-contents + (if (equal (file-name-extension bib) "bib") + bib + (concat bib ".bib"))))) + (setq file combined-bib-file)))) ;; Test if filename is given with .bib-extension and strip ;; it off. Filenames with another extensions will be ;; untouched and will finally rise an error in bibtex2html. (setq file (if (equal (file-name-extension file) "bib") (file-name-sans-extension file) file)) - ;; Outpufiles of bibtex2html will be put into current working directory - ;; so define a variable for this. + ;; Output files of bibtex2html will be put into current + ;; working directory so define a variable for this. (setq out-file (file-name-sans-extension (file-name-nondirectory file))) ;; limit is set: collect citations throughout the document -- 2.8.1 --=-=-=--