Function: hywiki-wikiword-to-string

hywiki-wikiword-to-string is a byte-compiled function defined in hywiki.el.

Signature

(hywiki-wikiword-to-string STR &optional SEPARATOR)

Documentation

Convert a PascalCase HyWikiWord to a lowercase dash-separated string.

With optional SEPARATOR string, use that instead of a dash between words.

For example, hy-wiki-word. Contiguous capital letters followed by a lower-case letter are split before the last capital letter. For example, BASEBall would become, base-ball but BASE would become base.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260822.1645/hywiki.el
(defun hywiki-wikiword-to-string (str &optional separator)
  "Convert a PascalCase HyWikiWord to a lowercase dash-separated string.
With optional SEPARATOR string, use that instead of a dash between words.

For example, hy-wiki-word.  Contiguous capital letters followed
by a lower-case letter are split before the last capital letter.
For example, BASEBall would become, base-ball but BASE would become base."
  (unless (stringp str)
    (error "(hywiki-wikiword-to-string): `str' must be a string, not `%s'" str))
  (when (null separator) (setq separator "-"))
  (let* ((sep-regexp (regexp-quote separator))
         (sep-replacement (format "\\1%s\\2" sep-regexp)))
    (unless (string-match-p sep-regexp str)
      (setq str (replace-regexp-in-string "\\([a-z]\\)\\([A-Z]\\)"
					  sep-replacement str)
	    str (replace-regexp-in-string "\\([A-Z]\\)\\([A-Z][a-z]\\)"
					  sep-replacement str)))
    (string-trim (downcase str) "[ \t\n\r]+" (format "[%s \t\n\r]+"
                                                     separator))))