ox: Fix fuzzy link resolution before first headline

* lisp/ox.el (org-export-resolve-fuzzy-link): Fix link resolution when
  link lives before the first headline.
* testing/lisp/test-ox.el: Add test.
This commit is contained in:
Nicolas Goaziou 2013-06-18 22:27:39 +02:00
parent dffdc499ea
commit 60899b1a2f
2 changed files with 10 additions and 2 deletions

View File

@ -4050,7 +4050,8 @@ significant."
(let ((foundp (funcall find-headline path parent)))
(when foundp (throw 'exit foundp))))
(let ((parent-hl (org-export-get-parent-headline link)))
(cons parent-hl (org-export-get-genealogy parent-hl))))
(if (not parent-hl) (list (plist-get info :parse-tree))
(cons parent-hl (org-export-get-genealogy parent-hl)))))
;; No destination found: return nil.
(and (not match-title-p) (puthash path nil link-cache))))))))

View File

@ -1642,7 +1642,14 @@ Another text. (ref:text)
(should-not
(org-test-with-parsed-data "[[target]]"
(org-export-resolve-fuzzy-link
(org-element-map tree 'link 'identity info t) info))))
(org-element-map tree 'link 'identity info t) info)))
;; Match fuzzy link even when before first headline.
(should
(eq 'headline
(org-test-with-parsed-data "[[hl]]\n* hl"
(org-element-type
(org-export-resolve-fuzzy-link
(org-element-map tree 'link 'identity info t) info))))))
(ert-deftest test-org-export/resolve-id-link ()
"Test `org-export-resolve-id-link' specifications."