From 44e45d528498a05156ed0c10be297b984d4fbd2f Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 30 Dec 2015 23:59:57 +0100 Subject: [PATCH] Parse inline src blocks and babel calls with newlines * lisp/org-element.el (org-element--pair-round-table): (org-element--pair-curly-table): New variables. (org-element-inline-babel-call-parser): (org-element-inline-src-block-parser): Allow newline characters in contents and parameters. * testing/lisp/test-org-element.el (test-org-element/inline-babel-call-parser): (test-org-element/inline-src-block-parser): Add test. --- lisp/org-element.el | 121 +++++++++++++++++++++++++++------------ testing/lisp/test-org-element.el | 33 ++++++++++- 2 files changed, 115 insertions(+), 39 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index c7a96b440..d8a78436f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -393,6 +393,15 @@ still has an entry since one of its properties (`:title') does.") (item :tag)) "Alist between element types and locations of secondary values.") +(defconst org-element--pair-round-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\( "()" table) + (modify-syntax-entry ?\) ")(" table) + (dolist (char '(?\{ ?\} ?\[ ?\] ?\< ?\>) table) + (modify-syntax-entry char " " table))) + "Table used internally to pair only round brackets. +Other brackets are treated as spaces.") + (defconst org-element--pair-square-table (let ((table (make-syntax-table))) (modify-syntax-entry ?\[ "(]" table) @@ -402,6 +411,15 @@ still has an entry since one of its properties (`:title') does.") "Table used internally to pair only square brackets. Other brackets are treated as spaces.") +(defconst org-element--pair-curly-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\{ "(}" table) + (modify-syntax-entry ?\} "){" table) + (dolist (char '(?\[ ?\[ ?\( ?\) ?\< ?\>) table) + (modify-syntax-entry char " " table))) + "Table used internally to pair only curly brackets. +Other brackets are treated as spaces.") + ;;; Accessors and Setters @@ -2814,27 +2832,45 @@ When at an inline babel call, return a list whose car is Assume point is at the beginning of the babel call." (save-excursion - (unless (bolp) (backward-char)) - (when (let ((case-fold-search t)) - (looking-at org-babel-inline-lob-one-liner-regexp)) - (let ((begin (match-end 1)) - (call (org-match-string-no-properties 2)) - (inside-header (org-string-nw-p (org-match-string-no-properties 4))) - (arguments (org-string-nw-p (org-match-string-no-properties 6))) - (end-header (org-string-nw-p (org-match-string-no-properties 8))) - (value (buffer-substring-no-properties (match-end 1) (match-end 0))) - (post-blank (progn (goto-char (match-end 0)) - (skip-chars-forward " \t"))) - (end (point))) - (list 'inline-babel-call - (list :call call - :inside-header inside-header - :arguments arguments - :end-header end-header - :begin begin - :end end - :value value - :post-blank post-blank)))))) + (catch :no-object + (when (let ((case-fold-search nil)) + (looking-at + "\\