// TrimShortHTML removes the <p>/</p> tags from HTML input in the situation
// where said tags are the only <p> tags in the input and enclose the content
// of the input (whitespace excluded).
764134
func (c *ContentSpec) TrimShortHTML(input []byte) []byte {
	first := bytes.Index(input, paragraphIndicator)
	last := bytes.LastIndex(input, paragraphIndicator)
	if first == last {
		input = bytes.TrimSpace(input)
		input = bytes.TrimPrefix(input, openingPTag)
		input = bytes.TrimSuffix(input, closingPTag)
		input = bytes.TrimSpace(input)
	}
	return input
}
114697
func (ctx *Context) HTML(code int, str string) error {
	ctx.Type(MIMETextHTMLCharsetUTF8)
	return ctx.End(code, []byte(str))
}
769268
func stripPathShortcuts(p string) string {
	newPath := path.Clean(p)
	trimmed := strings.TrimPrefix(newPath, "../")

	for trimmed != newPath {
		newPath = trimmed
		trimmed = strings.TrimPrefix(newPath, "../")
	}

	// trim leftover {".", ".."}
	if newPath == "." || newPath == ".." {
		newPath = ""
	}

	if len(newPath) > 0 && string(newPath[0]) == "/" {
		return newPath[1:]
	}

	return newPath
}
1243008
func TrimTrailingSpace(str string) string {
	var r = regexp.MustCompile(`[ \t]+$`)
	return r.ReplaceAllString(str, "")
}
1092055
func (s *Selection) WrapHtml(html string) *Selection {
	return s.wrapNodes(parseHtml(html)...)
}
416298
func trimSpaces(k AST) AST {
	// trim left hand side of spaces
	for i := 0; i < len(k.Root.raw); i++ {
		if !isWhitespace(k.Root.raw[i]) {
			break
		}

		k.Root.raw = k.Root.raw[1:]
		i--
	}

	// trim right hand side of spaces
	for i := len(k.Root.raw) - 1; i >= 0; i-- {
		if !isWhitespace(k.Root.raw[i]) {
			break
		}

		k.Root.raw = k.Root.raw[:len(k.Root.raw)-1]
	}

	return k
}
403676
func TrimStartSpaceEmptyLine(src string) (result string, err error) {
	lines := strings.Split(src, "\n")
	buffer := bytes.Buffer{}
	for _, line := range lines {
		if !regexpStartSpaceEmptyLine.MatchString(line) {
			if _, err = buffer.WriteString(line + "\n"); err != nil {
				return
			}
		}
	}
	return buffer.String(), nil
}
53815
func trimEmptyField(u *unstructured.Unstructured, fields ...string) {
	val, found, err := unstructured.NestedFieldNoCopy(u.Object, fields...)
	if err != nil || !found {
		return
	}
	remove := false
	switch typedVal := val.(type) {
	case map[string]interface{}:
		if len(typedVal) == 0 { // typed nil/empty map
			remove = true
		}
	case []interface{}:
		if len(typedVal) == 0 { // typed nil/empty slice
			remove = true
		}
	case nil: // untyped nil
		remove = true
	}
	if remove {
		unstructured.RemoveNestedField(u.Object, fields...)
	}
}
1050150
func (u *updateLog) removeHtlc(i uint64) {
	entry := u.htlcIndex[i]
	u.Remove(entry)
	delete(u.htlcIndex, i)

	delete(u.modifiedHtlcs, i)
}
1128684
func NewPartHTML(html string) *Message {
	return &Message{
		Header: Header{"Content-Type": []string{"text/html; charset=\"UTF-8\""}},
		Body:   []byte(html)}
}
447327
func trimHash(l string) string {
	if strings.Contains(l, "#") {
		var index int
		for n, str := range l {
			if strconv.QuoteRune(str) == "'#'" {
				index = n
				break
			}
		}
		return l[:index]
	}
	return l
}
1249687
func (s *Selection) ReplaceWithHtml(html string) *Selection {
	return s.ReplaceWithNodes(parseHtml(html)...)
}
682069
func (g *Graph) TrimLowFrequencyTags(tagCutoff int64) {
	// Remove nodes with value <= total*nodeFraction
	for _, n := range g.Nodes {
		n.LabelTags = trimLowFreqTags(n.LabelTags, tagCutoff)
		for s, nt := range n.NumericTags {
			n.NumericTags[s] = trimLowFreqTags(nt, tagCutoff)
		}
	}
}
1097005
func (c Context) StripHTML(s string) string {
	var buf bytes.Buffer
	var inTag, inQuotes bool
	var tagStart int
	for i, ch := range s {
		if inTag {
			if ch == '>' && !inQuotes {
				inTag = false
			} else if ch == '<' && !inQuotes {
				// false start
				buf.WriteString(s[tagStart:i])
				tagStart = i
			} else if ch == '"' {
				inQuotes = !inQuotes
			}
			continue
		}
		if ch == '<' {
			inTag = true
			tagStart = i
			continue
		}
		buf.WriteRune(ch)
	}
	if inTag {
		// false start
		buf.WriteString(s[tagStart:])
	}
	return buf.String()
}
943727
func chunksToHTML(chunks []formatChunk) template.HTML {
	buf := bytes.Buffer{}
	for _, chunk := range chunks {
		if len(chunk.html) != 0 {
			buf.WriteString(string(chunk.html))
		} else {
			buf.WriteString(template.HTMLEscapeString(chunk.str))
		}
	}
	return template.HTML(buf.String())
}
1342383
func (t *TemplateRenderable) RenderHTML(_ ...string) template.HTML {
	return template.HTML(t.Render())
}
800598
func (p *Pair) Trim() *Pair {
	p.Key = strings.TrimSpace(p.Key)
	p.Value = strings.TrimSpace(p.Value)

	return p
}