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
|
||||
@ -12,18 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
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)
|
||||
s := bufio.NewScanner(os.Stdin)
|
||||
inHeader := true
|
||||
inFooter := false
|
||||
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