From: Thibault Marin <thibault.marin.us@ieee.org>
To: "Clément Pit--Claudel" <clement.pit@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Multiple bibliography files with ox-bibtex and html export
Date: Thu, 08 Sep 2016 22:55:06 -0500 [thread overview]
Message-ID: <87wpilbucl.fsf@dell-desktop.WORKGROUP> (raw)
In-Reply-To: <61fbf71f-3809-7460-5ead-265c8c9e6f66@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]
Clément Pit--Claudel writes:
> On 2016-09-06 23:46, Thibault Marin wrote:
>>>> 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.
>
> Sorry for the late comment. bibtex2html can read from standard input; maybe that would be cleaner?
>
> Clément.
That may be a good idea, it would prevent potential name clashing with
the created bib file. Currently, the function creates a
<name-of-org-file>-combined.bib file with the content of all
bibliography files, then bibtex2html creates
<name-of-org-file>-combined.html and
<name-of-org-file>-combined_bib.html. Passing the contents via stdin
would skip the <name-of-org-file>-combined.bib. We could achieve the
same by simply deleting <name-of-org-file>-combined.bib after calling
bibtex2html. I personally don't mind leaving the .bib file after
processing, but if there is a consensus to limit the side effect, we can
do that.
As far as the implementation goes, I am not sure what is the best way to
get this to work with stdin. In the attached patch (which does *not*
work) I tried to use `call-process-region' and dump the bibliography
files into a temporary buffer. This complicates the code a little.
Alternatively, we could use the `INFILE' parameter from `call-process',
but it looks that this would require a file, so it would not change much
from the previous patch.
Any thoughts?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-contrib-lisp-ox-bibtex.el-org-bibtex-process-bib-fil.patch --]
[-- Type: text/x-diff, Size: 4049 bytes --]
From 85369923cdd7540467a615ca92cf486fd6d08708 Mon Sep 17 00:00:00 2001
From: thibault <thibault@dell-desktop.WORKGROUP>
Date: Thu, 8 Sep 2016 22:06:21 -0500
Subject: [PATCH 2/2] * contrib/lisp/ox-bibtex.el
(org-bibtex-process-bib-files): (WIP) Add support for multiple bibliography
files with html export.
Pass multiple bibliography files (comma separated) to bibtex2html.
---
contrib/lisp/ox-bibtex.el | 82 ++++++++++++++++++++++++++++++-----------------
1 file changed, 53 insertions(+), 29 deletions(-)
diff --git a/contrib/lisp/ox-bibtex.el b/contrib/lisp/ox-bibtex.el
index b46cb76..38c0957 100644
--- a/contrib/lisp/ox-bibtex.el
+++ b/contrib/lisp/ox-bibtex.el
@@ -187,24 +187,20 @@ Return new parse tree."
(org-element-map tree 'keyword
(lambda (keyword)
(when (equal (org-element-property :key keyword) "BIBLIOGRAPHY")
- (let ((arguments (org-bibtex-get-arguments keyword))
- (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))))
+ (let* ((arguments (org-bibtex-get-arguments keyword))
+ (file (org-bibtex-get-file keyword))
+ temp-file
+ out-file
+ (multiple-bib-files (split-string file ","))
+ (multiple-bib-p (< 1 (length multiple-bib-files)))
+ multiple-bib-file)
+ (when multiple-bib-p
+ (setq multiple-bib-file
+ (concat
+ (file-name-sans-extension
+ (file-name-nondirectory
+ (buffer-file-name))) "-combined.bib"))
+ (setq file multiple-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.
@@ -231,17 +227,45 @@ Return new parse tree."
(append (plist-get arguments :options)
(list "-citefile" temp-file))))))
;; Call "bibtex2html" on specified file.
- (unless (eq 0 (apply
- 'call-process
- (append '("bibtex2html" nil nil nil)
- '("-a" "-nodoc" "-noheader" "-nofooter")
- (let ((style
- (org-not-nil
- (org-bibtex-get-style keyword))))
- (and style (list "--style" style)))
- (plist-get arguments :options)
- (list (concat file ".bib")))))
- (error "Executing bibtex2html failed"))
+ (let* ((bibtex2html-cmd '("bibtex2html" nil nil nil))
+ (bibtex2html-args-default '("-a" "-nodoc" "-noheader"
+ "-nofooter"))
+ (bibtex2html-style
+ (let ((style
+ (org-not-nil
+ (org-bibtex-get-style keyword))))
+ (and style (list "--style" style))))
+ (bibtex2html-opts (plist-get arguments :options)))
+ (message "mf=%s file=%s" multiple-bib-file multiple-bib-files)
+ (if multiple-bib-p
+ (with-temp-buffer
+ multiple-bib-file
+ (dolist (bib multiple-bib-files)
+ (insert-file-contents
+ (if (equal (file-name-extension bib) "bib")
+ bib
+ (concat bib ".bib"))))
+ (unless
+ (eq 0
+ (apply
+ 'call-process-region
+ (append `(,(point-min) ,(point-max))
+ bibtex2html-cmd
+ bibtex2html-args-default
+ bibtex2html-style
+ bibtex2html-opts
+ `("-o" ,file)))))
+ (error "Executing bibtex2html failed"))
+ (unless
+ (eq 0
+ (apply
+ 'call-process
+ (append bibtex2html-cmd
+ bibtex2html-args-default
+ bibtex2html-style
+ bibtex2html-opts
+ (list (concat file ".bib")))))
+ (error "Executing bibtex2html failed"))))
(and temp-file (delete-file temp-file))
;; Open produced HTML file, and collect Bibtex key names
(with-temp-buffer
--
2.8.1
next prev parent reply other threads:[~2016-09-09 3:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 4:14 Multiple bibliography files with ox-bibtex and html export Thibault Marin
2016-09-06 9:09 ` Nicolas Goaziou
2016-09-07 3:46 ` Thibault Marin
2016-09-07 4:11 ` Clément Pit--Claudel
2016-09-09 3:55 ` Thibault Marin [this message]
2016-09-10 6:07 ` Thibault Marin
2016-09-10 16:31 ` Clément Pit--Claudel
2016-09-28 3:50 ` Thibault Marin
2016-11-16 5:31 ` Thibault Marin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wpilbucl.fsf@dell-desktop.WORKGROUP \
--to=thibault.marin.us@ieee.org \
--cc=clement.pit@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.