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:
parent
dffdc499ea
commit
60899b1a2f
|
@ -4050,7 +4050,8 @@ significant."
|
||||||
(let ((foundp (funcall find-headline path parent)))
|
(let ((foundp (funcall find-headline path parent)))
|
||||||
(when foundp (throw 'exit foundp))))
|
(when foundp (throw 'exit foundp))))
|
||||||
(let ((parent-hl (org-export-get-parent-headline link)))
|
(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.
|
;; No destination found: return nil.
|
||||||
(and (not match-title-p) (puthash path nil link-cache))))))))
|
(and (not match-title-p) (puthash path nil link-cache))))))))
|
||||||
|
|
||||||
|
|
|
@ -1642,7 +1642,14 @@ Another text. (ref:text)
|
||||||
(should-not
|
(should-not
|
||||||
(org-test-with-parsed-data "[[target]]"
|
(org-test-with-parsed-data "[[target]]"
|
||||||
(org-export-resolve-fuzzy-link
|
(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 ()
|
(ert-deftest test-org-export/resolve-id-link ()
|
||||||
"Test `org-export-resolve-id-link' specifications."
|
"Test `org-export-resolve-id-link' specifications."
|
||||||
|
|
Loading…
Reference in New Issue