forked from takahashim/aozoraconv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
51 lines (43 loc) · 833 Bytes
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package aozoraconv
type OptionFunc func(*option)
type option struct {
Header Escaper
Ruby Escaper
Annotation Escaper
RepeatTwo Escaper
}
func WithoutHeader() OptionFunc {
return func(opt *option) {
opt.Header = newHeaderEscaper()
}
}
func WithoutRuby() OptionFunc {
return func(opt *option) {
opt.Ruby = newRubyEscaper()
}
}
func WithoutAnnotation() OptionFunc {
return func(opt *option) {
opt.Annotation = newAnnotationEscaper()
}
}
func WithoutRepeatTwo() OptionFunc {
return func(opt *option) {
opt.RepeatTwo = newRepeatTwoEscaper()
}
}
func defaultOption() *option {
return &option{
Header: nil,
Ruby: nil,
Annotation: nil,
RepeatTwo: nil,
}
}
func newOption(funcs ...OptionFunc) *option {
opt := defaultOption()
for _, fn := range funcs {
fn(opt)
}
return opt
}