فهرست منبع

org-babel: avoid false positive matches for inline and #+lob constructs

This forces the #+lob regexp to match at the beginning of a line (with
optional preceding whitespace), and requires inline code blocks to be
surrounded by some whitespace.
Dan Davison 16 سال پیش
والد
کامیت
70a5963563
3فایلهای تغییر یافته به همراه5 افزوده شده و 7 حذف شده
  1. 2 4
      contrib/babel/lisp/org-babel-exp.el
  2. 1 1
      contrib/babel/lisp/org-babel-lob.el
  3. 2 2
      contrib/babel/lisp/org-babel.el

+ 2 - 4
contrib/babel/lisp/org-babel-exp.el

@@ -74,9 +74,7 @@ options and are taken from `org-babel-defualt-inline-header-args'."
              (replacement (save-match-data
                             (org-babel-exp-do-export
                              (first info) (second info) (third info) 'inline))))
-        ;; (message "%s -> %s" (second info) replacement) ;; debugging
-        (setf end (+ end (- (length replacement)
-                            (+ 6 (length (first info)) (length (second info))))))
+        (setq end (+ end (- (length replacement) (length (match-string 0)))))
         (replace-match replacement t t)))))
 
 (defun org-babel-exp-lob-one-liners (start end)
@@ -145,7 +143,7 @@ options are taken from `org-babel-default-header-args'."
             (format "src_%s{%s}" lang raw))
            (t
             (if (and (stringp raw) (= 0 (length raw)))
-                "=(no results)=" (format "=%S=" raw))))))
+                " =(no results)= " (format " =%S= " raw))))))
       ('block
           (save-excursion ;; org-exp-blocks places us at the end of the block
             (re-search-backward org-babel-src-block-regexp nil t)

+ 1 - 1
contrib/babel/lisp/org-babel-lob.el

@@ -55,7 +55,7 @@ add files to this list use the `org-babel-lob-ingest' command."
 
 ;; functions for executing lob one-liners
 
-(defvar org-babel-lob-one-liner-regexp "#\\+lob:[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\\([^\n]*\\)")
+(defvar org-babel-lob-one-liner-regexp "^[ \t]*#\\+lob:[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\\([^\n]*\\)")
 
 (defun org-babel-lob-execute-maybe ()
   "Detect if this is context for a org-babel Library Of Babel

+ 2 - 2
contrib/babel/lisp/org-babel.el

@@ -115,11 +115,11 @@ then run `org-babel-pop-to-session'."
                 "\\([ \t]+\\([^\n]+\\)\\)?\n" ;; match header arguments
                 "\\([^\000]+?\\)#\\+end_src"))
   (setq org-babel-inline-src-block-regexp
-	(concat "src_\\("
+	(concat "[ \t\n]src_\\("
 		(mapconcat 'regexp-quote value "\\|")
 		"\\)"
                 "\\(\\|\\[\\(.*\\)\\]\\)"
-                "{\\([^\n]+\\)}")))
+                "{\\([^\n]+\\)}\\(?:[ \t\n]\\|\\'\\)")))
 
 (defun org-babel-add-interpreter (interpreter)
   "Add INTERPRETER to `org-babel-interpreters' and update