Documentation
¶
Index ¶
- func FindData(fileContent string, pattern Pattern) (start, end int, result string)
- func FindDataWithAlternative(fileContent string, pattern1, pattern2 Pattern) (start, end int, result string)
- func FindDataWithCode(fileContent, startStr, endStr string) (start, end int, result, codeBlock, language string)
- func MatchMiddle(fileContent string, pattern PatternMiddle, ...) string
- func ParseCommand(command string) types.TerminalCommand
- func ReplaceData[F ReplaceTypes](fileContent, startStr, endStr string, op F, opt ...ReplaceDataOptions) string
- func ReplaceDataFunc(fileContent, startStr, endStr string, process func(data string) string) string
- func ReplaceDataPtr[F ReplaceTypesPtr](fileContent *string, opt ReplaceDataOptionsPtr[F])
- func ReplaceDataString(fileContent, startStr, endStr, replaceWith string) string
- type ParseResult
- type Pattern
- type PatternMiddle
- type ReplaceDataOptions
- type ReplaceDataOptionsPtr
- type ReplaceTypes
- type ReplaceTypesPtr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindDataWithAlternative ¶
func FindDataWithCode ¶
func FindDataWithCode(fileContent, startStr, endStr string) (start, end int, result, codeBlock, language string)
FindDataWithCode searches for content delimited by startStr and endStr within fileContent. It also extracts any code block following the found content. Returns the start and end indexes of the found content, the content itself, the code block, and the code's language if specified. If the start or end strings are not found, or if the code block is not properly terminated, returns -1 for indexes and empty strings for content, code, and language.
func MatchMiddle ¶
func MatchMiddle(fileContent string, pattern PatternMiddle, process func(part1, part2 string) string) string
func ParseCommand ¶
func ParseCommand(command string) types.TerminalCommand
func ReplaceData ¶
func ReplaceData[F ReplaceTypes](fileContent, startStr, endStr string, op F, opt ...ReplaceDataOptions) string
func ReplaceDataFunc ¶
func ReplaceDataPtr ¶ added in v1.4.0
func ReplaceDataPtr[F ReplaceTypesPtr](fileContent *string, opt ReplaceDataOptionsPtr[F])
func ReplaceDataString ¶
Types ¶
type ParseResult ¶
type ParseResult struct {
NewCode string
Path string
Lang string
File string
ID string
JS string
Endpoint string
Before []types.TerminalCommand
Cmd []types.TerminalCommand
After []types.TerminalCommand
CodeBlockShowStart int
CodeBlockShowEnd int
IsStream bool
IsEdit bool
InjectCode bool
}
func ParseCast ¶
func ParseCast(cast, code string) ParseResult
type Pattern ¶
func NewShortPattern ¶
type PatternMiddle ¶
type PatternMiddle struct {
Start string
StartAlt string
Middle string
MiddleStart string
MiddleEnd string
End string
EndAlt string
}
func PatternMiddleSimple ¶
func PatternMiddleSimple(start, middle, end string) PatternMiddle
type ReplaceDataOptions ¶
type ReplaceDataOptionsPtr ¶ added in v1.4.0
type ReplaceDataOptionsPtr[F ReplaceTypesPtr] struct { StartStr *string EndStr *string Pattern *string Op F Once bool OnlyAllowOnStart bool }
ReplaceDataOptionsPtr takes pointer to the fileContent.
you either use Pattern or StartStr/EndStr
type ReplaceTypes ¶
type ReplaceTypesPtr ¶ added in v1.4.0
Click to show internal directories.
Click to hide internal directories.