// Highlight returns a copy of s as an HTML string with syntax
// highlighting applied.
14800
func (ns *Namespace) Highlight(s interface{}, lang, opts string) (template.HTML, error) {
	ss, err := cast.ToStringE(s)
	if err != nil {
		return "", err
	}

	highlighted, _ := ns.deps.ContentSpec.Highlight(ss, lang, opts)
	return template.HTML(highlighted), nil
}
718942
func (s *Separator) Render(style *renderStyle) string {
	// loop over getting dashes
	parts := []string{}
	for i := 0; i < style.columns; i++ {
		w := style.PaddingLeft + style.CellWidth(i) + style.PaddingRight
		parts = append(parts, strings.Repeat(style.BorderX, w))
	}

	switch s.where {
	case LINE_TOP:
		return style.BorderTopLeft + strings.Join(parts, style.BorderTop) + style.BorderTopRight
	case LINE_SUBTOP:
		return style.BorderLeft + strings.Join(parts, style.BorderTop) + style.BorderRight
	case LINE_BOTTOM:
		return style.BorderBottomLeft + strings.Join(parts, style.BorderBottom) + style.BorderBottomRight
	case LINE_INNER:
		return style.BorderLeft + strings.Join(parts, style.BorderI) + style.BorderRight
	}
	panic("not reached")
}
915115
func capitalize(s string) string {
	if len(s) == 0 {
		return s
	}
	x, i := utf8.DecodeRuneInString(s)
	return string(unicode.ToUpper(x)) + string(s[i:])
}
247765
func Text(node *html.Node) string {
	joiner := func(s []string) string {
		n := 0
		for i := range s {
			trimmed := strings.TrimSpace(s[i])
			if trimmed != "" {
				s[n] = trimmed
				n++
			}
		}
		return strings.Join(s[:n], " ")
	}
	return TextJoin(node, joiner)
}
128689
func Colorize(msg string, color int) string {
	return ColorEscape(color) + msg + ColorResetEscape
}
193716
func HighlightPostTagEqual(o1, o2 *HighlightPostTagOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
114556
func (i HintStyle) String() string {
	switch i {
	case HintStyleDefault:
		return "HintStyleDefault"
	case HintStyleNone:
		return "HintStyleNone"
	case HintStyleSlight:
		return "HintStyleSlight"
	case HintStyleMedium:
		return "HintStyleMedium"
	case HintStyleFull:
		return "HintStyleFull"
	default:
		return fmt.Sprintf("HintStyle(%d)", i)
	}
}
358502
func indent(s string) (out string) {
	for _, l := range strings.SplitAfter(s, "\n") {
		out += fmt.Sprintf("  %s", l)
	}

	return
}
880468
func Color(value string) *trees.Style {
	return &trees.Style{Name: "color", Value: value}
}
1355943
func Focus(t *testing.T, text string, f func(*testing.T, G, S), opts ...Option) bool {
	t.Helper()
	return Run(t, text, f, append(opts, func(c *config) { c.focus = true })...)
}
1361305
func indent(s string) int {
	var i int

	for _, b := range s {
		if b != unicodeSpace {
			break
		}
		i++
	}

	return i / 2
}
66795
func Colorize(x string) string {
	attr := 0
	fg := 39
	bg := 49

	for _, key := range x {
		c, ok := codeMap[int(key)]
		switch {
		case !ok:
			log.Printf("Wrong color syntax: %c", key)
		case 0 <= c && c <= 8:
			attr = c
		case 30 <= c && c <= 37:
			fg = c
		case 40 <= c && c <= 47:
			bg = c
		case c == 60:
			fg += c
		}
	}
	return fmt.Sprintf("\033[%d;%d;%dm", attr, fg, bg)
}
854334
func (c Colour) Brighten(factor float64) Colour {
	r := float64(c.Red())
	g := float64(c.Green())
	b := float64(c.Blue())

	if factor < 0 {
		factor++
		r *= factor
		g *= factor
		b *= factor
	} else {
		r = (255-r)*factor + r
		g = (255-g)*factor + g
		b = (255-b)*factor + b
	}
	return NewColour(uint8(r), uint8(g), uint8(b))
}
953599
func (formatter *Formatter) Color(text string) string {
	var levelColor []byte
	if formatter.Event.Level >= event.Error {
		levelColor = colors.Red
	} else if formatter.Event.Level == event.Warning {
		levelColor = colors.Yellow
	} else {
		levelColor = colors.Cyan
	}
	return fmt.Sprintf("%s%s%s", levelColor, text, colors.Reset)
}
585306
func Color(str string, color int) string {
	return applyTransform(str, func(idx int, line string) string {
		return fmt.Sprintf("%s%s%s", getColor(color), line, RESET)
	})
}
1073371
func (l *EventListener) Apply(h *HTML) {
	h.eventListeners = append(h.eventListeners, l)
}
787220
func (h highlightHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
	highlighted, err := syntaxhighlight.AsHTML(text)
	if err != nil {
		h.Renderer.BlockCode(out, text, lang)
	} else {

		if out.Len() > 0 {
			out.WriteByte('\n')
		}

		// parse out the language names/classes
		count := 0
		for _, elt := range strings.Fields(lang) {
			if elt[0] == '.' {
				elt = elt[1:]
			}
			if len(elt) == 0 {
				continue
			}
			if count == 0 {
				out.WriteString("<pre><code class=\"prettyprint language-")
			} else {
				out.WriteByte(' ')
			}
			out.Write([]byte(elt)) // attrEscape(out, []byte(elt))
			count++
		}

		if count == 0 {
			out.WriteString("<pre><code class=\"prettyprint\">")
		} else {
			out.WriteString("\">")
		}

		out.Write(highlighted)
		out.WriteString("</code></pre>\n")
	}
}