Documentation ¶
Overview ¶
Package mycocontext provides a wrapper over context.Context and some operations on the wrapper.
Index ¶
- func ContextFromStringInput(hyphaName, input string) (Context, CancelFunc)
- func EatUntilSpace(ctx Context) (line string)
- func NextByte(ctx Context) (b byte, done bool)
- func NextLine(ctx Context) (line string, done bool)
- func NextRune(ctx Context) (r rune, done bool)
- func UnreadRune(ctx Context)
- type CancelFunc
- type Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextFromStringInput ¶
func ContextFromStringInput(hyphaName, input string) (Context, CancelFunc)
ContextFromStringInput returns the context for the given input.
func EatUntilSpace ¶
EatUntilSpace reads characters until it encounters a non-space character. The read characters are returned. No errors are reported even if there are any, be bold.
func NextByte ¶
NextByte returns the next byte in the inputFrom. The CR byte (\r) is never returned, if there is a CR in the inputFrom, the byte after it is returned. If there is no next byte, the NL byte (\n) is returned and done is true.
func NextLine ¶
NextLine returns the text in the inputFrom up to the next newline. The characters are gotten using nextByte.
func UnreadRune ¶ added in v0.5.4
func UnreadRune(ctx Context)
UnreadRune unreads the previous rune. Pray so it doesn't throw any errors, because they are ignored.
Types ¶
type CancelFunc ¶
type CancelFunc context.CancelFunc
CancelFunc is a function you call to cancel the context. Why would you, though?
type Context ¶
type Context interface { context.Context // HyphaName returns the name of the processed hypha. HyphaName() string // Input returns the buffer which contains all characters of the hypha text. Input() *bytes.Buffer // RecursionLevel returns current recursive transclusion level. RecursionLevel() uint // WithIncrementedRecursionLevel returns a copy of the context but with the recursion level incremented. // // lvl1 := ctx.RecursionLevel() // lvl2 := ctx.WithIncrementedRecursionLevel().RecursionLevel() // lvl2 - lvl1 == 1 WithIncrementedRecursionLevel() Context // WebSiteURL returns the URL of the wiki, including the protocol (http or https). It is used for generating OpenGraph meta tags. WebSiteURL() string }
Context is the wrapper around context.Context providing type-level safety on presence of several values.
func WithBuffer ¶
WithBuffer returns a copy of the given context but with a different input buffer.
func WithWebSiteURL ¶ added in v0.5.0
WithWebSiteURL returns a copy of the given context but with the website URL set to the given one instead of the default empty string. The url should not end on slash because that would break the links generated by the library.