mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Replace deprecated transforms.RemoveFunc with runes.Remove
This commit is contained in:
parent
d21802dbc6
commit
20a44c5025
1 changed files with 4 additions and 8 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/charmbracelet/charm"
|
||||
"github.com/dustin/go-humanize"
|
||||
"golang.org/x/text/runes"
|
||||
"golang.org/x/text/transform"
|
||||
"golang.org/x/text/unicode/norm"
|
||||
)
|
||||
|
@ -85,19 +86,14 @@ func (m markdown) relativeTime() string {
|
|||
}
|
||||
|
||||
// Normalize text to aid in the filtering process. In particular, we remove
|
||||
// diacritics, "ö" becomes "o".
|
||||
// diacritics, "ö" becomes "o". Note that Mn is the unicode key for nonspacing
|
||||
// marks.
|
||||
func normalize(in string) (string, error) {
|
||||
t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)
|
||||
t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
|
||||
out, _, err := transform.String(t, in)
|
||||
return out, err
|
||||
}
|
||||
|
||||
// Returns whether a given rune is a nonspacing mark (Mn is the key for
|
||||
// nonspacing marks)
|
||||
func isMn(r rune) bool {
|
||||
return unicode.Is(unicode.Mn, r)
|
||||
}
|
||||
|
||||
// wrapMarkdowns wraps a *charm.Markdown with a *markdown in order to add some
|
||||
// extra metadata.
|
||||
func wrapMarkdowns(t DocType, md []*charm.Markdown) (m []*markdown) {
|
||||
|
|
Loading…
Reference in a new issue