diff --git a/main.go b/main.go index fdef2d1..d983d4d 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "os" "fmt" "bufio" + "strings" ) type hlink struct { @@ -39,6 +40,14 @@ func text2link(text string, url string) string { return " " + text + "" } +func line2link(line string) hlink { + sline := strings.Split(line," ") + url:= sline[0][1:] + ".html" + text := strings.Join(sline[1:]," ") + //return " " + text + "" + return hlink{url,text} +} + func writeHTML(title string, body string, links...hlink) { f, _ := os.Create(title + ".html") f.WriteString(head) @@ -79,8 +88,8 @@ func fparse(fname string) Game{ game.Pages = append(game.Pages, Page{Body:cutFirstWord(line)}) fmt.Println(cutFirstWord(line)) case string(line[0]) == "-": - game.Pages[pcount]:Links = append - //fmt.Println("New link") + newLink := line2link(line) + game.Pages[pcount].Links = append(game.Pages[pcount].Links, newLink) } //fmt.Println(firstchar)