diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2023-07-19 15:53:28 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2023-07-19 15:53:28 +0200 |
commit | b9bd1bcce995299065252e192c96ae302c9b0e81 (patch) | |
tree | 8add1afbca906486a97e64342d1537ef1f96478c /guix/import | |
parent | 5566f691a28789e8a73be3b9549db0296b30c665 (diff) |
import/utils: beautify-description: Wrap class names in @code{...}.
* guix/import/utils.scm (beautify-description): Add procedure to wrap words in
@code{...} markup.
* tests/import-utils.scm: Add two tests.
Diffstat (limited to 'guix/import')
-rw-r--r-- | guix/import/utils.scm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 2ffc13bae3..257570e95b 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -335,7 +335,13 @@ LENGTH characters." (cut string-trim-both <> #\') ;; Escape single @ to prevent it from being understood as ;; invalid Texinfo syntax. - (cut regexp-substitute/global #f "@" <> 'pre "@@" 'post))))) + (cut regexp-substitute/global #f "@" <> 'pre "@@" 'post) + ;; Wrap camelCase or PascalCase words in @code{...}. + (lambda (word) + (let ((pattern (make-regexp "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z])"))) + (match (list-matches pattern word) + (() word) + (_ (string-append "@code{" word "}"))))))))) (words (string-tokenize (string-trim-both description) (char-set-complement |