mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix): remove nonspacing marks from slugs (#230)
Linux and macOS use different Unicode normalization conventions in filenames
This commit is contained in:
11
org-roam.el
11
org-roam.el
@ -562,13 +562,18 @@ specified via the #+ROAM_ALIAS property."
|
||||
|
||||
(defun org-roam--title-to-slug (title)
|
||||
"Convert TITLE to a filename-suitable slug."
|
||||
(cl-flet ((replace (title pair)
|
||||
(replace-regexp-in-string (car pair) (cdr pair) title)))
|
||||
(cl-flet* ((nonspacing-mark-p (char)
|
||||
(eq 'Mn (get-char-code-property char 'general-category)))
|
||||
(strip-nonspacing-marks (s)
|
||||
(apply #'string (seq-remove #'nonspacing-mark-p
|
||||
(ucs-normalize-NFD-string s))))
|
||||
(replace (title pair)
|
||||
(replace-regexp-in-string (car pair) (cdr pair) title)))
|
||||
(let* ((pairs `(("[^[:alnum:][:digit:]]" . "_") ;; convert anything not alphanumeric
|
||||
("__*" . "_") ;; remove sequential underscores
|
||||
("^_" . "") ;; remove starting underscore
|
||||
("_$" . ""))) ;; remove ending underscore
|
||||
(slug (-reduce-from #'replace title pairs)))
|
||||
(slug (-reduce-from #'replace (strip-nonspacing-marks title) pairs)))
|
||||
(s-downcase slug))))
|
||||
|
||||
;;;; Org-roam capture
|
||||
|
Reference in New Issue
Block a user