Skip to content

Commit

Permalink
update nodeToString function
Browse files Browse the repository at this point in the history
- ignore comment nodes
- remove trailing newline from log message
- reduntant fmt.Sprintf removed
  • Loading branch information
husio committed Nov 5, 2016
1 parent 40b81bc commit d7ad093
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions htmlRenderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package justext

import (
"fmt"
"github.com/levigross/exp-html"
"log"
"strings"
)
Expand Down Expand Up @@ -31,7 +30,7 @@ func nodesToString(node *html.Node) string {

switch node.Type {
case html.TextNode:
response = fmt.Sprintf("%s", html.EscapeString(strings.TrimSpace(node.Data)))
response = html.EscapeString(strings.TrimSpace(node.Data))

case html.ElementNode, html.DoctypeNode:
var att string = ""
Expand Down Expand Up @@ -60,8 +59,11 @@ func nodesToString(node *html.Node) string {
}
}

case html.CommentNode:
// ignore

default:
log.Printf("Unhandled node: %s\n", nodeTypeToString(node))
log.Printf("Unhandled node: %s", nodeTypeToString(node))
}
return response
}
Expand Down

0 comments on commit d7ad093

Please sign in to comment.