1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2025-02-02 20:55:13 +00:00

org-babel: fix inline source block regexp

This satisfies the requirements that
1. the src_lang{} construct is preceded by whitespace
2. this whitespace is not consumed by the replacement text
This commit is contained in:
Dan Davison 2009-10-26 22:08:34 -04:00 committed by Eric Schulte
parent 512b376bb5
commit 962a1e0608
2 changed files with 10 additions and 9 deletions

View File

@ -74,8 +74,8 @@ 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))))
(setq end (+ end (- (length replacement) (length (match-string 0)))))
(replace-match replacement t t)))))
(setq end (+ end (- (length replacement) (length (match-string 1)))))
(replace-match replacement t t nil 1)))))
(defun org-babel-exp-lob-one-liners (start end)
"Process #+lob (Library of Babel) calls between START and END for export.

View File

@ -115,11 +115,13 @@ then run `org-babel-pop-to-session'."
"\\([ \t]+\\([^\n]+\\)\\)?\n" ;; match header arguments
"\\([^\000]+?\\)#\\+end_src"))
(setq org-babel-inline-src-block-regexp
(concat "[ \t\n]src_\\("
(concat "[ \f\t\n\r\v]\\(src_" ;; (1) replacement target
"\\(" ;; (2) lang
(mapconcat 'regexp-quote value "\\|")
"\\)"
"\\(\\|\\[\\(.*\\)\\]\\)"
"{\\([^\n]+\\)}\\(?:[ \t\n]\\|\\'\\)")))
"\\(\\|\\[\\(.*\\)\\]\\)" ;; (3,4) (unused, headers)
"{\\([^\f\n\r\v]+\\)}" ;; (5) body
"\\)")))
(defun org-babel-add-interpreter (interpreter)
"Add INTERPRETER to `org-babel-interpreters' and update
@ -333,7 +335,6 @@ of the following form. (language body header-arguments-alist)"
(save-excursion (goto-char head) (org-babel-parse-src-block-match))
(if (save-excursion ;; inline source block
(re-search-backward "[ \f\t\n\r\v]" nil t)
(forward-char 1)
(looking-at org-babel-inline-src-block-regexp))
(org-babel-parse-inline-src-block-match)
nil)))) ;; indicate that no source block was found
@ -388,15 +389,15 @@ may be specified in the properties of the current outline entry."
(org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 3) "")))))))
(defun org-babel-parse-inline-src-block-match ()
(let* ((lang (org-babel-clean-text-properties (match-string 1)))
(let* ((lang (org-babel-clean-text-properties (match-string 2)))
(lang-headers (intern (concat "org-babel-default-header-args:" lang))))
(list lang
(org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 4)))
(org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 5)))
(org-babel-merge-params
org-babel-default-inline-header-args
(org-babel-params-from-properties)
(if (boundp lang-headers) (eval lang-headers) nil)
(org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 3) "")))))))
(org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 4) "")))))))
(defun org-babel-parse-header-arguments (arg-string)
"Parse a string of header arguments returning an alist."