Fix parsing of links without names
This commit is contained in:
parent
fbc1f76194
commit
a8b63b5982
5
text.go
5
text.go
@ -78,10 +78,15 @@ func Parse(r io.Reader) Text {
|
||||
line = line[2:]
|
||||
line = strings.TrimLeft(line, spacetab)
|
||||
split := strings.IndexAny(line, spacetab)
|
||||
if split == -1 {
|
||||
// line is a URL
|
||||
t = append(t, LineLink{URL: line})
|
||||
} else {
|
||||
url := line[:split]
|
||||
name := line[split:]
|
||||
name = strings.TrimLeft(name, spacetab)
|
||||
t = append(t, LineLink{url, name})
|
||||
}
|
||||
} else if strings.HasPrefix(line, "*") {
|
||||
line = line[1:]
|
||||
line = strings.TrimLeft(line, spacetab)
|
||||
|
Loading…
Reference in New Issue
Block a user