1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2025-02-06 21:29:25 +00:00

babel: don't evaluate inline code located in verbatim or quoted environments

* contrib/babel/lisp/org-babel-exp.el (org-babel-exp-inline-src-blocks):
  only evaluate inline source code blocks if they do not appear in a
  verbatim or quoted context

  (org-babel-in-example-or-verbatim): check if the point is currently
  located in a verbatim or quoted context
This commit is contained in:
Eric Schulte 2010-06-08 16:19:54 -07:00
parent 7361f79d4c
commit 5068f4a5cf

View File

@ -97,21 +97,33 @@ options and are taken from `org-babel-defualt-inline-header-args'."
(goto-char start)
(while (and (< (point) end)
(re-search-forward org-babel-inline-src-block-regexp end t))
(let* ((info (save-match-data (org-babel-parse-inline-src-block-match)))
(params (third info))
(replacement
(save-match-data
;; expand noweb references in the original file
(setf (second info)
(if (and (cdr (assoc :noweb params))
(string= "yes" (cdr (assoc :noweb params))))
(org-babel-expand-noweb-references
info (get-file-buffer org-current-export-file))
(second info)))
(message "info:%S" info)
(org-babel-exp-do-export info 'inline))))
(setq end (+ end (- (length replacement) (length (match-string 1)))))
(replace-match replacement t t nil 1)))))
(unless (org-babel-in-example-or-verbatim)
(let* ((info (save-match-data (org-babel-parse-inline-src-block-match)))
(params (third info))
(replacement
(save-match-data
;; expand noweb references in the original file
(setf (second info)
(if (and (cdr (assoc :noweb params))
(string= "yes" (cdr (assoc :noweb params))))
(org-babel-expand-noweb-references
info (get-file-buffer org-current-export-file))
(second info)))
(message "info:%S" info)
(org-babel-exp-do-export info 'inline))))
(setq end (+ end (- (length replacement) (length (match-string 1)))))
(replace-match replacement t t nil 1))))))
(defun org-babel-in-example-or-verbatim ()
"Return true if the point is currently in an escaped portion of
an org-mode buffer code which should be treated as normal
org-mode text."
(or (org-in-indented-comment-line)
(save-excursion
(save-match-data
(goto-char (point-at-bol))
(looking-at "[ \t]*:[ \t]")))
(org-in-regexps-block-p "^[ \t]*#\\+begin_src" "^[ \t]*#\\+end_src")))
(defun org-babel-exp-lob-one-liners (start end)
"Process #+lob (Library of Babel) calls between START and END for export.