aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-02-19 01:19:51 +0700
committerShulhan <ms@kilabit.info>2022-02-19 01:19:51 +0700
commitfdc557949e898f7284a080c75231a438f8f998b5 (patch)
tree49fed4fde810cd0c39fa83103042e0f6fcff1525
parent41117b40ee781e56b160902f94e5d57b71ab621c (diff)
downloadciigo-fdc557949e898f7284a080c75231a438f8f998b5.tar.xz
all: fix adoc files not re-converted when template file changes
In commit 06d03f6afe37 we skip converting files if the generated HTML is newer than adoc file. This cause an issue where the template file changes during Watch or Serve, but the HTML files is not regenerated.
-rw-r--r--ciigo.go4
-rw-r--r--htmlgenerator.go6
-rw-r--r--server.go2
-rw-r--r--watcher.go2
4 files changed, 8 insertions, 6 deletions
diff --git a/ciigo.go b/ciigo.go
index 091aa23..a2dece9 100644
--- a/ciigo.go
+++ b/ciigo.go
@@ -69,7 +69,7 @@ func Convert(opts *ConvertOptions) (err error) {
return fmt.Errorf("%s: %w", logp, err)
}
- htmlg.convertFileMarkups(fileMarkups)
+ htmlg.convertFileMarkups(fileMarkups, false)
return nil
}
@@ -112,7 +112,7 @@ func GoEmbed(opts *EmbedOptions) (err error) {
return fmt.Errorf("%s: %w", logp, err)
}
- htmlg.convertFileMarkups(fileMarkups)
+ htmlg.convertFileMarkups(fileMarkups, false)
memfsOpts := &memfs.Options{
Root: opts.Root,
diff --git a/htmlgenerator.go b/htmlgenerator.go
index e6b29fd..4819217 100644
--- a/htmlgenerator.go
+++ b/htmlgenerator.go
@@ -95,11 +95,13 @@ func (htmlg *htmlGenerator) convert(fmarkup *fileMarkup) (err error) {
//
// convertFileMarkups convert markup files into HTML.
//
-func (htmlg *htmlGenerator) convertFileMarkups(fileMarkups map[string]*fileMarkup) {
+func (htmlg *htmlGenerator) convertFileMarkups(fileMarkups map[string]*fileMarkup, isForce bool) {
logp := "convertFileMarkups"
for _, fmarkup := range fileMarkups {
if !fmarkup.isNewerThanHtml() {
- continue
+ if !isForce {
+ continue
+ }
}
err := htmlg.convert(fmarkup)
diff --git a/server.go b/server.go
index d20716c..d7fb352 100644
--- a/server.go
+++ b/server.go
@@ -85,7 +85,7 @@ func newServer(opts *ServeOptions) (srv *server, err error) {
return nil, fmt.Errorf("%s: %w", logp, err)
}
- srv.htmlg.convertFileMarkups(srv.watcher.fileMarkups)
+ srv.htmlg.convertFileMarkups(srv.watcher.fileMarkups, false)
}
return srv, nil
diff --git a/watcher.go b/watcher.go
index b9ad486..23e0be3 100644
--- a/watcher.go
+++ b/watcher.go
@@ -171,7 +171,7 @@ func (w *watcher) onChangeHtmlTemplate(ns *libio.NodeState) {
}
fmt.Printf("%s: regenerate all markup files ...\n", logp)
- w.htmlg.convertFileMarkups(w.fileMarkups)
+ w.htmlg.convertFileMarkups(w.fileMarkups, true)
}
//