mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
67df33f500
First step to use initialisms that golint suggests, for example: Line 116: func GetHtmlRenderer should be GetHTMLRenderer as see on http://goreportcard.com/report/spf13/hugo Thanks to @bep for the idea! Note that command-line flags (cobra and pflag) as well as struct fields like .BaseUrl and .Url that are used in Go HTML templates need more work to maintain backward-compatibility, and thus are NOT yet dealt with in this commit. First step in fixing #959.
33 lines
621 B
Go
33 lines
621 B
Go
package transform
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
var absURLInit sync.Once
|
|
var ar *absURLReplacer
|
|
|
|
// for performance reasons, we reuse the first baseUrl given
|
|
func initAbsurlReplacer(baseURL string) {
|
|
absURLInit.Do(func() {
|
|
ar = newAbsurlReplacer(baseURL)
|
|
})
|
|
}
|
|
|
|
func AbsURL(absURL string) (trs []link, err error) {
|
|
initAbsurlReplacer(absURL)
|
|
|
|
trs = append(trs, func(content []byte) []byte {
|
|
return ar.replaceInHTML(content)
|
|
})
|
|
return
|
|
}
|
|
|
|
func AbsURLInXML(absURL string) (trs []link, err error) {
|
|
initAbsurlReplacer(absURL)
|
|
|
|
trs = append(trs, func(content []byte) []byte {
|
|
return ar.replaceInXML(content)
|
|
})
|
|
return
|
|
}
|