1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-02 08:22:16 +00:00

ox: Fuzzy link matching ignores statistics cookies

* lisp/ox.el (org-export-resolve-fuzzy-link): Ignore statistics
  cookies when matching an headline.
* testing/lisp/test-ox.el: Add test.
This commit is contained in:
Nicolas Goaziou 2013-02-16 15:05:45 +01:00
parent 9c4d403ada
commit f33d90fb28
2 changed files with 16 additions and 2 deletions

View File

@ -3696,12 +3696,15 @@ significant."
(let ((find-headline
(function
;; Return first headline whose `:raw-value' property is
;; NAME in parse tree DATA, or nil.
;; NAME in parse tree DATA, or nil. Statistics cookies
;; are ignored.
(lambda (name data)
(org-element-map data 'headline
(lambda (headline)
(when (equal (org-split-string
(org-element-property :raw-value headline))
(replace-regexp-in-string
"\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
(org-element-property :raw-value headline)))
name)
headline))
info 'first-match)))))

View File

@ -1267,6 +1267,17 @@ Paragraph[1][2][fn:lbl3:C<<target>>][[test]][[target]]\n[1] A\n\n[2] <<test>>B"
;; 7. Space are not significant when matching a fuzzy link.
(should
(org-test-with-parsed-data "* Head 1\n[[Head\n 1]]"
(org-element-map tree 'link
(lambda (link) (org-export-resolve-fuzzy-link link info))
info t)))
;; 8. Statistics cookies are ignored for headline match.
(should
(org-test-with-parsed-data "* Head [0/0]\n[[Head]]"
(org-element-map tree 'link
(lambda (link) (org-export-resolve-fuzzy-link link info))
info t)))
(should
(org-test-with-parsed-data "* Head [100%]\n[[Head]]"
(org-element-map tree 'link
(lambda (link) (org-export-resolve-fuzzy-link link info))
info t))))