本文整理汇总了Golang中github.com/spf13/hugo/helpers.StripHTML函数的典型用法代码示例。如果您正苦于以下问题:Golang StripHTML函数的具体用法?Golang StripHTML怎么用?Golang StripHTML使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StripHTML函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: initPlain
func (p *Page) initPlain() {
p.plainInit.Do(func() {
p.plain = helpers.StripHTML(string(p.Content))
p.plainWords = strings.Fields(p.plain)
return
})
}
示例2: plainify
// plainify strips any HTML and returns the plain text version.
func plainify(in interface{}) (string, error) {
s, err := cast.ToStringE(in)
if err != nil {
return "", err
}
return helpers.StripHTML(s), nil
}
示例3: countRunes
// countRunes returns the approximate rune count of the given content.
func countRunes(content interface{}) (int, error) {
conv, err := cast.ToStringE(content)
if err != nil {
return 0, fmt.Errorf("Failed to convert content to string: %s", err.Error())
}
counter := 0
for _, r := range helpers.StripHTML(conv) {
if !helpers.IsWhitespace(r) {
counter++
}
}
return counter, nil
}
示例4: countWords
// countWords returns the approximate word count of the given content.
func countWords(content interface{}) (int, error) {
conv, err := cast.ToStringE(content)
if err != nil {
return 0, fmt.Errorf("Failed to convert content to string: %s", err.Error())
}
counter := 0
for _, word := range strings.Fields(helpers.StripHTML(conv)) {
runeCount := utf8.RuneCountInString(word)
if len(word) == runeCount {
counter++
} else {
counter += runeCount
}
}
return counter, nil
}
示例5: normalizeExpected
func normalizeExpected(ext, str string) string {
str = normalizeContent(str)
switch ext {
default:
return str
case "html":
return strings.Trim(helpers.StripHTML(str), " ")
case "ad":
paragraphs := strings.Split(str, "</p>")
expected := ""
for _, para := range paragraphs {
if para == "" {
continue
}
expected += fmt.Sprintf("<div class=\"paragraph\">\n%s</p></div>\n", para)
}
return expected
case "rst":
return fmt.Sprintf("<div class=\"document\">\n\n\n%s</div>", str)
}
}
示例6: Plain
func (p *Page) Plain() string {
if len(p.plain) == 0 {
p.plain = helpers.StripHTML(StripShortcodes(string(p.renderBytes(p.rawContent))))
}
return p.plain
}
示例7: Plain
func (p *Page) Plain() string {
if len(p.plain) == 0 {
p.plain = helpers.StripHTML(string(p.Content))
}
return p.plain
}
示例8: initPlain
func (p *Page) initPlain() {
p.plainInit.Do(func() {
p.plain = helpers.StripHTML(string(p.Content))
return
})
}