diff --git a/md2roff-bin/cmd.go b/md2roff-bin/cmd.go index cf77de1f..6db6b210 100644 --- a/md2roff-bin/cmd.go +++ b/md2roff-bin/cmd.go @@ -95,15 +95,13 @@ func generateFromFile(mdFile string) error { content = xRefRe.ReplaceAllStringFunc(content, func(match string) string { if match == currentPage { return match - } else { - matches := xRefRe.FindAllStringSubmatch(match, 1) - fileName := fmt.Sprintf("%s.%s", matches[0][1], matches[0][2]) - if pageIndex[fileName] { - return fmt.Sprintf(`%s`, fileName, match) - } else { - return match - } } + matches := xRefRe.FindAllStringSubmatch(match, 1) + fileName := fmt.Sprintf("%s.%s", matches[0][1], matches[0][2]) + if pageIndex[fileName] { + return fmt.Sprintf(`%s`, fileName, match) + } + return match }) tmplData := templateData{ diff --git a/ui/format.go b/ui/format.go index 94109b96..84204218 100644 --- a/ui/format.go +++ b/ui/format.go @@ -118,24 +118,24 @@ func (f *expander) expandSpecialChar(firstChar byte, format string) (expand stri } } case '+': - if e, u := f.expandOneVar(format); e != "" { + e, u := f.expandOneVar(format) + if e != "" { return "\n" + e, u, true - } else { - return "", u, true } + return "", u, true case ' ': - if e, u := f.expandOneVar(format); e != "" { + e, u := f.expandOneVar(format) + if e != "" { return " " + e, u, true - } else { - return "", u, true } + return "", u, true case '-': - if e, u := f.expandOneVar(format); e != "" { + e, u := f.expandOneVar(format) + if e != "" { return e, u, true - } else { - f.append(strings.TrimRight(f.crush(), "\n")) - return "", u, true } + f.append(strings.TrimRight(f.crush(), "\n")) + return "", u, true case '<', '>': if m := paddingPattern.FindStringSubmatch(string(firstChar) + format); len(m) == 7 { if p := padderFromConfig(m[1], m[2], m[3], m[4], m[5]); p != nil { diff --git a/utils/args_parser.go b/utils/args_parser.go index d736ba4f..29f344c7 100644 --- a/utils/args_parser.go +++ b/utils/args_parser.go @@ -20,9 +20,8 @@ func (f *argsFlag) lastValue() string { l := len(f.values) if l > 0 { return f.values[l-1] - } else { - return "" } + return "" } func (f *argsFlag) reset() { @@ -152,9 +151,8 @@ func (p *ArgsParser) RegisterBool(name string, aliases ...string) { func (p *ArgsParser) Value(name string) string { if f, found := p.flagMap[name]; found { return f.lastValue() - } else { - return "" } + return "" } func (p *ArgsParser) AllValues(name string) []string { diff --git a/utils/color.go b/utils/color.go index 7933041f..86aac687 100644 --- a/utils/color.go +++ b/utils/color.go @@ -8,7 +8,8 @@ import ( ) var ( - Black, White *Color + Black *Color + White *Color ) func init() { @@ -54,9 +55,8 @@ func rgbComponentToBoldValue(component uint8) float64 { srgb := float64(component) / 255 if srgb <= 0.03928 { return srgb / 12.92 - } else { - return math.Pow(((srgb + 0.055) / 1.055), 2.4) } + return math.Pow(((srgb + 0.055) / 1.055), 2.4) } func (c *Color) Luminance() float64 { @@ -134,8 +134,7 @@ func isTerm24bitColorCapable() bool { func RgbToTermColorCode(color *Color) string { if isTerm24bitColorCapable() { return fmt.Sprintf("2;%d;%d;%d", color.Red, color.Green, color.Blue) - } else { - intCode := ditherTo256ColorCode(color) - return fmt.Sprintf("5;%d", intCode) } + intCode := ditherTo256ColorCode(color) + return fmt.Sprintf("5;%d", intCode) }