This commit is contained in:
nate smith 2024-04-30 21:18:52 -07:00
parent de1772462f
commit cba908d1fd
2 changed files with 7 additions and 5 deletions

View File

@ -13,7 +13,7 @@ var rootCmd = &cobra.Command{
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, err.Error())
fmt.Fprintf(os.Stderr, err.Error()+"\n")
os.Exit(1)
}
}

View File

@ -71,7 +71,7 @@ func Cutup(opts CutupOpts) error {
}
close(paths)
ixPath := path.Join(opts.CutupDir, "_title_index.csv")
ixPath := path.Join(opts.CutupDir, "_title_index.tsv")
ixFile, err := os.Create(ixPath)
if err != nil {
return fmt.Errorf("could not open '%s': %w", ixPath, err)
@ -110,14 +110,14 @@ func worker(opts CutupOpts, paths <-chan string, sources chan<- string) {
for s.Scan() {
text = strings.TrimSpace(s.Text())
if opts.headerEndCheck(text) {
if inHeader && opts.headerEndCheck(text) {
inHeader = false
if opts.Flavor == "gutenberg" {
title = extractGutenbergTitle(text)
continue
} else {
title = path.Base(p)
}
inHeader = false
}
if inHeader {
continue
@ -140,7 +140,9 @@ func worker(opts CutupOpts, paths <-chan string, sources chan<- string) {
}
for i, r := range text {
if v := shouldBreak(phraseBuff, r); v > 0 {
if len(phraseBuff) > 0 {
phraseBuff = phraseBuff[0 : len(phraseBuff)-v]
}
if len(phraseBuff) >= 10 {
cleaned = clean(phraseBuff)
if len(cleaned) > 0 {