Documentation ¶
Overview ¶
Package mycocontext provides a wrapper over context.Context and some operations on the wrapper.
Index ¶
- func ContextFromStringInput(input string, opts options.Options) (Context, CancelFunc)
- func EatUntilSpace(ctx Context) (line string)
- func HyphaExists(ctx Context, hyphaName string) bool
- func HyphaHTMLData(ctx Context, name string) (rawText, binaryHtml string, err error)
- func IsEof(ctx Context) bool
- func IterateHyphaNamesWith(ctx Context, f func(string))
- func NextByte(ctx Context) (b byte, eof bool)
- func NextLine(ctx Context) (line string, done bool)
- func NextRune(ctx Context) (r rune, eof bool)
- func Options(ctx Context) options.Options
- func UnreadRune(ctx Context)
- type CancelFunc
- type Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextFromStringInput ¶
func ContextFromStringInput(input string, opts options.Options) (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 HyphaExists ¶
func HyphaHTMLData ¶
func IsEof ¶
IsEof is true if there is nothing left to read in the input. It does not handle the case when all next characters are \r, which are never returned by NextRune, thus making this function lie.
Be not afraid because everyone lies. Not a good idea to trust a //function// anyway.
func IterateHyphaNamesWith ¶
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 eof is true.
func NextLine ¶
NextLine returns the text in the inputFrom up to the next newline. The characters are gotten using nextByte.
func UnreadRune ¶
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 // TransclusionSupported is true if Mycomarkup is invoked as a stand-alone program, false if used as a library. TransclusionSupported() bool }
Context is the wrapper around context.Context providing type-level safety on presence of several values.