Documentation ¶
Index ¶
- func GuardedBlocks(data string, begin *regexp.Regexp, end *regexp.Regexp) (blocks []string)
- func IsWhitespace(data string) (isWhitespace bool)
- func LineLengths(data []byte) []uint
- func LineLengthsForFile(filePath string) ([]uint, error)
- func PrefixContinuationLinesWith(paragraph string, prefix string) string
- func PrefixLines(data []byte, prefix []byte) (result []byte)
- func RemoveLine(in string, search string) (out string)
- func RenderMarkdownFileToHTMLFile(markdownFilePath string, htmlFilePath string) (err error)
- func ReplaceBytesInBinary(binaryPathIn string, binaryPathOut string, search []byte, replace []byte, ...) (err error)
- func ReplaceBytesInFile(filePathIn string, filePathOut string, search []byte, replace []byte, n int) (err error)
- func RewriteWebsiteContent(data string, defaultURL string, url string, uriPrefix string, ...) (dataReplaced string)
- func RewriteWebsiteContentDirectory(contentDirectoryPath string, defaultURL string, url string, uriPrefix string, ...) (err error)
- func SearchAndReplaceFile(file string, search *regexp.Regexp, replace string) (err error)
- func SortLines(s string) (sorted string)
- func SortLinesAndTrimSpace(s string) (sorted string)
- func Split(s []byte, sep byte) <-chan []byte
- func StringTrimIndentations(s string) string
- func TrimIndentations(s []byte) []byte
- func WordAfterFirstMatch(str string, substring string) string
- type SynchronizedBuffer
- func (b *SynchronizedBuffer) Bytes() []byte
- func (b *SynchronizedBuffer) Cap() int
- func (b *SynchronizedBuffer) Grow(n int)
- func (b *SynchronizedBuffer) Len() int
- func (b *SynchronizedBuffer) Next(n int) []byte
- func (b *SynchronizedBuffer) Read(p []byte) (n int, err error)
- func (b *SynchronizedBuffer) ReadByte() (byte, error)
- func (b *SynchronizedBuffer) ReadBytes(delim byte) (line []byte, err error)
- func (b *SynchronizedBuffer) ReadFrom(r io.Reader) (n int64, err error)
- func (b *SynchronizedBuffer) ReadRune() (r rune, size int, err error)
- func (b *SynchronizedBuffer) ReadString(delim byte) (line string, err error)
- func (b *SynchronizedBuffer) Reset()
- func (b *SynchronizedBuffer) String() string
- func (b *SynchronizedBuffer) Truncate(n int)
- func (b *SynchronizedBuffer) UnreadByte() error
- func (b *SynchronizedBuffer) UnreadRune() error
- func (b *SynchronizedBuffer) Write(p []byte) (n int, err error)
- func (b *SynchronizedBuffer) WriteByte(c byte) error
- func (b *SynchronizedBuffer) WriteRune(r rune) (n int, err error)
- func (b *SynchronizedBuffer) WriteString(s string) (n int, err error)
- func (b *SynchronizedBuffer) WriteTo(w io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GuardedBlocks ¶ added in v1.2.0
GuardedBlocks extracts blocks of consecutive lines that are guarded by the given begin and end lines. The guarding lines are included in the results. If no end guard is given, the start guard is used as end guard as well.
func IsWhitespace ¶
IsWhitespace checks if the given string consists of only whitespace.
func LineLengths ¶
LineLengths returns a slice of the line lengths of the given data. Line endings (Unix+Windows) are ignored.
func LineLengthsForFile ¶
LineLengthsForFile returns a slice of the line lengths of the given data. Line endings (Unix+Windows) are ignored.
func PrefixContinuationLinesWith ¶
PrefixContinuationLinesWith indents every line except the first one with the given amount of whitespace.
func PrefixLines ¶
PrefixLines prefixes every non-empty line with the given prefix.
func RemoveLine ¶
RemoveLine looks up every line with the given search string in the input and returns an output removing all the selected lines.
func RenderMarkdownFileToHTMLFile ¶
RenderMarkdownFileToHTMLFile reads in the Markdown file, renders it as HTML and writes that output in the HTML file.
func ReplaceBytesInBinary ¶
func ReplaceBytesInBinary(binaryPathIn string, binaryPathOut string, search []byte, replace []byte, n int) (err error)
ReplaceBytesInBinary replaces a certain amount of occurrences of the given bytes in a binary. A negative number of occurrences replaces all matches. If no output file is given, the input file is overwritten.
func ReplaceBytesInFile ¶
func ReplaceBytesInFile(filePathIn string, filePathOut string, search []byte, replace []byte, n int) (err error)
ReplaceBytesInFile replaces a certain amount of occurrences of the given bytes in a file. A negative number of occurrences replaces all matches. If no output file is given, the input file is overwritten.
func RewriteWebsiteContent ¶
func RewriteWebsiteContent(data string, defaultURL string, url string, uriPrefix string, fileHashes map[string]string) (dataReplaced string)
RewriteWebsiteContent replaces all URLs and URIs to the given ones, and gives all URLs and URIs also a hash so they invalidate their cache when their content changes.
func RewriteWebsiteContentDirectory ¶
func RewriteWebsiteContentDirectory(contentDirectoryPath string, defaultURL string, url string, uriPrefix string, staticFiles map[string]*osutil.StaticFile) (err error)
RewriteWebsiteContentDirectory replaces all URLs and URIs to the given ones, and gives all URLs and URIs also a hash so they invalidate their cache when their content changes.
func SearchAndReplaceFile ¶
SearchAndReplaceFile searches for occurrences of a given pattern in a file and replaces them accordingly. Capturing groups can be referenced in the replace string by using $, i.e. $1 is the first capturing group.
func SortLines ¶
SortLines splits the given string into lines, sorts them and then returns the sorted lines as a combined string.
func SortLinesAndTrimSpace ¶
SortLinesAndTrimSpace sorts the lines of the given string and removes all leading and trailing whitespaces.
func Split ¶
Split iteratively splits argument s and returns the split items over the returned channel.
func StringTrimIndentations ¶
StringTrimIndentations removes indentations that were added for a cleaner code style
func TrimIndentations ¶
TrimIndentations removes indentations that were added for a cleaner code style
func WordAfterFirstMatch ¶
WordAfterFirstMatch returns the next word in the string after the given substring, or the empty string if it does not exist.
Types ¶
type SynchronizedBuffer ¶
type SynchronizedBuffer struct {
// contains filtered or unexported fields
}
SynchronizedBuffer holds a concurrency-safe buffer.
func (*SynchronizedBuffer) Bytes ¶
func (b *SynchronizedBuffer) Bytes() []byte
Bytes calls "Bytes" of "bytes.Buffer".
func (*SynchronizedBuffer) Cap ¶
func (b *SynchronizedBuffer) Cap() int
Cap calls "Cap" of "bytes.Buffer".
func (*SynchronizedBuffer) Grow ¶
func (b *SynchronizedBuffer) Grow(n int)
Grow calls "Grow" of "bytes.Buffer".
func (*SynchronizedBuffer) Len ¶
func (b *SynchronizedBuffer) Len() int
Len calls "Len" of "bytes.Buffer".
func (*SynchronizedBuffer) Next ¶
func (b *SynchronizedBuffer) Next(n int) []byte
Next calls "Next" of "bytes.Buffer".
func (*SynchronizedBuffer) Read ¶
func (b *SynchronizedBuffer) Read(p []byte) (n int, err error)
Read calls "Read" of "bytes.Buffer".
func (*SynchronizedBuffer) ReadByte ¶
func (b *SynchronizedBuffer) ReadByte() (byte, error)
ReadByte calls "ReadByte" of "bytes.Buffer".
func (*SynchronizedBuffer) ReadBytes ¶
func (b *SynchronizedBuffer) ReadBytes(delim byte) (line []byte, err error)
ReadBytes calls "ReadBytes" of "bytes.Buffer".
func (*SynchronizedBuffer) ReadFrom ¶
func (b *SynchronizedBuffer) ReadFrom(r io.Reader) (n int64, err error)
ReadFrom calls "ReadFrom" of "bytes.Buffer".
func (*SynchronizedBuffer) ReadRune ¶
func (b *SynchronizedBuffer) ReadRune() (r rune, size int, err error)
ReadRune calls "ReadRune" of "bytes.Buffer".
func (*SynchronizedBuffer) ReadString ¶
func (b *SynchronizedBuffer) ReadString(delim byte) (line string, err error)
ReadString calls "ReadString" of "bytes.Buffer".
func (*SynchronizedBuffer) Reset ¶
func (b *SynchronizedBuffer) Reset()
Reset calls "Reset" of "bytes.Buffer".
func (*SynchronizedBuffer) String ¶
func (b *SynchronizedBuffer) String() string
String calls "String" of "bytes.Buffer".
func (*SynchronizedBuffer) Truncate ¶
func (b *SynchronizedBuffer) Truncate(n int)
Truncate calls "Truncate" of "bytes.Buffer".
func (*SynchronizedBuffer) UnreadByte ¶
func (b *SynchronizedBuffer) UnreadByte() error
UnreadByte calls "UnreadByte" of "bytes.Buffer".
func (*SynchronizedBuffer) UnreadRune ¶
func (b *SynchronizedBuffer) UnreadRune() error
UnreadRune calls "UnreadRune" of "bytes.Buffer".
func (*SynchronizedBuffer) Write ¶
func (b *SynchronizedBuffer) Write(p []byte) (n int, err error)
Write calls "Write" of "bytes.Buffer".
func (*SynchronizedBuffer) WriteByte ¶
func (b *SynchronizedBuffer) WriteByte(c byte) error
WriteByte calls "WriteByte" of "bytes.Buffer".
func (*SynchronizedBuffer) WriteRune ¶
func (b *SynchronizedBuffer) WriteRune(r rune) (n int, err error)
WriteRune calls "WriteRune" of "bytes.Buffer".
func (*SynchronizedBuffer) WriteString ¶
func (b *SynchronizedBuffer) WriteString(s string) (n int, err error)
WriteString calls "WriteString" of "bytes.Buffer".