Skip to content

Commit

Permalink
fix: 卷和章节冲突的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ystyle committed Dec 11, 2022
1 parent eab8b19 commit 25ced1b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Book struct {
Decoder *encoding.Decoder
PageStylesFile string
Reg *regexp.Regexp
Reg2 *regexp.Regexp
version string
}

Expand All @@ -59,6 +60,7 @@ const (
htmlTitleStart = `<h3 class="title">`
mobiTtmlTitleStart = `<h3 style="text-align:%s;">`
htmlTitleEnd = "</h3>"
Match = "^第[0-9一二三四五六七八九十零〇百千两 ]+卷"
DefaultMatchTips = "^第[0-9一二三四五六七八九十零〇百千两 ]+[章回节集卷]|^[Ss]ection.{1,20}$|^[Cc]hapter.{1,20}$|^[Pp]age.{1,20}$|^\\d{1,4}$|^引子$|^楔子$|^章节目录|^章节|^序章"
cssContent = `
.title {text-align:%s}
Expand Down Expand Up @@ -168,6 +170,8 @@ func (book *Book) Check(version string) error {
return fmt.Errorf("生成匹配规则出错: %s\n%s\n", book.Match, err.Error())
}
book.Reg = reg
reg2, _ := regexp.Compile(Match)
book.Reg2 = reg2
return nil
}

Expand Down Expand Up @@ -261,9 +265,6 @@ func (book *Book) Parse() error {
addPart(&content, Tutorial)
}
}
if content.Len() == 0 {
continue
}
contentList = append(contentList, Section{
Title: title,
Content: content.String(),
Expand Down

0 comments on commit 25ced1b

Please sign in to comment.