[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
10/10: import-utils: Do not include punctuation when wrapping in @code{}
From: |
guix-commits |
Subject: |
10/10: import-utils: Do not include punctuation when wrapping in @code{}. |
Date: |
Mon, 28 Aug 2023 13:10:45 -0400 (EDT) |
rekado pushed a commit to branch master
in repository guix.
commit c8a642de9a7b6c0e21c8327232245ab721822842
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Mon Aug 28 19:08:38 2023 +0200
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.
---
guix/import/utils.scm | 9 ++++++++-
tests/import-utils.scm | 4 ++++
2 files changed, 12 insertions(+), 1 deletion(-)
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
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index 7b078eac05..229e6eafaa 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -61,6 +61,10 @@ Differences are hard to spot, e.g. in CLOS vs. GOOPS."))
"The term API is not code, but @code{myAPI} might be."
(beautify-description "The term API is not code, but myAPI might be."))
+(test-equal "beautify-description: do not include punctuation when wrapping in
@code"
+ "Code (@code{DelayedMatrix}, @code{MaMa}, or @code{MeMe}) should be wrapped."
+ (beautify-description "Code (DelayedMatrix, MaMa, or MeMe) should be
wrapped."))
+
(test-equal "license->symbol"
'license:lgpl2.0
(license->symbol license:lgpl2.0))
- branch master updated (3350e871a8 -> c8a642de9a), guix-commits, 2023/08/28
- 04/10: gnu: Add r-derfinder., guix-commits, 2023/08/28
- 03/10: gnu: Add r-sangerseqr., guix-commits, 2023/08/28
- 02/10: gnu: Add r-rtcga., guix-commits, 2023/08/28
- 08/10: gnu: Add r-sesame., guix-commits, 2023/08/28
- 09/10: gnu: Add r-lea., guix-commits, 2023/08/28
- 05/10: gnu: Add r-rdisop., guix-commits, 2023/08/28
- 07/10: gnu: Add r-sesamedata., guix-commits, 2023/08/28
- 01/10: gnu: Add r-arrayqualitymetrics., guix-commits, 2023/08/28
- 06/10: gnu: Add r-enrichedheatmap., guix-commits, 2023/08/28
- 10/10: import-utils: Do not include punctuation when wrapping in @code{}.,
guix-commits <=