Selaa lähdekoodia

babel: src block regexps are more robust to embedded "[begin|end]_src" in block body

Eric Schulte 15 vuotta sitten
vanhempi
commit
727aa263cb
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4 4
      contrib/babel/lisp/org-babel.el

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

@@ -139,7 +139,7 @@ can not be resolved.")
 		"\\)[ \t]*"
 		"\\([^\":\n]*\"[^\"\n*]*\"[^\":\n]*\\|[^\":\n]*\\)" ;; (2)   switches
 		"\\([^\n]*\\)\n"                      ;; (3)   header arguments
-                "\\([^\000]+?\\)#\\+end_src"))        ;; (4)   body
+                "\\([^\000]+?\n\\)[ \t]*#\\+end_src"));; (4)   body
   (setq org-babel-inline-src-block-regexp
 	(concat "[ \f\t\n\r\v]\\(src_"                ;; (1)   replacement target
 		"\\("                                 ;; (2)   lang
@@ -605,8 +605,8 @@ If the point is not on a source block then return nil."
             (point)))
      (save-excursion ;; inside a src block
        (and
-        (re-search-backward "#\\+begin_src" nil t) (setq top (point))
-        (re-search-forward "#\\+end_src" nil t) (setq bottom (point))
+        (re-search-backward "^[ \t]*#\\+begin_src" nil t) (setq top (point))
+        (re-search-forward "^[ \t]*#\\+end_src" nil t) (setq bottom (point))
         (< top initial) (< initial bottom)
         (goto-char top) (move-beginning-of-line 1)
         (looking-at org-babel-src-block-regexp)
@@ -656,7 +656,7 @@ following the source block."
 	   (head (unless on-lob-line (org-babel-where-is-src-block-head))) end)
       (when head (goto-char head))
       (or (and name (org-babel-find-named-result name))
-          (and (or on-lob-line (re-search-forward "#\\+end_src" nil t))
+          (and (or on-lob-line (re-search-forward "^[ \t]*#\\+end_src" nil t))
                (progn (move-end-of-line 1)
 		      (if (eobp) (insert "\n") (forward-char 1))
 		      (setq end (point))