mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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.
This commit is contained in:
parent
b4c7fe02ae
commit
c8a642de9a
2 changed files with 12 additions and 1 deletions
|
@ -342,7 +342,14 @@ (define* (beautify-description description #:optional (length 80))
|
||||||
(let ((pattern (make-regexp "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z])")))
|
(let ((pattern (make-regexp "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z])")))
|
||||||
(match (list-matches pattern word)
|
(match (list-matches pattern word)
|
||||||
(() 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
|
(words
|
||||||
(string-tokenize (string-trim-both description)
|
(string-tokenize (string-trim-both description)
|
||||||
(char-set-complement
|
(char-set-complement
|
||||||
|
|
|
@ -61,6 +61,10 @@ (define-module (test-import-utils)
|
||||||
"The term API is not code, but @code{myAPI} might be."
|
"The term API is not code, but @code{myAPI} might be."
|
||||||
(beautify-description "The term API is not code, but 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"
|
(test-equal "license->symbol"
|
||||||
'license:lgpl2.0
|
'license:lgpl2.0
|
||||||
(license->symbol license:lgpl2.0))
|
(license->symbol license:lgpl2.0))
|
||||||
|
|
Loading…
Reference in a new issue