mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
@@ -19,6 +19,8 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/gohugoio/hugo/parser/metadecoders"
|
||||
)
|
||||
@@ -234,3 +236,14 @@ func IsProbablySourceOfItems(source []byte, items Items) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
var hasShortcodeRe = regexp.MustCompile(`{{[%,<][^\/]`)
|
||||
|
||||
// HasShortcode returns true if the given string contains a shortcode.
|
||||
func HasShortcode(s string) bool {
|
||||
// Fast path for the common case.
|
||||
if !strings.Contains(s, "{{") {
|
||||
return false
|
||||
}
|
||||
return hasShortcodeRe.MatchString(s)
|
||||
}
|
||||
|
Reference in New Issue
Block a user