links

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

= Link
This module features a datatype used all across the project — link! It is not the type of link you see in a mycomarkup document, it is an abstraction that ties them together.

Basically, a link can be:
* **Created.** To be created, these things are needed:
** //An address// the link is pointing to.
** //An address// from which the link is pointing from. Usually, current hypha name, but who knows how this library shall be used.
** //A display text// that can be empty.
* **Marked as existing.** All links are considered as nonexistent until marked as existing.
* **Shown.** A renderer uses some getter methods on the link and does what it has to.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {

	// Settable stuff
	DestinationUnknown bool
	// contains filtered or unexported fields
}

Link is an abstraction for universal representation of links, be they links in mycomarkup links or whatever.

func From

func From(srcAddress, srcDisplay, srcHypha string) *Link

func (*Link) Address

func (link *Link) Address() string

Address returns the address of the given link. Why would you need that?

func (*Link) Classes

func (link *Link) Classes() (classes string)

Classes returns CSS class string for given link. It is not wrapped in any quotes, wrap yourself.

func (*Link) Display

func (link *Link) Display() string

Display returns the display text of the given link.

func (*Link) Exists added in v0.2.0

func (link *Link) Exists() bool

func (*Link) Href

func (link *Link) Href() string

Href returns content for the href attrubite for hyperlink. You should always use it.

func (*Link) ImgSrc

func (link *Link) ImgSrc() string

ImgSrc returns content for src attribute of img tag. Used with `img{}`.

func (*Link) ItExists

func (link *Link) ItExists() *Link

ItExists notes that the destination makes sense, exists.

func (*Link) OfKind

func (link *Link) OfKind(kind LinkType) bool

OfKind returns if the given link is of the given kind.

func (*Link) String

func (link *Link) String() string

String returns a debugging string representation of the given link.

type LinkType

type LinkType int

LinkType tells what type the given link is.

const (
	// LinkInvalid is an error state for LinkType.
	LinkInvalid LinkType = iota
	// LinkLocalRoot is a link like "/list", "/user-list", etc.
	LinkLocalRoot
	// LinkLocalHypha is a link like "test", "../test", etc.
	LinkLocalHypha
	// LinkExternal is an external link with specified protocol.
	LinkExternal
	// LinkInterwiki is currently left unused.
	LinkInterwiki
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL