Browse Source

add class no-title to links without a title

master
Wojciech Kwolek 2 months ago
parent
commit
3b9bd1c276
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      blockparser/link.go

+ 5
- 1
blockparser/link.go View File

@ -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