-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (39 loc) · 1.07 KB
/
main.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
package main
import (
"fmt"
"nbspify/config"
"nbspify/input"
nbsperKinds "nbspify/nbspers"
)
func main() {
processedText := input.ReadInput()
nbspers := getNbspers()
definitions := config.LoadDefinitions()
optionsNbsper := initOptions()
if nbspers != nil {
for _, nbsper := range nbspers {
matchSegments := definitions[nbsper.GetCode()]
if len(matchSegments) > 0 {
processedText = nbsper.Apply(processedText, matchSegments, optionsNbsper)
}
}
}
// STDOUT
fmt.Print(processedText)
}
func initOptions() *config.OptionsNbsper {
// TODO - configurable by flags
return &config.OptionsNbsper{
CaseSensitive: false,
}
}
func getNbspers() []nbsperKinds.Nbsper {
nbspers := make([]nbsperKinds.Nbsper, 0)
// The order matters as the output is modified in-place...
nbspers = append(nbspers,  erKinds.NbsperReplace{})
nbspers = append(nbspers,  erKinds.NbsperInside{})
nbspers = append(nbspers,  erKinds.NbsperAround{})
nbspers = append(nbspers,  erKinds.NbsperBefore{})
nbspers = append(nbspers,  erKinds.NbsperAfter{})
return nbspers
}