diff --git a/README.md b/README.md index d96744a..1436a00 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,8 @@ Include this in your emacs settings to get syntax highlighting: ### Destructive operations -* [!cons](#-cons-car-cdr) `(car cdr)` -* [!cdr](#-cdr-list) `(list)` +* [!cons](#cons-car-cdr) `(car cdr)` +* [!cdr](#cdr-list) `(list)` ### Function combinators diff --git a/dev/examples-to-docs.el b/dev/examples-to-docs.el index c8e82de..2353b81 100644 --- a/dev/examples-to-docs.el +++ b/dev/examples-to-docs.el @@ -72,6 +72,14 @@ FUNCTION may reference an elisp function, alias, macro or a subr." docstring (mapconcat 'identity (-take 3 examples) "\n"))))) +(defun docs--chop-prefix (prefix s) + "Remove PREFIX if it is at the start of S." + (let ((pos (length prefix))) + (if (and (>= (length s) (length prefix)) + (string= prefix (substring s 0 pos))) + (substring s pos) + s))) + (defun docs--chop-suffix (suffix s) "Remove SUFFIX if it is at end of S." (let ((pos (- (length suffix)))) @@ -83,7 +91,9 @@ FUNCTION may reference an elisp function, alias, macro or a subr." (defun github-id (command-name signature) (docs--chop-suffix "-" - (replace-regexp-in-string "[^a-zA-Z0-9-]+" "-" (format "%S %S" command-name signature)))) + (replace-regexp-in-string "[^a-zA-Z0-9-]+" "-" (docs--chop-prefix + "!" + (format "%S %S" command-name signature))))) (defun s-replace (old new s) "Replaces OLD with NEW in S."