Browse Source

org-element: Fix parsing of bold objects at the beginning of a headline

* lisp/org-element.el (org-element-context): Fix parsing of bold
  objects at the beginning of a headline.
* testing/lisp/test-org-element.el (test-org-element/context): Add
  test.
Nicolas Goaziou 11 years ago
parent
commit
cb22a0355f
2 changed files with 9 additions and 3 deletions
  1. 2 2
      lisp/org-element.el
  2. 7 1
      testing/lisp/test-org-element.el

+ 2 - 2
lisp/org-element.el

@@ -4868,8 +4868,8 @@ Providing it allows for quicker computation."
 	;; their title.
 	((memq type '(headline inlinetask))
 	 (goto-char (org-element-property :begin element))
-	 (skip-chars-forward "* ")
-	 (if (and (>= origin (point)) (< origin (line-end-position)))
+	 (skip-chars-forward "*")
+	 (if (and (> origin (point)) (< origin (line-end-position)))
 	     (narrow-to-region (point) (line-end-position))
 	   (throw 'objects-forbidden element)))
 	;; At a paragraph, a table-row or a verse block, objects are

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

@@ -3076,7 +3076,13 @@ Paragraph \\alpha."
        (org-test-with-temp-text "Some *text with _underline_ text*"
 	 (progn
 	   (search-forward "under")
-	   (org-element-type (org-element-context (org-element-at-point))))))))
+	   (org-element-type (org-element-context (org-element-at-point)))))))
+  ;; Special case: bold object at the beginning of a headline.
+  (should
+   (eq 'bold
+       (org-test-with-temp-text "* *bold*"
+	 (search-forward "bo")
+	 (org-element-type (org-element-context))))))
 
 
 (provide 'test-org-element)