Browse Source

Use better regular expression to find bibliography line

Hsiu-Khuern writes:

> In contrib/lisp/org-export-bibtex.el, the BiBTeX file has to
> match the Emacs regexp "\w+".  So a line like
>
> #+BIBLIOGRAPHY: mybib_new
>
> will not work because of the underscore character in the
> filename.  (I suppose the actual behavior depends on the local
> Emacs settings that affect the "syntax table".)  May I propose
> changing the regexp to "[[:alnum:]_]+"?
>
> Initially, I was stumped by this because I thought \w was a
> "regular" regexp :), such as defined in sed, and would match
> underscores as well.
Carsten Dominik 15 years ago
parent
commit
4dc86eedd4
2 changed files with 6 additions and 1 deletions
  1. 5 0
      contrib/ChangeLog
  2. 1 1
      contrib/lisp/org-exp-bibtex.el

+ 5 - 0
contrib/ChangeLog

@@ -1,3 +1,8 @@
+2009-08-14  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* lisp/org-exp-bibtex.el (org-export-bibtex-preprocess): Use a
+	safer regular expression.
+
 2009-08-07  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* lisp/org-track.el: New file.

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

@@ -65,7 +65,7 @@
 
     ;; Convert #+BIBLIOGRAPHY: name style
     (goto-char (point-min))
-    (while (re-search-forward "^#\\+BIBLIOGRAPHY:\\s-+\\(\\w+\\)\\s-+\\(\\w+\\)\\([^\r\n]*\\)" nil t)
+    (while (re-search-forward "^#\\+BIBLIOGRAPHY:[ \t]+\\(\\S-+\\)[ \t]+\\(\\S-+\\)\\([^\r\n]*\\)" nil t)
       (let ((file  (match-string 1))
 	    (style (match-string 2))
 	    (opt   (org-exp-bibtex-options-to-plist (match-string 3))))