Documentation ¶
Overview ¶
Package links provides a data type for links.
Index ¶
- type InterwikiLink
- func (l *InterwikiLink) Classes(_ mycocontext.Context) string
- func (l *InterwikiLink) DisplayedText() string
- func (l *InterwikiLink) Err() error
- func (l *InterwikiLink) HyphaProbe(mycocontext.Context) func(string)
- func (l *InterwikiLink) ImgSrc(ctx mycocontext.Context) string
- func (l *InterwikiLink) LinkHref(ctx mycocontext.Context) string
- func (l *InterwikiLink) TryToGetError(ctx mycocontext.Context) bool
- type LegacyLink
- func (link LegacyLink) Classes() (classes string)
- func (link LegacyLink) CopyMarkedAsExisting() LegacyLink
- func (link LegacyLink) Display() string
- func (link LegacyLink) Href() string
- func (link LegacyLink) ImgSrc() string
- func (link LegacyLink) IsBlueLink() bool
- func (link LegacyLink) OfKind(kind LinkType) bool
- func (link LegacyLink) TargetHypha() string
- type Link
- type LinkType
- type LocalLink
- func (l *LocalLink) Classes(ctx mycocontext.Context) string
- func (l *LocalLink) DisplayedText() string
- func (l *LocalLink) Existing() bool
- func (l *LocalLink) HyphaProbe(ctx mycocontext.Context) func(string)
- func (l *LocalLink) ImgSrc(ctx mycocontext.Context) string
- func (l *LocalLink) LinkHref(ctx mycocontext.Context) string
- func (l *LocalLink) Target() string
- type LocalRootedLink
- func (l *LocalRootedLink) Classes(_ mycocontext.Context) string
- func (l *LocalRootedLink) DisplayedText() string
- func (l *LocalRootedLink) HyphaProbe(_ mycocontext.Context) func(string)
- func (l *LocalRootedLink) ImgSrc(_ mycocontext.Context) string
- func (l *LocalRootedLink) LinkHref(_ mycocontext.Context) string
- type URLLink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InterwikiLink ¶ added in v4.3.1
type InterwikiLink struct {
// contains filtered or unexported fields
}
InterwikiLink in Mycomarkup has this syntax:
[[prefix>target]] [[prefix>target|display]]
For every prefix, there is a known link format. A link format is a format string, that might resemble Go's format strings, but they are actually not. This is DSL for link formats. It is inspired by DokuWiki's interwiki link format: https://www.dokuwiki.org/interwiki.
https://example.org/view/{NAME}
Supported instructions are (more will be added):
{NAME} is the document name without any encoding.
func (*InterwikiLink) Classes ¶ added in v4.3.1
func (l *InterwikiLink) Classes(_ mycocontext.Context) string
func (*InterwikiLink) DisplayedText ¶ added in v4.3.1
func (l *InterwikiLink) DisplayedText() string
func (*InterwikiLink) Err ¶ added in v4.3.1
func (l *InterwikiLink) Err() error
func (*InterwikiLink) HyphaProbe ¶ added in v4.3.1
func (l *InterwikiLink) HyphaProbe(mycocontext.Context) func(string)
func (*InterwikiLink) ImgSrc ¶ added in v4.3.1
func (l *InterwikiLink) ImgSrc(ctx mycocontext.Context) string
func (*InterwikiLink) LinkHref ¶ added in v4.3.1
func (l *InterwikiLink) LinkHref(ctx mycocontext.Context) string
func (*InterwikiLink) TryToGetError ¶ added in v4.3.1
func (l *InterwikiLink) TryToGetError(ctx mycocontext.Context) bool
type LegacyLink ¶ added in v4.3.1
type LegacyLink struct {
// contains filtered or unexported fields
}
LegacyLink is an abstraction for universal representation of links, be they links in mycomarkup links or whatever.
ADT would help out a lot.
func From ¶
func From(srcAddress, srcDisplay, srcHypha string) LegacyLink
From makes a link from the given source address and display text on the given hypha. The arguments are stripped of whitespace on both sides before further processing.
func (LegacyLink) Classes ¶ added in v4.3.1
func (link LegacyLink) Classes() (classes string)
Classes returns CSS class string for given link. It is not wrapped in any quotes, wrap yourself.
func (LegacyLink) CopyMarkedAsExisting ¶ added in v4.3.1
func (link LegacyLink) CopyMarkedAsExisting() LegacyLink
CopyMarkedAsExisting returns a copy of the link that is marked as existing, i/e colored in blue.
func (LegacyLink) Display ¶ added in v4.3.1
func (link LegacyLink) Display() string
Display returns the display text of the given link. It is not escaped, escape by yourself.
func (LegacyLink) Href ¶ added in v4.3.1
func (link LegacyLink) Href() string
Href returns escaped content for the href attribute for HTML link. You should always use it.
func (LegacyLink) ImgSrc ¶ added in v4.3.1
func (link LegacyLink) ImgSrc() string
ImgSrc returns escaped content for src attribute of img tag. Used with `img{}`.
func (LegacyLink) IsBlueLink ¶ added in v4.3.1
func (link LegacyLink) IsBlueLink() bool
IsBlueLink is true if the link should be blue, not red. Red links are links to hyphae that do not exist, all other links are blue.
func (LegacyLink) OfKind ¶ added in v4.3.1
func (link LegacyLink) OfKind(kind LinkType) bool
OfKind is true if the given link is of the given kind, i/e the kinds are equal.
func (LegacyLink) TargetHypha ¶ added in v4.3.1
func (link LegacyLink) TargetHypha() string
TargetHypha returns the canonical name of the target hypha. Use for hypha links.
type Link ¶
type Link interface { // Classes returns a string to put into the class attr in HTML. Classes(ctx mycocontext.Context) string // LinkHref returns a string to put into the href attr of <a>. LinkHref(ctx mycocontext.Context) string // ImgSrc returns a string to put into the src attr of <img>. ImgSrc(ctx mycocontext.Context) string // DisplayedText returns a string to put inside <a>. DisplayedText() string // HyphaProbe returns a function that captures the Link. Probes are checked against all existing hyphae. This is Mycorrhiza-specific. If it is nil, do not check this link for existence. TODO: make it optional. HyphaProbe(ctx mycocontext.Context) func(string) }
Link is a link of some kind.
type LocalLink ¶ added in v4.3.1
type LocalLink struct {
// contains filtered or unexported fields
}
func (*LocalLink) Classes ¶ added in v4.3.1
func (l *LocalLink) Classes(ctx mycocontext.Context) string
func (*LocalLink) DisplayedText ¶ added in v4.3.1
func (*LocalLink) HyphaProbe ¶ added in v4.3.1
func (l *LocalLink) HyphaProbe(ctx mycocontext.Context) func(string)
func (*LocalLink) ImgSrc ¶ added in v4.3.1
func (l *LocalLink) ImgSrc(ctx mycocontext.Context) string
type LocalRootedLink ¶ added in v4.3.1
type LocalRootedLink struct {
// contains filtered or unexported fields
}
func (*LocalRootedLink) Classes ¶ added in v4.3.1
func (l *LocalRootedLink) Classes(_ mycocontext.Context) string
func (*LocalRootedLink) DisplayedText ¶ added in v4.3.1
func (l *LocalRootedLink) DisplayedText() string
func (*LocalRootedLink) HyphaProbe ¶ added in v4.3.1
func (l *LocalRootedLink) HyphaProbe(_ mycocontext.Context) func(string)
func (*LocalRootedLink) ImgSrc ¶ added in v4.3.1
func (l *LocalRootedLink) ImgSrc(_ mycocontext.Context) string
func (*LocalRootedLink) LinkHref ¶ added in v4.3.1
func (l *LocalRootedLink) LinkHref(_ mycocontext.Context) string
type URLLink ¶ added in v4.3.1
type URLLink struct {
// contains filtered or unexported fields
}
func (*URLLink) DisplayedText ¶ added in v4.3.1
func (*URLLink) HyphaProbe ¶ added in v4.3.1
func (l *URLLink) HyphaProbe(_ mycocontext.Context) func(string)