wip
This commit is contained in:
parent
6a710a4867
commit
c508d152d2
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Given a project gutenberg plaintext book filename, this program prints just its content (ie with header and footer stripped)
|
Given a project gutenberg plaintext book on STDIN, this program prints just its content (ie with header and footer stripped)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
@ -12,18 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) < 2 {
|
s := bufio.NewScanner(os.Stdin)
|
||||||
fmt.Fprintln(os.Stderr, "need a filename argument")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
filename := os.Args[1]
|
|
||||||
f, err := os.Open(filename)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "could not open '%s' for reading\n", filename)
|
|
||||||
os.Exit(2)
|
|
||||||
}
|
|
||||||
|
|
||||||
s := bufio.NewScanner(f)
|
|
||||||
inHeader := true
|
inHeader := true
|
||||||
inFooter := false
|
inFooter := false
|
||||||
skippedAll := true
|
skippedAll := true
|
||||||
|
@ -63,3 +63,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clean(s string) string {
|
||||||
|
s = strings.ReplaceAll(s, "’", "'")
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user