Replace new-line characters in HTML title with space.

Targets #2.
develop
Icedream 2016-06-19 23:31:47 +02:00
parent 6775fe5100
commit ec899f0ddf
1 changed files with 4 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"log"
"net/http"
"net/url"
"regexp"
"strings"
"golang.org/x/net/html"
@ -22,6 +23,8 @@ import (
var (
ErrCorruptedImage = errors.New("Corrupted image.")
rxNewlines = regexp.MustCompile(`(?:\r?\n)*`)
)
const (
@ -105,7 +108,7 @@ func (p *Parser) Parse(u *url.URL, referer *url.URL) (result parsers.ParseResult
title, ok := scrape.Find(root, scrape.ByTag(atom.Title))
if ok {
// Got it!
result.Information[0]["Title"] = scrape.Text(title)
result.Information[0]["Title"] = rxNewlines.ReplaceAllString(scrape.Text(title), " ")
} else {
// No title found
result.Information[0]["Title"] = "(no title)"