bugfixes
This commit is contained in:
parent
de1772462f
commit
cba908d1fd
@ -13,7 +13,7 @@ var rootCmd = &cobra.Command{
|
|||||||
|
|
||||||
func Execute() {
|
func Execute() {
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error()+"\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func Cutup(opts CutupOpts) error {
|
|||||||
}
|
}
|
||||||
close(paths)
|
close(paths)
|
||||||
|
|
||||||
ixPath := path.Join(opts.CutupDir, "_title_index.csv")
|
ixPath := path.Join(opts.CutupDir, "_title_index.tsv")
|
||||||
ixFile, err := os.Create(ixPath)
|
ixFile, err := os.Create(ixPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not open '%s': %w", ixPath, err)
|
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() {
|
for s.Scan() {
|
||||||
text = strings.TrimSpace(s.Text())
|
text = strings.TrimSpace(s.Text())
|
||||||
if opts.headerEndCheck(text) {
|
if inHeader && opts.headerEndCheck(text) {
|
||||||
|
inHeader = false
|
||||||
if opts.Flavor == "gutenberg" {
|
if opts.Flavor == "gutenberg" {
|
||||||
title = extractGutenbergTitle(text)
|
title = extractGutenbergTitle(text)
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
title = path.Base(p)
|
title = path.Base(p)
|
||||||
}
|
}
|
||||||
inHeader = false
|
|
||||||
}
|
}
|
||||||
if inHeader {
|
if inHeader {
|
||||||
continue
|
continue
|
||||||
@ -140,7 +140,9 @@ func worker(opts CutupOpts, paths <-chan string, sources chan<- string) {
|
|||||||
}
|
}
|
||||||
for i, r := range text {
|
for i, r := range text {
|
||||||
if v := shouldBreak(phraseBuff, r); v > 0 {
|
if v := shouldBreak(phraseBuff, r); v > 0 {
|
||||||
phraseBuff = phraseBuff[0 : len(phraseBuff)-v]
|
if len(phraseBuff) > 0 {
|
||||||
|
phraseBuff = phraseBuff[0 : len(phraseBuff)-v]
|
||||||
|
}
|
||||||
if len(phraseBuff) >= 10 {
|
if len(phraseBuff) >= 10 {
|
||||||
cleaned = clean(phraseBuff)
|
cleaned = clean(phraseBuff)
|
||||||
if len(cleaned) > 0 {
|
if len(cleaned) > 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user