diff options
author | Noah Campbell <noahcampbell@gmail.com> | 2013-09-18 20:15:46 +0400 |
---|---|---|
committer | Noah Campbell <noahcampbell@gmail.com> | 2013-09-18 20:15:46 +0400 |
commit | d8e1834910d2b845ee5066571a61be49a7a1451c (patch) | |
tree | 7ef6b512842a2ea44327cacab18a1d585d81dcef /transform/posttrans_test.go | |
parent | a82efe5bb131f1d4a811d3220c2ce40d56aa9eaf (diff) |
Fix parsing edge case of frontmatter
When the frontmatter contains a - (or other delimiter) close to the
closing frontmatter delimiter, frontmatter detection would fail.
Diffstat (limited to 'transform/posttrans_test.go')
-rw-r--r-- | transform/posttrans_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/transform/posttrans_test.go b/transform/posttrans_test.go index de2d2277c..08fe18c11 100644 --- a/transform/posttrans_test.go +++ b/transform/posttrans_test.go @@ -1,23 +1,23 @@ package transform import ( - "testing" - "strings" "bytes" + "strings" + "testing" ) const H5_JS_CONTENT_DOUBLE_QUOTE = "<!DOCTYPE html><html><head><script src=\"foobar.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href='/foobar'>foobar</a>. Follow up</article></body></html>" const H5_JS_CONTENT_SINGLE_QUOTE = "<!DOCTYPE html><html><head><script src='foobar.js'></script></head><body><nav><h1>title</h1></nav><article>content <a href='/foobar'>foobar</a>. Follow up</article></body></html>" const H5_JS_CONTENT_ABS_URL = "<!DOCTYPE html><html><head><script src=\"http://user@host:10234/foobar.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href=\"https://host/foobar\">foobar</a>. Follow up</article></body></html>" + // URL doesn't recognize authorities. BUG? //const H5_JS_CONTENT_ABS_URL = "<!DOCTYPE html><html><head><script src=\"//host/foobar.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href=\"https://host/foobar\">foobar</a>. Follow up</article></body></html>" const CORRECT_OUTPUT_SRC_HREF = "<!DOCTYPE html><html><head><script src=\"http://base/foobar.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href=\"http://base/foobar\">foobar</a>. Follow up</article></body></html>" - func TestAbsUrlify(t *testing.T) { tests := []struct { - content string + content string expected string }{ {H5_JS_CONTENT_DOUBLE_QUOTE, CORRECT_OUTPUT_SRC_HREF}, @@ -29,13 +29,13 @@ func TestAbsUrlify(t *testing.T) { tr := &Transformer{ BaseURL: "http://base", } - out := new(bytes.Buffer) - err := tr.Apply(strings.NewReader(test.content), out) - if err != nil { - t.Errorf("Unexpected error: %s", err) - } - if test.expected != string(out.Bytes()) { - t.Errorf("Expected:\n%s\nGot:\n%s", test.expected, string(out.Bytes())) + out := new(bytes.Buffer) + err := tr.Apply(strings.NewReader(test.content), out) + if err != nil { + t.Errorf("Unexpected error: %s", err) + } + if test.expected != string(out.Bytes()) { + t.Errorf("Expected:\n%s\nGot:\n%s", test.expected, string(out.Bytes())) + } } } -} |