// Returns a slugified string
// Example: "Page Title" becomes "page-title"
762972
func Slugify(inputString string) string {

	isMn := func(r rune) bool {
		return unicode.Is(unicode.Mn, r) // Mn: nonspacing marks
	}

	t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)

	replaceChar := func(r rune) rune {
		switch {
		case unicode.IsLetter(r):
			return unicode.ToLower(r)
		case unicode.IsNumber(r), r == '_', r == '-', r == '+':
			return r
		case unicode.IsSpace(r):
			return '-'
		default:
			return -1
		}
	}

	slug, _, _ := transform.String(t, strings.Map(replaceChar, inputString))

	return slug
}
429787
func (d *DomainName) String() string {
	switch {
	case d.TLD == "":
		return ""
	case d.SLD == "":
		return d.TLD
	case d.TRD == "":
		return d.SLD + "." + d.TLD
	default:
		return d.TRD + "." + d.SLD + "." + d.TLD
	}
}
313228
func (d FaxCoverPage) String() string {
	if None <= d && d <= Urgent {
		return faxCoverPages[d]
	}
	return faxCoverPages[0]
}
417590
func (doc *PluginDocument) DumpString() string {
	str := ""
	str += "==================== START DUMP ============================\n"
	str += "PackageName: [" + doc.PackageName + "]\n"
	str += "PluginName:  [" + doc.PluginName + "]\n"
	str += "BlockHeading: [" + doc.BlockHeading + "]\n"
	str += "Description: [" + doc.Description + "]\n\n"
	str += "Parameters: [" + "\n"
	str += doc.Parameters.dumpString() + "\n"
	str += "]\n\n"
	for parentName, defMap := range doc.InheritedParameters {
		str += "Parameters (from " + parentName + ")[\n"
		str += defMap.dumpString() + "\n"
		str += "]\n\n"
	}
	str += "Metadata: [" + "\n"
	str += doc.Metadata.dumpString() + "\n"
	for parentName, defMap := range doc.InheritedMetadata {
		str += "Metadata (from " + parentName + ")[\n"
		str += defMap.dumpString() + "\n"
		str += "]\n\n"
	}
	str += "Example: [" + "\n------------\n" + doc.Example + "\n----------]\n"
	str += "==================== END DUMP ============================\n"
	return str
}
625479
func (col *Column) String() string {
	result := col.ColName.L
	if col.TblName.L != "" {
		result = col.TblName.L + "." + result
	}
	if col.DBName.L != "" {
		result = col.DBName.L + "." + result
	}
	return result
}
137557
func (e Entry) String() string {
	if e.Raw != "" {
		return e.Raw
	}
	if e.Type == BlankType {
		return ""
	}
	if e.Type == DotDotType {
		return e.Name
	}
	if e.Type == SpecialType || e.Type == FullType || inKeyValSlice("type=dir", e.Keywords) {
		return fmt.Sprintf("%s %s", e.Name, strings.Join(KeyValToString(e.Keywords), " "))
	}
	return fmt.Sprintf("    %s %s", e.Name, strings.Join(KeyValToString(e.Keywords), " "))
}
1313770
func title(p string) string {
	return strings.TrimSuffix(path.Base(p), path.Ext(p))
}
907803
func (r *Reference) String() string {
	var buf bytes.Buffer
	fmt.Fprintf(&buf, "@SQ\tSN:%s\tLN:%d", r.name, r.lRef)
	if r.md5 != "" {
		fmt.Fprintf(&buf, "\tM5:%x", []byte(r.md5))
	}
	if r.assemID != "" {
		fmt.Fprintf(&buf, "\tAS:%s", r.assemID)
	}
	if r.species != "" {
		fmt.Fprintf(&buf, "\tSP:%s", r.species)
	}
	if r.uri != nil {
		fmt.Fprintf(&buf, "\tUR:%s", r.uri)
	}
	for _, tp := range r.otherTags {
		fmt.Fprintf(&buf, "\t%s:%s", tp.tag, tp.value)
	}
	return buf.String()
}
1301764
func (m Method) VerbTitle() string {
	return strings.Title(strings.ToLower(m.verb))
}
1120195
func KeywordString(id int) string {
	str, ok := keywordStrings[id]
	if !ok {
		return ""
	}
	return str
}
28895
func (page *Page) getTitle(text []byte) error {
	startTag := []byte("<title>")
	startIndex := bytes.Index(text, startTag)

	endTag := []byte("</title>")
	endIndex := bytes.Index(text, endTag)

	if startIndex != -1 && endIndex != -1 {
		title := text[startIndex+len(startTag) : endIndex]

		if len(title) < 1 || !isTitle(title) {
			return ErrTitleNotFound
		}

		page.Title = string(title)
	} else {
		return ErrTitleNotFound
	}

	return nil
}
221100
func (h Headers) String() string {
	ec := h.Validate()
	if ec != nil {
		return ec.Error()
	}
	b := make([]byte, 0, 1024)
	for i := 0; i < len(h); i += 2 {
		b = append(b, h[i]+":"+h[i+1]+"\n"...)
	}
	return string(b)
}
628286
func (n Name) Title() string {
	x := strings.Split(string(n), "/")
	for i, s := range x {
		x[i] = Titleize(s)
	}

	return strings.Join(x, " ")
}
1063842
func ToSlug(slug []byte) []byte {
	// Convert punctuation and spaces to hyphens: string([]byte{45}) = "-"
	slug = regexp.MustCompile(`[[:punct:]\s_]+`).ReplaceAll(slug, []byte{45})
	slug = regexp.MustCompile(`["']+`).ReplaceAll(slug, []byte{})
	return regexp.MustCompile(`(^-+|-+$)`).ReplaceAll(slug, []byte{})
}
819428
func Examples(s string) string {
	if len(s) == 0 {
		return s
	}
	return normalizer{s}.Trim().Indent().string
}
835096
func filterString(in string) string {
	var (
		rs         = []rune(in)
		flag, prev rune
		psn        int
	)
	for k, r := range rs {
		// fmt.Println(string(r), " ", r)
		switch r {
		case '"':
			if flag == '\'' && prev != '\\' {
				rs[k] = 0 // bookmark for replace
			}
			if flag == 0 {
				flag = '"'
				psn = k
			} else if r == flag && prev != '\\' {
				flag = 0
			}
		case '\'':
			if flag == 0 {
				flag = '\''
				psn = k
			} else if r == flag && prev != '\\' {
				// if k-(psn+1) != 1 {
				rs[psn] = '"'
				rs[k] = '"'
				// }
				flag = 0
			}
		case '`':
			if flag == 0 {
				flag = '`'
				psn = k
			} else if r == flag {
				flag = 0
			}
		}
		prev = r
	}
	filterPlus(rs)
	filterJsEsc(rs)
	out := strings.Replace(string(rs), string(rune(0)), `\"`, -1)
	out = strings.Replace(out, string(rune(1)), ``, -1)
	out = strings.Replace(out, string([]rune{2, 2}), "`+", -1)
	out = strings.Replace(out, string(rune(3)), "+`", -1)
	return out
}
938230
func indentString(s, p string) string {
	var res []byte
	b := []byte(s)
	prefix := []byte(p)
	bol := true
	for _, c := range b {
		if bol && c != '\n' {
			res = append(res, prefix...)
		}
		res = append(res, c)
		bol = c == '\n'
	}
	return string(res)
}