// Link defines how formal links should be processed to produce corresponding HTML elements.
558684
func (r *MarkdownRenderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) {
	if len(link) > 0 && !isLink(link) {
		if link[0] != '#' {
			link = []byte(path.Join(r.urlPrefix, string(link)))
		}
	}

	r.Renderer.Link(out, link, title, content)
}
696205
func (l Links) Next(href string, args ...interface{}) Links {
	return l.Link("next", href, args...)
}
1168076
func (s *SetSpec) Link(scope Scope) (TypeSpec, error) {
	if s.linked() {
		return s, nil
	}

	var err error
	s.ValueSpec, err = s.ValueSpec.Link(scope)
	return s, err
}
36798
func ValidateLink(val string) (string, error) {
	_, _, err := ParseLink(val)
	return val, err
}
221166
func Link(doners ...Doner) C {
	c := make(chan struct{})
	cancel := func() { close(c) }

	var once sync.Once
	for _, d := range doners {
		Defer(d, func() { once.Do(cancel) })
	}

	return c
}
370628
func (e *Editor) RmLink(ctx context.Context, pth string) error {
	splpath := path.SplitList(pth)
	nd, err := e.rmLink(ctx, e.root, splpath)
	if err != nil {
		return err
	}
	e.root = nd
	return nil
}
935703
func Links(apidsl func()) {
	if mt, ok := mediaTypeDefinition(); ok {
		dslengine.Execute(apidsl, mt)
	}
}
850611
func (l *Link) HTML() template.HTML {
	if l == nil {
		return ""
	}
	buf := bytes.Buffer{}
	if err := linkifyTemplate.Execute(&buf, l); err != nil {
		panic(err)
	}
	return template.HTML(buf.Bytes())
}
1350485
func (c ConstReference) Link(scope Scope, t TypeSpec) (ConstantValue, error) {
	if t == c.Target.Type {
		return c, nil
	}
	return c.Target.Value.Link(scope, t)
}
436684
func (r *MarkdownRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
	if kind != blackfriday.LINK_TYPE_NORMAL {
		r.Renderer.AutoLink(out, link, kind)
		return
	}

	// Since this method could only possibly serve one link at a time,
	// we do not need to find all.
	if bytes.HasPrefix(link, []byte(setting.AppURL)) {
		m := CommitPattern.Find(link)
		if m != nil {
			m = bytes.TrimSpace(m)
			i := strings.Index(string(m), "commit/")
			j := strings.Index(string(m), "#")
			if j == -1 {
				j = len(m)
			}
			out.WriteString(fmt.Sprintf(` <code><a href="%s">%s</a></code>`, m, tool.ShortSHA1(string(m[i+7:j]))))
			return
		}

		m = IssueFullPattern.Find(link)
		if m != nil {
			m = bytes.TrimSpace(m)
			i := strings.Index(string(m), "issues/")
			j := strings.Index(string(m), "#")
			if j == -1 {
				j = len(m)
			}

			index := string(m[i+7 : j])
			fullRepoURL := setting.AppURL + strings.TrimPrefix(r.urlPrefix, "/")
			var link string
			if strings.HasPrefix(string(m), fullRepoURL) {
				// Use a short issue reference if the URL refers to this repository
				link = fmt.Sprintf(`<a href="%s">#%s</a>`, m, index)
			} else {
				// Use a cross-repository issue reference if the URL refers to a different repository
				repo := string(m[len(setting.AppURL) : i-1])
				link = fmt.Sprintf(`<a href="%s">%s#%s</a>`, m, repo, index)
			}
			out.WriteString(link)
			return
		}
	}

	r.Renderer.AutoLink(out, link, kind)
}
214492
func (i *LocalInstaller) link(from string) error {
	origin, err := filepath.Abs(from)
	if err != nil {
		return err
	}
	dest, err := filepath.Abs(i.Path())
	if err != nil {
		return err
	}
	return os.Symlink(origin, dest)
}
351207
func (w *worker) processLinks(doc *goquery.Document) (result []*url.URL) {
	baseURL, _ := doc.Find("base[href]").Attr("href")
	urls := doc.Find("a[href]").Map(func(_ int, s *goquery.Selection) string {
		val, _ := s.Attr("href")
		if baseURL != "" {
			val = handleBaseTag(doc.Url, baseURL, val)
		}
		return val
	})
	for _, s := range urls {
		// If href starts with "#", then it points to this same exact URL, ignore (will fail to parse anyway)
		if len(s) > 0 && !strings.HasPrefix(s, "#") {
			if parsed, e := url.Parse(s); e == nil {
				parsed = doc.Url.ResolveReference(parsed)
				result = append(result, parsed)
			} else {
				w.logFunc(LogIgnored, "ignore on unparsable policy %s: %s", s, e.Error())
			}
		}
	}
	return
}
1254849
func (t *TypedefSpec) Link(scope Scope) (TypeSpec, error) {
	if t.linked() {
		return t, nil
	}

	var err error
	t.Target, err = t.Target.Link(scope)
	if err == nil {
		t.root = RootTypeSpec(t.Target)
	}
	return t, err
}
661152
func (d *driver) Readlink(p string) (string, error) {
	return sysx.Readlink(p)
}
79875
func (r *FlatChain) Link(rx FlatChains) FlatChains {
	return r.Chain(NewFlatChain(func(c *Context, next NextHandler) {
		rx.HandleContext(c)
		next(c)
	}, r.log))
}
1335428
func (f *FieldSpec) Link(scope Scope) (err error) {
	if f.Type, err = f.Type.Link(scope); err != nil {
		return err
	}
	if f.Default != nil {
		f.Default, err = f.Default.Link(scope, f.Type)
	}
	return err
}
1056299
func NewLink(options ...JITOption) (*LinkState, error) {
	link := &LinkState{}

	argcount, args, argvals := link.encodeArguments(options)
	err := result(C.cuLinkCreate(argcount, args, argvals, &link.state))
	return link, err
}