ugly but working
This commit is contained in:
parent
50fdd4687e
commit
bbc7167319
25
main.go
25
main.go
|
@ -60,6 +60,26 @@ func writeHTML(title string, body string, links...hlink) {
|
||||||
f.WriteString(tail)
|
f.WriteString(tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
type Page struct {
|
||||||
|
Body string
|
||||||
|
Links []hlink
|
||||||
|
URL string
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func page2html(page Page) {
|
||||||
|
f, _ := os.Create(page.URL)
|
||||||
|
f.WriteString(head)
|
||||||
|
f.WriteString(" <p>"+ page.Body +"</p>")
|
||||||
|
f.WriteString("\n <br>\n")
|
||||||
|
for _,link := range(page.Links){
|
||||||
|
f.WriteString(text2link(link.text,link.url))
|
||||||
|
}
|
||||||
|
f.WriteString(tail)
|
||||||
|
f.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func cutFirstWord(w string) string {
|
func cutFirstWord(w string) string {
|
||||||
splitLine := strings.Split(w, " ")
|
splitLine := strings.Split(w, " ")
|
||||||
return strings.Join(splitLine[1:], " ")
|
return strings.Join(splitLine[1:], " ")
|
||||||
|
@ -98,13 +118,14 @@ func fparse(fname string) Game{
|
||||||
|
|
||||||
func game2html(game Game) {
|
func game2html(game Game) {
|
||||||
for p := 0; p < len(game.Pages); p++ {
|
for p := 0; p < len(game.Pages); p++ {
|
||||||
fmt.Println(game.Pages[p])
|
//fmt.Println(game.Pages[p])
|
||||||
|
page2html(game.Pages[p])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
game := fparse("model")
|
game := fparse("model")
|
||||||
//fmt.Println(len(game.Pages))
|
fmt.Println(len(game.Pages))
|
||||||
game2html(game)
|
game2html(game)
|
||||||
/*
|
/*
|
||||||
l1 := hlink{url:"01.html",text:"First"}
|
l1 := hlink{url:"01.html",text:"First"}
|
||||||
|
|
Loading…
Reference in New Issue