Only extract the first element as title
This commit is contained in:
25
readability_test.go
Normal file
25
readability_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package readability_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.kopis.de/carsten/readability"
|
||||
)
|
||||
|
||||
func TestFullHtml(t *testing.T) {
|
||||
b, err := os.ReadFile("test1.html")
|
||||
if err != nil {
|
||||
t.Fatal("Can not read file")
|
||||
}
|
||||
|
||||
reader := bytes.NewReader(b)
|
||||
title, _, err := readability.ExtractContent(".", reader)
|
||||
if err != nil {
|
||||
t.Fatal("Can not extract content")
|
||||
}
|
||||
if title != "The Verge" {
|
||||
t.Fatalf("Unexpected title: %s", title)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user