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 ReplaceDataString(fileContent, startStr, endStr, replaceWith string) string
- type ParseResult
- type Pattern
- type PatternMiddle
- type ReplaceDataOptions
- type ReplaceTypes
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 ReplaceDataString ¶
Types ¶
type ParseResult ¶
type ParseResult struct {
NewCode string
Path string
Lang 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 ¶
Click to show internal directories.
Click to hide internal directories.