提交 425a75f3 编写于 作者: K kfcampbell

Lint md2roff-bin, ui, utils dirs.

上级 04169cbf
......@@ -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(`<a href="./%s.html">%s</a>`, 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(`<a href="./%s.html">%s</a>`, fileName, match)
}
return match
})
tmplData := templateData{
......
......@@ -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 {
......
......@@ -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 {
......
......@@ -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)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册