Skip to content

Commit

Permalink
Render hyperlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Jun 4, 2024
1 parent ee87556 commit 70a044b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions style.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,23 @@ func (s Style) Render(strs ...string) string {
useSpaceStyler = (underline && !underlineSpaces) || (strikethrough && !strikethroughSpaces) || underlineSpaces || strikethroughSpaces

transform = s.getAsTransform(transformKey)

hyperlinkURL = s.getAsHyperlinkURL(hyperlinkURLKey)
hyperlinkParams = s.getAsHyperlinkParams(hyperlinkParamsKey)
)

if transform != nil {
str = transform(str)
}

if hyperlinkURL != "" {
var params []string
for k, v := range hyperlinkParams {
params = append(params, k, v)
}
str = ansi.SetHyperlink(hyperlinkURL, params...) + str
}

if s.props == 0 {
return s.maybeConvertTabs(str)
}
Expand Down Expand Up @@ -471,6 +482,10 @@ func (s Style) Render(strs ...string) string {
}
}

if hyperlinkURL != "" {
str += ansi.ResetHyperlink()
}

return str
}

Expand Down

0 comments on commit 70a044b

Please sign in to comment.