links

package
v3.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package links provides a data type for links.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	// 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

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 (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) CopyMarkedAsExisting

func (link Link) CopyMarkedAsExisting() Link

CopyMarkedAsExisting returns a copy of the link that is marked as existing, i/e colored in blue.

func (Link) Display

func (link Link) Display() string

Display returns the display text of the given link. It is not escaped, escape by yourself.

func (Link) Href

func (link Link) Href() string

Href returns escaped content for the href attribute for HTML link. You should always use it.

func (Link) ImgSrc

func (link Link) ImgSrc() string

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

func (link Link) 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 (Link) OfKind

func (link Link) OfKind(kind LinkType) bool

OfKind is true if the given link is of the given kind, i/e the kinds are equal.

func (Link) TargetHypha

func (link Link) TargetHypha() string

TargetHypha returns the canonical name of the target hypha. Use for hypha links.

type LinkType

type LinkType int

LinkType tells what type the given link is.

const (
	// LinkLocalRoot is a link like "/list", "/user-list", etc.
	LinkLocalRoot LinkType = iota
	// LinkLocalHypha is a link like "test", "../test", etc.
	LinkLocalHypha
	// LinkExternal is an external link with specified protocol.
	LinkExternal
)

Jump to

Keyboard shortcuts

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