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
This commit is contained in:
parent
ed42dc34a8
commit
ec23993301
28
lisp/ox.el
28
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.
|
||||
|
|
|
@ -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))))
|
||||
|
|
Loading…
Reference in New Issue