Browse Source

org-element: Fix block parsing

* contrib/lisp/org-element.el (org-element-current-element): Fix
  regexp for block boundaries.
* testing/lisp/test-org-element.el (test-org-element/block-switches):
  Fix test.
Nicolas Goaziou 13 years ago
parent
commit
fd5f561a3e
2 changed files with 5 additions and 5 deletions
  1. 4 4
      contrib/lisp/org-element.el
  2. 1 1
      testing/lisp/test-org-element.el

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

@@ -3020,7 +3020,7 @@ it is quicker than its counterpart, albeit more restrictive."
           (let ((type (upcase (match-string 1))))
             (if (save-excursion
                   (re-search-forward
-                   (format "[ \t]*#\\+END_%s\\(?: \\|$\\)" type) nil t))
+                   (format "^[ \t]*#\\+END_%s\\(?: \\|$\\)" type) nil t))
                 (funcall
 		 (intern
 		  (format
@@ -3030,9 +3030,9 @@ it is quicker than its counterpart, albeit more restrictive."
        ;; Inlinetask.
        ((org-at-heading-p) (org-element-inlinetask-parser raw-secondary-p))
        ;; LaTeX Environment or Paragraph if incomplete.
-       ((looking-at "^[ \t]*\\\\begin{")
+       ((looking-at "[ \t]*\\\\begin{")
         (if (save-excursion
-              (re-search-forward "^[ \t]*\\\\end{[^}]*}[ \t]*" nil t))
+              (re-search-forward "[ \t]*\\\\end{[^}]*}[ \t]*" nil t))
             (org-element-latex-environment-parser)
           (org-element-paragraph-parser)))
        ;; Property Drawer.
@@ -3046,7 +3046,7 @@ it is quicker than its counterpart, albeit more restrictive."
           (cond
            ((not (save-excursion
                    (re-search-forward
-                    (format "[ \t]*#\\+END_%s\\(?: \\|$\\)" type) nil t)))
+                    (format "^[ \t]*#\\+END_%s\\(?: \\|$\\)" type) nil t)))
             (org-element-paragraph-parser))
            ((string= type "CENTER") (org-element-center-block-parser))
            ((string= type "QUOTE") (org-element-quote-block-parser))

+ 1 - 1
testing/lisp/test-org-element.el

@@ -128,7 +128,7 @@ Return interpreted string."
 	(should (org-element-property :preserve-indent element))))
     ;; 2. "-n -r -k" combination should number lines, retain labels but
     ;;    not use them in coderefs.
-    (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\N#+END_EXAMPLE"
+    (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\n#+END_EXAMPLE"
       (let ((element (org-element-current-element)))
 	(should (and (org-element-property :number-lines element)
 		     (org-element-property :retain-labels element)