aboutsummaryrefslogtreecommitdiff
path: root/convert_options.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-12-23 02:42:06 +0700
committerShulhan <ms@kilabit.info>2025-01-07 00:13:55 +0700
commitb686ea0a41b7af68d4d86ff3cc2c3068ebb88b66 (patch)
treeb8725c3c2e2461e2b0542c76880d385ee5aa6741 /convert_options.go
parentff338f853eb7537230c84ccc06feae3b63859877 (diff)
downloadciigo-b686ea0a41b7af68d4d86ff3cc2c3068ebb88b66.tar.xz
all: refactoring to use [watchfs/v2]
The [watchfs/v2] bring new enhancements that watching only single file instead of all markup files for changes. This minimize number of goroutine calling os.Stat on each markup files being watched on directory.
Diffstat (limited to 'convert_options.go')
-rw-r--r--convert_options.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/convert_options.go b/convert_options.go
index 0423644..5879151 100644
--- a/convert_options.go
+++ b/convert_options.go
@@ -6,6 +6,7 @@ package ciigo
import (
"fmt"
"regexp"
+ "strings"
)
const (
@@ -22,7 +23,7 @@ type ConvertOptions struct {
// Exclude define regular expresion to exclude certain paths from
// being scanned.
- Exclude string
+ Exclude []string
// HTMLTemplate the HTML template to be used when converting markup
// file into HTML.
@@ -41,16 +42,20 @@ func (opts *ConvertOptions) init() (err error) {
if len(opts.Root) == 0 {
opts.Root = DefaultRoot
}
- if len(opts.Exclude) > 0 {
- var re *regexp.Regexp
+ for _, str := range opts.Exclude {
+ str = strings.TrimSpace(str)
+ if len(str) == 0 {
+ continue
+ }
- re, err = regexp.Compile(opts.Exclude)
+ var re *regexp.Regexp
+ re, err = regexp.Compile(str)
if err != nil {
return fmt.Errorf(`%s: %w`, logp, err)
}
opts.excRE = append(opts.excRE, re)
- defExcludes = append(defExcludes, opts.Exclude)
+ defExcludes = append(defExcludes, str)
}
return nil
}