mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-19 03:52:37 +00:00
Code cleanup
This commit is contained in:
parent
19cb6c7819
commit
689cda1740
4 changed files with 10 additions and 11 deletions
|
@ -1,8 +1,8 @@
|
||||||
package target
|
package target
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InMemoryTarget struct {
|
type InMemoryTarget struct {
|
||||||
|
@ -22,4 +22,3 @@ func (t *InMemoryTarget) Publish(label string, reader io.Reader) (err error) {
|
||||||
func (t *InMemoryTarget) Translate(label string) (dest string, err error) {
|
func (t *InMemoryTarget) Translate(label string) (dest string, err error) {
|
||||||
return label, nil
|
return label, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package transform
|
package transform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
type chain struct {
|
type chain struct {
|
||||||
|
@ -23,7 +23,7 @@ func (c *chain) Apply(w io.Writer, r io.Reader) (err error) {
|
||||||
}
|
}
|
||||||
in = bytes.NewBuffer(out.Bytes())
|
in = bytes.NewBuffer(out.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = io.Copy(w, in)
|
_, err = io.Copy(w, in)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ const H5_JS_CONTENT_ABS_URL_WITH_NAV = "<!DOCTYPE html><html><head><script src=\
|
||||||
|
|
||||||
const CORRECT_OUTPUT_SRC_HREF_WITH_NAV = "<!DOCTYPE html><html><head><script src=\"http://two/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\" class=\"active\"></li></ul></nav><article>content <a href=\"http://two/foobar\">foobar</a>. Follow up</article></body></html>"
|
const CORRECT_OUTPUT_SRC_HREF_WITH_NAV = "<!DOCTYPE html><html><head><script src=\"http://two/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\" class=\"active\"></li></ul></nav><article>content <a href=\"http://two/foobar\">foobar</a>. Follow up</article></body></html>"
|
||||||
|
|
||||||
var two_chain_tests = []test {
|
var two_chain_tests = []test{
|
||||||
{H5_JS_CONTENT_ABS_URL_WITH_NAV, CORRECT_OUTPUT_SRC_HREF_WITH_NAV},
|
{H5_JS_CONTENT_ABS_URL_WITH_NAV, CORRECT_OUTPUT_SRC_HREF_WITH_NAV},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,15 @@ func TestAbsUrlify(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type test struct {
|
type test struct {
|
||||||
content string
|
content string
|
||||||
expected string
|
expected string
|
||||||
}
|
}
|
||||||
|
|
||||||
var abs_url_tests = []test {
|
var abs_url_tests = []test{
|
||||||
{H5_JS_CONTENT_DOUBLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
|
{H5_JS_CONTENT_DOUBLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
|
||||||
{H5_JS_CONTENT_SINGLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
|
{H5_JS_CONTENT_SINGLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
|
||||||
{H5_JS_CONTENT_ABS_URL, H5_JS_CONTENT_ABS_URL},
|
{H5_JS_CONTENT_ABS_URL, H5_JS_CONTENT_ABS_URL},
|
||||||
}
|
}
|
||||||
|
|
||||||
func apply(t *testing.T, tr Transformer, tests []test) {
|
func apply(t *testing.T, tr Transformer, tests []test) {
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
Loading…
Reference in a new issue