Skip to content

Commit d791186

Browse files
committed
[minor] adding "no_page_map" configuration, freebsd releases and updating all dependencies to go1.23.5.
1 parent 28518d1 commit d791186

File tree

33 files changed

+1111
-570
lines changed

33 files changed

+1111
-570
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Set up Go
2929
uses: actions/setup-go@v5
3030
with:
31-
go-version: '1.23'
31+
go-version: '1.23.5'
3232

3333
- name: Build everything
3434
run: task release

Taskfile.yaml

+21-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ tasks:
109109
deps: [generate-project-version, get-dictionaries, get-sentences]
110110
cmds:
111111
- mkdir -p '{{.REL_BUILD_DIR}}'
112-
- for: [linux-amd64, linux-arm64, linux-386, darwin-amd64, darwin-arm64, windows-amd64-.exe, windows-arm64-.exe, windows-386-.exe]
112+
- for: [linux-amd64, linux-arm64, linux-386, darwin-amd64, darwin-arm64, freebsd-amd64, freebsd-arm64, windows-amd64-.exe, windows-arm64-.exe, windows-386-.exe]
113113
task: release-for-platform-{{with $arch := split "-" .ITEM}}{{$arch._0}}{{end}}
114114
vars:
115115
GOOS: '{{with $arch := split "-" .ITEM}}{{$arch._0}}{{end}}'
@@ -183,6 +183,25 @@ tasks:
183183
status:
184184
- test -f '{{.REL_NAME}}.zip'
185185

186+
release-for-platform-freebsd:
187+
internal: true
188+
desc: Builds release for specified platform
189+
requires:
190+
vars: [GOOS, GOARCH, SUFFIX]
191+
label: release-for-platform-darwin-{{.GOOS}}-{{.GOARCH}}
192+
vars:
193+
BUILD_DIR: '{{.REL_BUILD_DIR}}_{{.GOOS}}_{{.GOARCH}}'
194+
REL_NAME: '{{.REL_BUILD_DIR}}/fb2c-{{.GOOS}}-{{.GOARCH}}'
195+
cmds:
196+
- mkdir -p {{.BUILD_DIR}}
197+
- defer: rm -rf {{.BUILD_DIR}}
198+
- task: go-build
199+
vars: {GOOS: '{{.GOOS}}', GOARCH: '{{.GOARCH}}', FLAGS: 'release', PACKAGE: './cmd/fb2c', TARGET: '{{.BUILD_DIR}}/fb2c{{.SUFFIX}}'}
200+
- echo "{{.TATN}}Archiving release \"{{.REL_NAME}}.zip\"{{.TOFF}}"
201+
- 7z a -r -bd -bso0 -tzip {{.REL_NAME}} ./{{.BUILD_DIR}}/*
202+
status:
203+
- test -f '{{.REL_NAME}}.zip'
204+
186205
generate-enums:
187206
internal: true
188207
desc: Generates fmt.Stringer interfaces for specified enum types
@@ -348,6 +367,7 @@ tasks:
348367
vars:
349368
GO_VER: '{{default "" (regexFind "[0-9]+\\.[0-9]+\\.?[0-9]*[-a-zA-Z0-9+]*" (env "CUR_PROJECT_TYPE"))}}'
350369
cmds:
370+
- GOOS=freebsd go mod tidy{{if .GO_VER}} -go={{.GO_VER}}{{end}} {{.CLI_ARGS}}
351371
- GOOS=linux go mod tidy{{if .GO_VER}} -go={{.GO_VER}}{{end}} {{.CLI_ARGS}}
352372
- GOOS=darwin go mod tidy{{if .GO_VER}} -go={{.GO_VER}}{{end}} {{.CLI_ARGS}}
353373
- GOOS=windows go mod tidy{{if .GO_VER}} -go={{.GO_VER}}{{end}} {{.CLI_ARGS}}

config/cfg.go

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ type Doc struct {
140140
FileNameFormat string `json:"file_name_format"`
141141
FileNameTransliterate bool `json:"file_name_transliterate"`
142142
FixZip bool `json:"fix_zip_format"`
143+
NoPageMap bool `json:"no_page_map"`
143144
//
144145
DropCaps struct {
145146
Create bool `json:"create"`

config/os_linux.go renamed to config/os_unix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build linux
1+
//go:build linux || freebsd
22

33
package config
44

go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module fb2converter
22

3-
go 1.23.4
3+
go 1.23.5
44

55
require (
66
dario.cat/mergo v1.0.1
@@ -14,7 +14,7 @@ require (
1414
github.com/ghodss/yaml v1.0.0
1515
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
1616
github.com/google/uuid v1.6.0
17-
github.com/gosimple/slug v1.14.0
17+
github.com/gosimple/slug v1.15.0
1818
github.com/h2non/filetype v1.1.3
1919
github.com/hashicorp/hcl v1.0.0
2020
github.com/hidez8891/zip v1.11.0
@@ -23,11 +23,11 @@ require (
2323
github.com/urfave/cli/v2 v2.27.5
2424
go.uber.org/zap v1.27.0
2525
golang.org/x/image v0.23.0
26-
golang.org/x/net v0.33.0
27-
golang.org/x/sys v0.28.0
28-
golang.org/x/term v0.27.0
26+
golang.org/x/net v0.34.0
27+
golang.org/x/sys v0.29.0
28+
golang.org/x/term v0.28.0
2929
golang.org/x/text v0.21.0
30-
golang.org/x/tools v0.28.0
30+
golang.org/x/tools v0.29.0
3131
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
3232
honnef.co/go/tools v0.5.1
3333
)

go.sum

+10-10
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8
3232
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
3333
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
3434
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
35-
github.com/gosimple/slug v1.14.0 h1:RtTL/71mJNDfpUbCOmnf/XFkzKRtD6wL6Uy+3akm4Es=
36-
github.com/gosimple/slug v1.14.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
35+
github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo=
36+
github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
3737
github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=
3838
github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=
3939
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
@@ -74,20 +74,20 @@ golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68=
7474
golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY=
7575
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
7676
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
77-
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
78-
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
77+
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
78+
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
7979
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
8080
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
8181
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
82-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
83-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
84-
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
85-
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
82+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
83+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
84+
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
85+
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
8686
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8787
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
8888
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
89-
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
90-
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
89+
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
90+
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
9191
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
9292
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
9393
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

processor/generate.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ func (p *Processor) prepareStylesheet() error {
395395
// generatePagemap creates epub page map.
396396
func (p *Processor) generatePagemap() error {
397397

398+
if p.noPages {
399+
return nil
400+
}
401+
398402
p.env.Log.Debug("Generating page map - start")
399403
defer func(start time.Time) {
400404
p.env.Log.Debug("Generating page map - done", zap.Duration("elapsed", time.Since(start)))
@@ -534,7 +538,12 @@ func (p *Processor) generateOPF() error {
534538

535539
// Spine generation
536540

537-
spine := to.AddNext("spine", attr("toc", "ncx"), attr("page-map", "page-map"))
541+
var spine *etree.Element
542+
if p.noPages {
543+
spine = to.AddNext("spine", attr("toc", "ncx"))
544+
} else {
545+
spine = to.AddNext("spine", attr("toc", "ncx"), attr("page-map", "page-map"))
546+
}
538547

539548
for _, f := range p.Book.Files {
540549
id := f.id

processor/process.go

+7
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type Processor struct {
7171
notesMode NotesFmt
7272
tocPlacement TOCPlacement
7373
tocType TOCType
74+
noPages bool
7475
kindlePageMap APNXGeneration
7576
stampPlacement StampPlacement
7677
coverResize CoverProcessing
@@ -126,6 +127,11 @@ func NewFB2(r io.Reader, unknownEncoding bool, src, dst string, nodirs, stk, ove
126127
apnx = APNXNone
127128
}
128129
}
130+
if env.Cfg.Doc.NoPageMap && apnx != APNXNone {
131+
env.Log.Warn("APNX generation option requested but no page map is generated, turning off")
132+
apnx = APNXNone
133+
}
134+
129135
var stamp StampPlacement
130136
if len(env.Cfg.Doc.Cover.Placement) > 0 {
131137
stamp = ParseStampPlacementString(env.Cfg.Doc.Cover.Placement)
@@ -153,6 +159,7 @@ func NewFB2(r io.Reader, unknownEncoding bool, src, dst string, nodirs, stk, ove
153159
notesMode: notes,
154160
tocType: toct,
155161
tocPlacement: place,
162+
noPages: env.Cfg.Doc.NoPageMap,
156163
kindlePageMap: apnx,
157164
stampPlacement: stamp,
158165
coverResize: resize,

processor/xhtml.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func (p *Processor) doTextTransformations(text string, breakable, tail bool) str
262262
return text
263263
}
264264

265-
// formatText inserts page markers (for page map), kobo spans (if necessary) and hyphenates words if requested.
265+
// formatText inserts page markers (for page map) if requested, kobo spans (if necessary) and hyphenates words if requested.
266266
func (p *Processor) formatText(in string, breakable, tail bool, to *etree.Element) {
267267

268268
in = p.doTextTransformations(in, breakable, tail)
@@ -276,6 +276,8 @@ func (p *Processor) formatText(in string, breakable, tail bool, to *etree.Elemen
276276
kobo = p.format == OKepub
277277
)
278278

279+
insertMarkers = insertMarkers && !p.noPages
280+
279281
bufWriteString := func(text string, kobo bool) {
280282
if kobo {
281283
p.ctx().sentence++

static/configuration.toml

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@
131131
#---- NOTE: this setting may conflict with document transforms
132132
# ignore_nonbreakable_space = false
133133

134+
#---- When set no page maps will be generated in epub and no page markers inserted anywhere.
135+
#---- this in turn will disable apnx generation for kindle based formats
136+
# no_page_map = false
137+
134138
#---- To generate epub page map we use very rough text processing, controlling approximate page size in Unicode code points
135139
# characters_per_page = 2300
136140

vendor/github.com/gosimple/slug/slug.go

+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/syscall_dragonfly.go

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/windows/dll_windows.go

+5-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/tools/go/analysis/analysis.go

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)