Skip to content

Commit

Permalink
Simplify man-page related code
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Dec 17, 2024
1 parent c7df484 commit 951457d
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions v2/man.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ func (e *Editor) manPageHighlight(line string, firstLine, lastLine bool) string
return e.ManSectionColor.Get(line)
}
if strings.HasPrefix(trimmedLine, "-") { // a flag or parameter
var rs []rune
rs = append(rs, []rune(e.MarkdownTextColor.String())...)
rs := []rune(e.MarkdownTextColor.String())
inFlag := false
spaceCount := 0
foundLetter := false
Expand Down Expand Up @@ -120,16 +119,8 @@ func (e *Editor) manPageHighlight(line string, firstLine, lastLine bool) string
} else {
nextRune = ' '
}
if (unicode.IsLetter(r) || r == '_') && !inWord {
inWord = true
} else if inWord && !unicode.IsLetter(r) && !hexDigit(r) {
inWord = false
}
if !inAngles && r == '<' {
inAngles = true
} else if inAngles && r == '>' {
inAngles = false
}
inWord = (unicode.IsLetter(r) || r == '_') || (inWord && unicode.IsLetter(r)) || (inWord && hexDigit(r))
inAngles = (!inAngles && r == '<') || (inAngles && r != '>')
if !inWord && unicode.IsDigit(r) && !inDigits {
inDigits = true
rs = append(rs, []rune(off+e.ItalicsColor.String())...)
Expand Down Expand Up @@ -173,6 +164,5 @@ func (e *Editor) manPageHighlight(line string, firstLine, lastLine bool) string
}
prevRune = r
}
rs = append(rs, []rune(off)...)
return string(rs)
return string(append(rs, []rune(off)...))
}

0 comments on commit 951457d

Please sign in to comment.