Browse Source

org-exp-blocks: match blocks with empty bodies

* lisp/org-exp-blocks.el (org-exp-blocks-block-regexp): Wrapping block
  regexp into its own variable, also allowing match of empty bodies.
  (org-export-blocks-preprocess): Using new regexp variable.
Eric Schulte 14 years ago
parent
commit
94d19488cb
1 changed files with 8 additions and 2 deletions
  1. 8 2
      lisp/org-exp-blocks.el

+ 8 - 2
lisp/org-exp-blocks.el

@@ -76,6 +76,13 @@
   (require 'cl))
 (require 'org)
 
+(defvar org-exp-blocks-block-regexp
+  (concat
+   "^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)"
+   "[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)[\r\n]*[ \t]*"
+   "#\\+end_\\S-+.*[\r\n]?")
+  "Regular expression used to match blocks by org-exp-blocks.")
+
 (defun org-export-blocks-set (var value)
   "Set the value of `org-export-blocks' and install fontification."
   (set var value)
@@ -174,8 +181,7 @@ which defaults to the value of `org-export-blocks-witheld'."
 				 org-export-interblocks)))
 	(goto-char (point-min))
 	(setq start (point))
-	(while (re-search-forward
-		"^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)[\r\n][ \t]*#\\+end_\\S-+.*[\r\n]?" nil t)
+	(while (re-search-forward org-exp-blocks-block-regexp nil t)
           (setq indentation (length (match-string 1)))
 	  (setq type (intern (downcase (match-string 2))))
 	  (setq headers (save-match-data (org-split-string (match-string 3) "[ \t]+")))