minor bugfixes and cleanup

This commit is contained in:
ston1th 2018-09-19 00:10:16 +02:00
commit 97d914bce4
26 changed files with 198 additions and 221 deletions

View file

@ -22,7 +22,6 @@ func makeFilter() analysis.CharFilter {
}
var (
//reHeader = regexp.MustCompile("(<h[1-6])>(.+)(</h[1-6]>)")
reHeader = regexp.MustCompile("(<h[1-6]>)(.+)(</h[1-6]>)")
reLink = regexp.MustCompile(`id="(.+?)"`)
whiteSpace = regexp.MustCompile(`\s+`)
@ -64,7 +63,6 @@ func buildIndex(html string) (string, string) {
var ret string
m := make(map[string]int)
hn := reIndex.FindAllStringSubmatch(html, -1)
//html = reHeader.ReplaceAllString(html, `${1} id="${2}">${2}${3}`)
html = reHeader.ReplaceAllString(html, `<a id="${2}" class="anchor"></a>${1}${2}${3}`)
html = reLink.ReplaceAllStringFunc(html, spaceReplace)
for k, v := range hn {
@ -126,11 +124,3 @@ func closeTag(j int) (ret string) {
}
return
}
func renderResult(res []core.Result) (html string) {
for _, r := range res {
html += `<a href="/` + r.StoreTitle + `"><b>` + r.Title + "</b></a>" +
`<pre style="white-space: pre-wrap">` + r.Text + "</pre><br>"
}
return
}