Browse Source

org-exp-bibtex.el: Allow multiple citation keys per \cite macro

LaTeX supports \cite{key1,key2,...}.  Now org-exp-bibtex.el does as
well.
Carsten Dominik 16 years ago
parent
commit
d288e665dc
2 changed files with 16 additions and 1 deletions
  1. 5 0
      contrib/ChangeLog
  2. 11 1
      contrib/lisp/org-exp-bibtex.el

+ 5 - 0
contrib/ChangeLog

@@ -1,3 +1,8 @@
+2009-04-01  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* lisp/org-exp-bibtex.el (org-export-bibtex-preprocess): Handle
+	multiple keys in a single \cite command.
+
 2009-03-30  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* lisp/org-mtags.el: Fix copyright year.

+ 11 - 1
contrib/lisp/org-exp-bibtex.el

@@ -79,7 +79,9 @@
 
 
 	    (when (assoc "limit" opt) ;; Limit is true - collect references
-	      (org-exp-bibtex-docites (lambda () (add-to-list 'cite-list (match-string 1))))
+	      (org-exp-bibtex-docites (lambda ()
+					(dolist (c (org-split-string (match-string 1) ","))
+					  (add-to-list 'cite-list c))))
 ;;	      (message "cites: %s" cite-list)
 	      (let ((tmp (make-temp-file "org-exp-bibtex")))
 		(with-temp-file tmp (dolist (i cite-list) (insert (concat i "\n"))))
@@ -111,6 +113,14 @@
 
     ;; Convert cites to links in html
     (when htmlp
+      ;; Split citation commands with multiple keys
+      (org-exp-bibtex-docites
+       (lambda ()
+	 (let ((keys (save-match-data (org-split-string (match-string 1) ","))))
+	   (when (> (length keys) 1)
+	     (replace-match (mapconcat (lambda (k) (format "\\cite{%s}" k)) keys "")
+			    t t)))))
+      ;; Replace the citation commands with links
       (org-exp-bibtex-docites
        (lambda () (let* ((cn (match-string 1))
 			 (cv (assoc cn oebp-cite-plist)))