diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2023-08-28 19:08:38 +0200 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2023-09-17 16:23:46 -0400 |
commit | 20d1c8873b972607d875eaca0558a50140c4b7d4 (patch) | |
tree | 37f2dad0463c71b0d8c3f7f0b7862525243025e8 /guix | |
parent | 23aea14ab9e4c20f08ca1c188a176b64edf36cf5 (diff) |
import-utils: Do not include punctuation when wrapping in @code{}.
* guix/import/utils.scm (beautify-description): Exclude punctuation.
* tests/import-utils.scm: Add new test.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/import/utils.scm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/guix/import/utils.scm b/guix/import/utils.scm index fcd7707482..0cf52cdbde 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -342,7 +342,14 @@ LENGTH characters." (let ((pattern (make-regexp "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z])"))) (match (list-matches pattern word) (() word) - (_ (string-append "@code{" word "}"))))))))) + ((m . rest) + ;; Do not include leading or trailing punctuation. + (let* ((last-text (or (and=> (string-skip-right word char-set:punctuation) 1+) + (string-length word))) + (inner (substring word (match:start m) last-text)) + (pre (string-take word (match:start m))) + (post (substring word last-text (string-length word)))) + (string-append pre "@code{" inner "}" post)))))))))) (words (string-tokenize (string-trim-both description) (char-set-complement |