Skip to content

Commit

Permalink
Add NoStrongs option
Browse files Browse the repository at this point in the history
This enables ignoring <b> and <strong> tags.

It's based on jaytaylor#38 by @jypelle.
  • Loading branch information
thebaer committed Sep 2, 2020
1 parent aab264b commit 6f68950
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions html2text.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options struct {
PrettyTables bool // Turns on pretty ASCII rendering for table elements.
PrettyTablesOptions *PrettyTablesOptions // Configures pretty ASCII rendering for table elements.
OmitLinks bool // Turns on omitting links
NoStrongs bool // Ignores <b> and <strong> tags
TightLinks bool // Removes whitespace around links
}

Expand Down Expand Up @@ -231,6 +232,9 @@ func (ctx *textifyTraverseContext) handleElement(node *html.Node) error {
return err
}
str := subCtx.buf.String()
if ctx.options.NoStrongs {
return ctx.emit(str)
}
return ctx.emit("*" + str + "*")

case atom.A:
Expand Down

0 comments on commit 6f68950

Please sign in to comment.