mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 15:36:20 -05:00
import: go: Do not set '%strict-tokenizer?' from the top level.
This avoids interference with other users of (htmlprag) and makes the intent clearer. * guix/import/go.scm <top level>: Remove call to '%strict-tokenizer?'. (go-package-licenses, go-package-description) (go-package-synopsis, fetch-module-meta-data): Pass #:strict? #t to 'html->sxml'.
This commit is contained in:
parent
ee990899bd
commit
9406bb12ee
1 changed files with 4 additions and 7 deletions
|
@ -63,9 +63,6 @@ (define-module (guix import go)
|
||||||
#:export (go-module->guix-package
|
#:export (go-module->guix-package
|
||||||
go-module-recursive-import))
|
go-module-recursive-import))
|
||||||
|
|
||||||
;;; Parameterize htmlprag to parse valid HTML more reliably.
|
|
||||||
(%strict-tokenizer? #t)
|
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;;
|
;;;
|
||||||
;;; (guix import go) attempts to make it easier to create Guix package
|
;;; (guix import go) attempts to make it easier to create Guix package
|
||||||
|
@ -149,7 +146,7 @@ (define (go-package-licenses name)
|
||||||
;; element marked with a "License" class attribute.
|
;; element marked with a "License" class attribute.
|
||||||
(select (sxpath `(// (* (@ (equal? (class "License"))))
|
(select (sxpath `(// (* (@ (equal? (class "License"))))
|
||||||
h2 // *text*))))
|
h2 // *text*))))
|
||||||
(select (html->sxml body))))
|
(select (html->sxml body #:strict? #t))))
|
||||||
|
|
||||||
(define (sxml->texi sxml-node)
|
(define (sxml->texi sxml-node)
|
||||||
"A very basic SXML to Texinfo converter which attempts to preserve HTML
|
"A very basic SXML to Texinfo converter which attempts to preserve HTML
|
||||||
|
@ -167,7 +164,7 @@ (define (go-package-description name)
|
||||||
"Retrieve a short description for NAME, a Go package name,
|
"Retrieve a short description for NAME, a Go package name,
|
||||||
e.g. \"google.golang.org/protobuf/proto\"."
|
e.g. \"google.golang.org/protobuf/proto\"."
|
||||||
(let* ((body (go.pkg.dev-info name))
|
(let* ((body (go.pkg.dev-info name))
|
||||||
(sxml (html->sxml body))
|
(sxml (html->sxml body #:strict? #t))
|
||||||
(overview ((sxpath
|
(overview ((sxpath
|
||||||
`(//
|
`(//
|
||||||
(* (@ (equal? (class "Documentation-overview"))))
|
(* (@ (equal? (class "Documentation-overview"))))
|
||||||
|
@ -209,7 +206,7 @@ (define (go-package-synopsis module-name)
|
||||||
(select-title (sxpath
|
(select-title (sxpath
|
||||||
`(// (div (@ (equal? (class "UnitReadme-content"))))
|
`(// (div (@ (equal? (class "UnitReadme-content"))))
|
||||||
// h3 *text*))))
|
// h3 *text*))))
|
||||||
(match (select-title (html->sxml body))
|
(match (select-title (html->sxml body #:strict? #t))
|
||||||
(() #f) ;nothing selected
|
(() #f) ;nothing selected
|
||||||
((title more ...) ;title is the first string of the list
|
((title more ...) ;title is the first string of the list
|
||||||
(string-trim-both title)))))
|
(string-trim-both title)))))
|
||||||
|
@ -465,7 +462,7 @@ (define (fetch-module-meta-data module-path)
|
||||||
(let* ((meta-data (http-fetch* (format #f "https://~a?go-get=1" module-path)))
|
(let* ((meta-data (http-fetch* (format #f "https://~a?go-get=1" module-path)))
|
||||||
(select (sxpath `(// head (meta (@ (equal? (name "go-import"))))
|
(select (sxpath `(// head (meta (@ (equal? (name "go-import"))))
|
||||||
// content))))
|
// content))))
|
||||||
(match (select (html->sxml meta-data))
|
(match (select (html->sxml meta-data #:strict? #t))
|
||||||
(() #f) ;nothing selected
|
(() #f) ;nothing selected
|
||||||
(((content content-text))
|
(((content content-text))
|
||||||
(match (string-split content-text #\space)
|
(match (string-split content-text #\space)
|
||||||
|
|
Loading…
Reference in a new issue