Nearly done with download :)

This commit is contained in:
Belac Darkstorm
2017-04-09 01:26:31 -05:00
parent 01556c1eb0
commit 695ce815d9
7 changed files with 221 additions and 19 deletions
+10 -10
View File
@@ -1,25 +1,25 @@
//Package appimg is to download and update AppImages for LinuxPA.
//Converted from github.com/CalebQ42/bbConvert
package appimg
import "reflect"
//Convert converts the input string. Only returns <a> tags
func Convert(in string) (out []Tag) {
func convert(in string) (out []tag) {
for i := 0; i < len(in); i++ {
v := in[i]
if v == '<' {
for j := i; j < len(in); j++ {
val := in[j]
if val == '>' {
var tmp Tag
var tmp tag
tmp.process(in[i+1 : j+1])
if !tmp.end {
if !tmp.end && tmp.typ == "a" {
tmp.index[0] = i
tmp.index[1] = j
nd := fndend(tmp, in[j+1:])
if !reflect.DeepEqual(nd, Tag{}) && tmp.typ == "a" {
if !reflect.DeepEqual(nd, tag{}) {
tmp.Meat = in[j+1 : nd.index[0]]
out = append(out, tmp)
str := in[tmp.index[1]:nd.index[0]]
in = in[:i] + str + in[nd.index[1]+1:]
}
}
break
@@ -30,13 +30,13 @@ func Convert(in string) (out []Tag) {
return
}
func fndend(fnt Tag, area string) Tag {
func fndend(fnt tag, area string) tag {
var count int
for i, v := range area {
if v == '<' {
for j, val := range area[i:] {
if val == '>' {
var tmp Tag
var tmp tag
tmp.process(area[i+1 : i+j+1])
if tmp.typ == fnt.typ {
if tmp.end {
@@ -56,5 +56,5 @@ func fndend(fnt Tag, area string) Tag {
}
}
}
return Tag{}
return tag{}
}