// Text writes a text with an encoding of special runes.
8433
func (w *standardSMLWriter) Text(text string) error {
	var buf bytes.Buffer
	for _, r := range text {
		switch r {
		case '^':
			buf.WriteString("^^")
		case '{':
			buf.WriteString("^{")
		case '}':
			buf.WriteString("^}")
		default:
			buf.WriteRune(r)
		}
	}
	return w.context.Writef(buf.String())
}
795958
func (c *ChatPostMessageCall) Text(text string) *ChatPostMessageCall {
	c.text = text
	return c
}
431167
func (span Span) String() string {
	ret := "<span" + span.Attrs() + ">"
	if span.HTMLEncode {
		ret += html.EscapeString(span.Text)
	} else {
		ret += span.Text
	}
	for _, el := range span.Body {
		ret += el.String()
	}
	ret += "</span>"
	return ret
}
791486
func wrapText(s string, width int, indent int) string {
	buf := bytes.NewBuffer(nil)
	runes := []rune(s)
	linelen, i := 0, 0
	for i < len(runes) {
		if runes[i] == '\n' {
			buf.WriteString("\n")
			if i < len(runes) {
				buf.WriteString(strings.Repeat(" ", indent))
				linelen = indent
			}
		} else if linelen == width {
			buf.WriteString("\n")
			if i < len(runes) {
				buf.WriteString(strings.Repeat(" ", indent))
				linelen = indent
			}
			buf.WriteRune(runes[i])
		} else {
			buf.WriteRune(runes[i])
		}
		i++
		linelen++
	}
	return buf.String()
}
1232548
func (m *markupWriter) Write(ma Markup) (string, error) {
	// if tmr, ok := ma.(*Text); ok {
	// 	return m.ElementWriter.text.Print(tmr), nil
	// }

	if emr, ok := ma.(*Element); ok {
		return m.ElementWriter.Print(emr), nil
	}

	return "", ErrNotMarkup
}
1195962
func (c *Corpus) str(s string) string {
	if s == "" {
		return ""
	}
	if s, ok := c.strs[s]; ok {
		return s
	}
	if c.strs == nil {
		c.strs = make(map[string]string)
	}
	c.strs[s] = s
	return s
}
921610
func (formatter *outputFormatter) Text(s *goquery.Selection) string {
	var buf bytes.Buffer

	// Slightly optimized vs calling Each: no single selection object created
	var f func(*html.Node)
	f = func(n *html.Node) {
		if n.Type == html.TextNode && 0 == n.DataAtom { // NB: had to add the DataAtom check to avoid printing text twice when a textual node embeds another textual node
			// Keep newlines and spaces, like jQuery
			buf.WriteString(n.Data)
		}
		if n.FirstChild != nil {
			for c := n.FirstChild; c != nil; c = c.NextSibling {
				f(c)
			}
		}
	}
	for _, n := range s.Nodes {
		f(n)
	}

	return buf.String()
}
1127964
func CharDescription(ch rune) string {
	/*if ch == '\\' {
		return "\\\\"
	}

	if ch > ' ' && ch <= '~' {
		return string(ch)
	} else if ch == '\n' {
		return "\\n"
	} else if ch == ' ' {
		return "\\ "
	}*/

	b := &bytes.Buffer{}
	escape(b, ch, false) //fmt.Sprintf("%U", ch)
	return b.String()
}
294646
func (p *Lexer) Rune() (rune, error) {

	p.fill()

	r, size := rune(p.buf[p.r]), 1
	if r >= utf8.RuneSelf {
		r, size = utf8.DecodeRune(p.buf[p.r:p.lastByte])
	}
	p.r += size
	p.lastRuneSize = append(p.lastRuneSize, size)
	return r, nil
}
91216
func (z *Tokenizer) Text() []byte {
	switch z.tt {
	case TextToken, CommentToken, DoctypeToken:
		s := z.buf[z.data.start:z.data.end]
		z.data.start = z.raw.end
		z.data.end = z.raw.end
		s = convertNewlines(s)
		if (z.convertNUL || z.tt == CommentToken) && bytes.Contains(s, nul) {
			s = bytes.Replace(s, nul, replacement, -1)
		}
		if !z.textIsRaw {
			s = unescape(s, false)
		}
		return s
	}
	return nil
}
1152425
func (k *Key) Strings(delim string) []string {
	str := k.String()
	if len(str) == 0 {
		return []string{}
	}

	runes := []rune(str)
	vals := make([]string, 0, 2)
	var buf bytes.Buffer
	escape := false
	idx := 0
	for {
		if escape {
			escape = false
			if runes[idx] != '\\' && !strings.HasPrefix(string(runes[idx:]), delim) {
				buf.WriteRune('\\')
			}
			buf.WriteRune(runes[idx])
		} else {
			if runes[idx] == '\\' {
				escape = true
			} else if strings.HasPrefix(string(runes[idx:]), delim) {
				idx += len(delim) - 1
				vals = append(vals, strings.TrimSpace(buf.String()))
				buf.Reset()
			} else {
				buf.WriteRune(runes[idx])
			}
		}
		idx++
		if idx == len(runes) {
			break
		}
	}

	if buf.Len() > 0 {
		vals = append(vals, strings.TrimSpace(buf.String()))
	}

	return vals
}
266073
func (e *Event) Text() (string, error) {
	if e.Type != TextMessage {
		return "", errors.New("Event.Text() called on non-TextMessage event")
	}
	bts, err := ioutil.ReadAll(e)
	return string(bts), err
}
1297086
func (g *Graph) _text(n int, buffer *bytes.Buffer, show bool) {

	sp := ""
	for i := 0; i < n; i++ {
		sp += "  "
	}

	/*
	   When printing strings with newlines, there are two possibilities:
	   block or quoted. Block is cleaner, but limited to leaf nodes. If the node
	   is not leaf (it has subnodes), then we are forced to print a multiline
	   quoted string.

	   If the string has no newlines but spaces or special characters, then the
	   same rule applies: quote those nodes that are non-leaf, print a block
	   otherways.

	   [!] Cannot print blocks at level 0? Or can we?
	*/

	s := "_"
	if g != nil {
		s = _string(g.This)
	}

	if strings.ContainsAny(s, "\n\r \t'\",()") {

		// print quoted, but not at level 0
		// Do not convert " to \" below if level==0 !
		if n > 0 {
			buffer.WriteString(sp[:len(sp)-1])
			buffer.WriteByte('"')
		}

		var c, cp byte

		cp = 0

		for i := 0; i < len(s); i++ {
			c = s[i] // byte, not rune
			if c == 13 {
				continue // ignore CR's
			} else if c == 10 {
				buffer.WriteByte('\n')
				buffer.WriteString(sp)
			} else if c == '"' && n > 0 {
				if cp != '\\' {
					buffer.WriteString("\\\"")
				}
			} else {
				buffer.WriteByte(c)
			}
			cp = c
		}

		if n > 0 {
			buffer.WriteString("\"")
		}
		buffer.WriteString("\n")
	} else {
		if len(s) == 0 && !show {
			n--
		} else {
			if len(s) == 0 && show {
				s = "_"
			}
			buffer.WriteString(sp)
			buffer.WriteString(s)
			buffer.WriteByte('\n')
		}
	}

	if g != nil {
		for i := 0; i < len(g.Out); i++ {
			node := g.Out[i]
			node._text(n+1, buffer, show)
		}
	}
}
1213147
func (r *RegexLiteral) String() string {
	if r.Val != nil {
		return fmt.Sprintf("/%s/", strings.Replace(r.Val.String(), `/`, `\/`, -1))
	}
	return ""
}
1171068
func (p *Parser) Text() bool {

	s, b := p.TemplateText()

	if b {
		p.ev.Add(s)
		return true
	}
	return false
}
433261
func (w *Wow) Text(txt string) *Wow {
	w.mu.Lock()
	w.txt = txt
	w.mu.Unlock()
	return w
}
1078446
func lexText(l *lexer) stateFn {
	var r, lastChar rune
	for {
		lastChar = r
		r = l.next()

		// comment / soydoc handling
		if r == '/' {
			switch l.next() {
			case '/':
				// '//' only begins a comment if the previous character is whitespace,
				// or if we are the start of input.
				var lastCharEmitted = lastChar
				if lastChar == 0 && l.lastEmit.val != "" {
					lastCharEmitted = rune(l.lastEmit.val[len(l.lastEmit.val)-1])
				}
				if lastCharEmitted == 0 || isSpaceEOL(lastCharEmitted) {
					maybeEmitText(l, 3)
					if lastChar != 0 {
						l.start++ // ignore the preceeding space, if present.
					}
					return lexLineComment(l)
				}
			case '*':
				maybeEmitText(l, 2)
				if l.next() == '*' {
					return lexSoyDoc(l)
				}
				l.backup()
				return lexBlockComment(l)
			}
			l.backup()
		}

		// eof or entering a tag?
		switch r {
		case '{':
			l.backup()
			maybeEmitText(l, 0)
			return lexLeftDelim
		case '}':
			return l.errorf("unexpected closing delimiter } found in input.")
		case eof:
			l.backup()
			maybeEmitText(l, 0)
			l.emit(itemEOF)
			return nil
		}
	}
}