Message ID | 20220503114301.9524-5-attila@lendvai.name |
---|---|
State | New |
Headers | show |
Series | None | expand |
Attila Lendvai schreef op di 03-05-2022 om 13:42 [+0200]: > (sxml-match sxml-node > - ((strong ,text) > - (format #f "@strong{~a}" text)) > - ((a (@ (href ,url)) ,text) > - (format #f "@url{~a,~a}" url text)) > - ((code ,text) > - (format #f "@code{~a}" text)) > - (,something-else something-else))) > + ((strong ,text) > + (format #f "@strong{~a}" text)) Do we know for sure here that 'text' is actually a string? What if the input was (strong (em (a (href "http://super") "Super") emphasis")? > + ((a (@ (href ,url)) ,body) > + ;; Examples: image in the url: github.com/go-openapi/jsonpointer > + ;; (code ...) in the URL body: github.com/mwitkow/go-conntrack > + (if (string? body) > + (format #f "@url{~a,~a}" url body) > + (sxml-match body > + ((code ,text) > + (format #f "@url{~a,~a}" url (sxml->texi body))) > + (,_ I'm not familiar enough with sxml to be sure, but maybe the , can be removed here. > + (format #f "@url{~a}" url))))) > + ((code ,text) > + (format #f "@code{~a}" text)) > + (,something-else > + ;; Example: @ in the description: github.com/ethersphere/langos > + (if (string? something-else) > + (string-replace-substring something-else > + "@" "@@") > + something-else)))) Anyway, more cases are nice, but I recommend tests. Greetings, Maxime.
diff --git a/guix/import/go.scm b/guix/import/go.scm index a115c61adc..6b0fbaa8b6 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -172,13 +172,26 @@ (define (sxml->texi sxml-node) "A very basic SXML to Texinfo converter which attempts to preserve HTML formatting and links as text." (sxml-match sxml-node - ((strong ,text) - (format #f "@strong{~a}" text)) - ((a (@ (href ,url)) ,text) - (format #f "@url{~a,~a}" url text)) - ((code ,text) - (format #f "@code{~a}" text)) - (,something-else something-else))) + ((strong ,text) + (format #f "@strong{~a}" text)) + ((a (@ (href ,url)) ,body) + ;; Examples: image in the url: github.com/go-openapi/jsonpointer + ;; (code ...) in the URL body: github.com/mwitkow/go-conntrack + (if (string? body) + (format #f "@url{~a,~a}" url body) + (sxml-match body + ((code ,text) + (format #f "@url{~a,~a}" url (sxml->texi body))) + (,_ + (format #f "@url{~a}" url))))) + ((code ,text) + (format #f "@code{~a}" text)) + (,something-else + ;; Example: @ in the description: github.com/ethersphere/langos + (if (string? something-else) + (string-replace-substring something-else + "@" "@@") + something-else)))) (define (go-package-description name) "Retrieve a short description for NAME, a Go package name,