package markdownish import ( "strings" "unicode" "unicode/utf8" ) // TODO to avoid having to include unicode's tables, self-implement unicode.IsSpace func unicodeIsSpace(r rune) bool { return unicode.IsSpace(r) } // TODO Remove in Go 1.21. func max(x, y int) int { if x >= y { return x } return y } func escape(raw string, allowed func(rune) bool) string { b := new(strings.Builder) for len(raw) > 0 { r, size := utf8.DecodeRuneInString(raw) raw = raw[size:] if !allowed(r) { r = utf8.RuneError } b.WriteRune(r) } return b.String() }