Closed randomwangran closed 1 year ago
例子: /PATH/#"Introducing the AI Language Model Assistant"#.chat
使用 gpt/hugo-slug-as-underscore 后:
gpt/hugo-slug-as-underscore
/PATH/introducing_the_ai_language_model_assistant.chat
附,参考脚本
(defun gpt/hugo-slug-as-underscore (beg end) (interactive "r") (insert (gpt/org-hugo-slug (buffer-substring-no-properties (region-beginning) (region-end)))) (delete-region beg end)) (defun gpt/hugo-slug-as-underscore (beg end) (interactive "r") (insert (gpt/org-hugo-slug (buffer-substring-no-properties (region-beginning) (region-end)))) (delete-region beg end)) (defun gpt/org-hugo-slug (str &optional allow-double-hyphens) "See function `org-hugo-slug'" (let* ((str (downcase str)) (str (replace-regexp-in-string "<\\(?1:[a-z]+\\)[^>]*>.*</\\1>" "" str)) (str (replace-regexp-in-string (concat "\\](" ffap-url-regexp "[^)]+)") "]" str)) (str (replace-regexp-in-string "&" " and " (replace-regexp-in-string "\\." " dot " (replace-regexp-in-string "\\+" " plus " str)))) (str (replace-regexp-in-string "[^[:alnum:]()]" " " str)) (str (if (version< emacs-version "25.0") (let ((multibyte-punctuations-str ":")) (replace-regexp-in-string (format "[%s]" multibyte-punctuations-str) " " str)) str)) (str (replace-regexp-in-string "\\(^[[:space:]]*\\|[[:space:]]*$\\)" "" str)) (str (replace-regexp-in-string "[[:space:]]\\{2,\\}" " " str)) (str (replace-regexp-in-string "\\s-*([[:space:]]*\\([^)]+?\\)[[:space:]]*)\\s-*" " -\\1- " str)) (str (replace-regexp-in-string "[()]" "" str)) (str (replace-regexp-in-string " " "_" str)) (str (replace-regexp-in-string "\\(^[-]*\\|[-]*$\\)" "" str))) (unless allow-double-hyphens (setq str (replace-regexp-in-string "--" "_" str))) str))
不增加一些特殊的字符,我怎么知道这个文件名已经被自动分析标题了?
如果没有这些特殊的字符,那每次都要重新去分析标题,其实挺浪费ChatGPT流量的
例子: /PATH/#"Introducing the AI Language Model Assistant"#.chat
使用
gpt/hugo-slug-as-underscore
后:/PATH/introducing_the_ai_language_model_assistant.chat
附,参考脚本