[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org ec23993301 2/3: lisp/ox.el: Ignore case when matchi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org ec23993301 2/3: lisp/ox.el: Ignore case when matching headings and targets |
Date: |
Sat, 14 Oct 2023 06:58:42 -0400 (EDT) |
branch: externals/org
commit ec23993301e5ed051dc8aedb28ecb680e3d73620
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
lisp/ox.el: Ignore case when matching headings and targets
* lisp/ox.el (org-export-search-cells):
(org-export-string-to-search-cell): Ignore case in headline titles and
radio targets.
* testing/lisp/test-ox.el (test-org-export/fuzzy-link): Add new test.
ox.el implements an independent link resolution mechanism that is not
fully consistent with ol.el. In particular, radio links, when
resolved via `org-export-resolve-link' (unlike
`org-export-resolve-radio-link'), were previously case-sensitive, in
contrast with ol.el, which is case-insensitive. Similarly, headline
matching by fuzzy links had inconsistency between `org-link-search'
and what ox.el does.
Link: https://orgmode.org/list/m2cyxl3qd0.fsf@me.com
---
lisp/ox.el | 28 +++++++++++++++++++---------
testing/lisp/test-ox.el | 6 ++++++
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 1e7e7e4b24..8df160488d 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -4410,13 +4410,14 @@ A search cell follows the pattern (TYPE . SEARCH) where
- NAME or RESULTS affiliated keyword if TYPE is `other'.
A search cell is the internal representation of a fuzzy link. It
-ignores white spaces and statistics cookies, if applicable."
+ignores case, white spaces, and statistics cookies, if applicable."
(pcase (org-element-type datum)
(`headline
- (let ((title (split-string
- (replace-regexp-in-string
- "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" " "
- (org-element-property :raw-value datum)))))
+ (let ((title (mapcar #'upcase
+ (split-string
+ (replace-regexp-in-string
+ "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" " "
+ (org-element-property :raw-value datum))))))
(delq nil
(list
(cons 'headline title)
@@ -4424,7 +4425,9 @@ ignores white spaces and statistics cookies, if
applicable."
(let ((custom-id (org-element-property :custom-id datum)))
(and custom-id (cons 'custom-id custom-id)))))))
(`target
- (list (cons 'target (split-string (org-element-property :value datum)))))
+ (list (cons 'target
+ (mapcar #'upcase
+ (split-string (org-element-property :value datum))))))
((and (let name (or (org-element-property :name datum)
(car (org-element-property :results datum))))
(guard name))
@@ -4435,12 +4438,19 @@ ignores white spaces and statistics cookies, if
applicable."
"Return search cells associated to string S.
S is either the path of a fuzzy link or a search option, i.e., it
tries to match either a headline (through custom ID or title),
-a target or a named element."
+a target or a named element.
+
+The title match is case-insensitive."
(pcase (string-to-char s)
- (?* (list (cons 'headline (split-string (substring s 1)))))
+ (?* (list (cons 'headline (mapcar #'upcase (split-string (substring s
1))))))
(?# (list (cons 'custom-id (substring s 1))))
((let search (split-string s))
- (list (cons 'target search) (cons 'other search)))))
+ (cl-remove-duplicates
+ (list (cons 'target search)
+ (cons 'other search)
+ (cons 'target (mapcar #'upcase search))
+ (cons 'other (mapcar #'upcase search)))
+ :test #'equal))))
(defun org-export-match-search-cell-p (datum cells)
"Non-nil when DATUM matches search cells CELLS.
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 4ba0ba0325..e59c20caef 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -3340,6 +3340,12 @@
Paragraph[fn:1][fn:2][fn:lbl3:C<<target>>][[test]][[target]]
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)))
+ ;; Case is not significant when matching headings and radio targets.
+ (should
+ (org-test-with-parsed-data "* Head line\n[[head line]]"
(org-element-map tree 'link
(lambda (link) (org-export-resolve-fuzzy-link link info))
info t))))