Преглед на файлове

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.
Nicolas Goaziou преди 12 години
родител
ревизия
f33d90fb28
променени са 2 файла, в които са добавени 16 реда и са изтрити 2 реда
  1. 5 2
      lisp/ox.el
  2. 11 0
      testing/lisp/test-ox.el

+ 5 - 2
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)))))

+ 11 - 0
testing/lisp/test-ox.el

@@ -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))))