Skip to content

Commit

Permalink
fix generate content html
Browse files Browse the repository at this point in the history
  • Loading branch information
missdeer committed Jan 25, 2024
1 parent afa22a3 commit 2bab984
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dlutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (du *DownloadUtil) AddURL(index int, title string, link string) (reachEnd b
theURL, _ := url.Parse(link)
headers := http.Header{
"Referer": []string{fmt.Sprintf("%s://%s", theURL.Scheme, theURL.Host)},
"User-Agent": []string{"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"},
"User-Agent": []string{"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0"},
"Accept": []string{"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"},
"Accept-Language": []string{`en-US,en;q=0.8`},
"Upgrade-Insecure-Requests": []string{"1"},
Expand Down
4 changes: 2 additions & 2 deletions ebook/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ func (m *singleHTMLBook) writeContentHTML() {
return
}

contentHTML.WriteString(fmt.Sprintf(contentHTMLTemplate, m.bodyFontFamily, m.bodyFontSize, m.h1FontFamily, m.h1FontSize,
m.h2FontFamily, m.h2FontSize, m.paraFontFamily, m.paraFontSize, m.paraLineHeight, m.title, m.title, time.Now().String(),
contentHTML.WriteString(fmt.Sprintf(contentHTMLTemplate, m.title, m.bodyFontFamily, m.bodyFontSize, m.h1FontFamily, m.h1FontSize,
m.h2FontFamily, m.h2FontSize, m.paraFontFamily, m.paraFontSize, m.paraLineHeight, m.title, time.Now().String(),
string(tocC), string(contentC)))
contentHTML.Close()
}
10 changes: 2 additions & 8 deletions ebook/kindlegenmobi.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
"unicode/utf8"

Expand Down Expand Up @@ -251,11 +250,6 @@ func (m *kindlegenMobiBook) SetLineSpacing(float64) {

// Begin prepare book environment
func (m *kindlegenMobiBook) Begin() {
if b, e := fsutil.FileExists(m.fontFilePath); e != nil || !b {
contentHTMLTemplate = strings.Replace(contentHTMLTemplate, `@font-face{ font-family: "CustomFont"; src: url(fonts/CustomFont.ttf); }";`, "", -1)
contentHTMLTemplate = strings.Replace(contentHTMLTemplate, `font-family: "CustomFont";`, "", -1)
return
}
}

// End generate files that kindlegen needs
Expand Down Expand Up @@ -462,9 +456,9 @@ func (m *kindlegenMobiBook) writeContentHTML() {
return
}

contentHTML.WriteString(fmt.Sprintf(contentHTMLTemplate, m.bodyFontFamily, m.bodyFontSize, m.h1FontFamily, m.h1FontSize,
contentHTML.WriteString(fmt.Sprintf(contentHTMLTemplate, m.title, m.bodyFontFamily, m.bodyFontSize, m.h1FontFamily, m.h1FontSize,
m.h2FontFamily, m.h2FontSize, m.paraFontFamily, m.paraFontSize, m.paraLineHeight,
m.title, m.title, time.Now().String(),
m.title, time.Now().String(),
string(tocC), string(contentC)))
contentHTML.Close()
}
Expand Down

0 comments on commit 2bab984

Please sign in to comment.