Browse Source

add class no-title to links without a title

master
Wojciech Kwolek 1 year ago
parent
commit
3b9bd1c276
  1. 6
      blockparser/link.go

6
blockparser/link.go

@ -14,5 +14,9 @@ type Link struct {
func (l Link) RenderHTML() string {
href := l.Href() // TODO: handle " in links?
title := html.EscapeString(l.Title())
return fmt.Sprintf(`<div><a href="%s">%s</a></div>`, href, title)
class := ""
if l.Href() == l.Title() {
class = ` class="no-title"`
}
return fmt.Sprintf(`<div><a href="%s"%s>%s</a></div>`, href, class, title)
}

Loading…
Cancel
Save