This commit is contained in:
nate smith 2024-01-31 21:46:43 -08:00
parent 6a710a4867
commit c508d152d2
2 changed files with 8 additions and 13 deletions

View File

@ -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

View File

@ -63,3 +63,9 @@ func main() {
}
}
}
func clean(s string) string {
s = strings.ReplaceAll(s, "", "'")
return s
}