tagscan

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package tagscan extracts control tags like <dtmf>1</dtmf> from a streamed text response, so a processor can act on the tags and speak the rest. It buffers across chunks, since a tag may span several, and holds back a trailing partial tag until it completes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner extracts <tag>value</tag> control tags for a fixed set of tag names from a stream of text chunks, returning the text with the tags removed.

func New

func New(tags ...string) *Scanner

New builds a Scanner recognizing the given tag names.

func (*Scanner) Feed

func (s *Scanner) Feed(chunk string, onTag func(tag, value string)) string

Feed appends chunk, invokes onTag for each complete tag found (in order), and returns the text safe to emit now: tag content removed, with a trailing partial tag held back until a later Feed or Flush completes it.

func (*Scanner) Flush

func (s *Scanner) Flush() string

Flush returns any held-back text and clears the buffer. Call it at the end of a response, when no more chunks will complete a partial tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL