// WithMarkup returns a derived styled text with a new markup @r available for
// a given style.  Markup starts by a @ sign, and is followed then by a rune
// indicating the particular style. Default style is marked by @N.
//
// This simple markup is inspired from github/gdamore/tcell, but with somewhat
// different defaults: unless at least one non-default markup is registered,
// markup commands processing is not activated, and @ is treated as any other
// character.
WithMarkup returns a derived styled text with a new markup @r available for
a given style.  Markup starts by a @ sign, and is followed then by a rune
indicating the particular style. Default style is marked by @N.

This simple markup is inspired from github/gdamore/tcell, but with somewhat
different defaults: unless at least one non-default markup is registered,
markup commands processing is not activated, and @ is treated as any other
character.
// WithMarkup returns a derived styled text with a new markup @r available for // a given style . Markup starts by a @ sign and is followed then by a rune // indicating the particular style . Default style is marked by @N . // // This simple markup is inspired from github / gdamore / tcell but with somewhat // different defaults : unless at least one non - default markup is registered // markup commands processing is not activated and @ is treated as any other // character .
func (stt StyledText) WithMarkup(r rune, style gruid.Style) StyledText {
	if r == ' ' || r == '\n' {
		return stt
	}
	if len(stt.markups) == 0 {
		stt.markups = map[rune]gruid.Style{}
	} else {
		omarks := stt.markups
		stt.markups = make(map[rune]gruid.Style, len(omarks))
		for k, v := range omarks {
			stt.markups[k] = v
		}
	}
	if r == 'N' {
		stt.style = style
		return stt
	}
	stt.markups[r] = style
	return stt
}
func ( stt StyledText ) WithMarkup ( r rune , style gruid . Style ) StyledText { if r == ' ' || r == '\n' { return stt } if len ( stt . markups ) == 0 { stt . markups = map [ rune ] gruid . Style { } } else { omarks := stt . markups stt . markups = make ( map [ rune ] gruid . Style , len ( omarks ) ) for k , v := range omarks { stt . markups [ k ] = v } } if r == 'N' { stt . style = style return stt } stt . markups [ r ] = style return stt }
WithMarkup returns a derived styled text with a new markup @r available for
a given style.
WithMarkup returns a derived styled text with a new markup @r available for a given style .
// avoid strange cases that can conflict with format // N has a built-in meaning