From f33d90fb28500b5794905af75a457f39232b13fd Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 16 Feb 2013 15:05:45 +0100 Subject: [PATCH] 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. --- lisp/ox.el | 7 +++++-- testing/lisp/test-ox.el | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index bb3433116..81f93cc2c 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -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))))) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 34174aab6..c33d68e90 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -1267,6 +1267,17 @@ Paragraph[1][2][fn:lbl3:C<>][[test]][[target]]\n[1] A\n\n[2] <>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))))