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

Lint md2roff-bin, ui, utils dirs.

上级 04169cbf
...@@ -95,15 +95,13 @@ func generateFromFile(mdFile string) error { ...@@ -95,15 +95,13 @@ func generateFromFile(mdFile string) error {
content = xRefRe.ReplaceAllStringFunc(content, func(match string) string { content = xRefRe.ReplaceAllStringFunc(content, func(match string) string {
if match == currentPage { if match == currentPage {
return match 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{ tmplData := templateData{
......
...@@ -118,24 +118,24 @@ func (f *expander) expandSpecialChar(firstChar byte, format string) (expand stri ...@@ -118,24 +118,24 @@ func (f *expander) expandSpecialChar(firstChar byte, format string) (expand stri
} }
} }
case '+': case '+':
if e, u := f.expandOneVar(format); e != "" { e, u := f.expandOneVar(format)
if e != "" {
return "\n" + e, u, true return "\n" + e, u, true
} else {
return "", u, true
} }
return "", u, true
case ' ': case ' ':
if e, u := f.expandOneVar(format); e != "" { e, u := f.expandOneVar(format)
if e != "" {
return " " + e, u, true return " " + e, u, true
} else {
return "", u, true
} }
return "", u, true
case '-': case '-':
if e, u := f.expandOneVar(format); e != "" { e, u := f.expandOneVar(format)
if e != "" {
return e, u, true 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 '<', '>': case '<', '>':
if m := paddingPattern.FindStringSubmatch(string(firstChar) + format); len(m) == 7 { 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 { if p := padderFromConfig(m[1], m[2], m[3], m[4], m[5]); p != nil {
......
...@@ -20,9 +20,8 @@ func (f *argsFlag) lastValue() string { ...@@ -20,9 +20,8 @@ func (f *argsFlag) lastValue() string {
l := len(f.values) l := len(f.values)
if l > 0 { if l > 0 {
return f.values[l-1] return f.values[l-1]
} else {
return ""
} }
return ""
} }
func (f *argsFlag) reset() { func (f *argsFlag) reset() {
...@@ -152,9 +151,8 @@ func (p *ArgsParser) RegisterBool(name string, aliases ...string) { ...@@ -152,9 +151,8 @@ func (p *ArgsParser) RegisterBool(name string, aliases ...string) {
func (p *ArgsParser) Value(name string) string { func (p *ArgsParser) Value(name string) string {
if f, found := p.flagMap[name]; found { if f, found := p.flagMap[name]; found {
return f.lastValue() return f.lastValue()
} else {
return ""
} }
return ""
} }
func (p *ArgsParser) AllValues(name string) []string { func (p *ArgsParser) AllValues(name string) []string {
......
...@@ -8,7 +8,8 @@ import ( ...@@ -8,7 +8,8 @@ import (
) )
var ( var (
Black, White *Color Black *Color
White *Color
) )
func init() { func init() {
...@@ -54,9 +55,8 @@ func rgbComponentToBoldValue(component uint8) float64 { ...@@ -54,9 +55,8 @@ func rgbComponentToBoldValue(component uint8) float64 {
srgb := float64(component) / 255 srgb := float64(component) / 255
if srgb <= 0.03928 { if srgb <= 0.03928 {
return srgb / 12.92 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 { func (c *Color) Luminance() float64 {
...@@ -134,8 +134,7 @@ func isTerm24bitColorCapable() bool { ...@@ -134,8 +134,7 @@ func isTerm24bitColorCapable() bool {
func RgbToTermColorCode(color *Color) string { func RgbToTermColorCode(color *Color) string {
if isTerm24bitColorCapable() { if isTerm24bitColorCapable() {
return fmt.Sprintf("2;%d;%d;%d", color.Red, color.Green, color.Blue) 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.
先完成此消息的编辑!
想要评论请 注册