internal/docsite/links.go
internal/docsite · 189 lines · 8 declarations · source
Declarations
var inlineLink, referenceLink, scheme and 2 more
var (
inlineLink = regexp.MustCompile(`\]\(([^)\s]+)((?:\s+"[^"]*")?)\)`)
referenceLink = regexp.MustCompile(`(?m)^(\s{0,3}\[[^\]]+\]:\s*)(\S+)`)
scheme = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9+.-]*:`)
fence = regexp.MustCompile("^\\s{0,3}(```|~~~)")
backtickRun = regexp.MustCompile("`+")
)
const staticDir
const staticDir = "site/static/"
staticDir is the renderer's static directory. Its files are served from the site's root: the renderer places site/static/img/x.png at /img/x.png and resolves such a path against the base URL.
func resolveLinks
func resolveLinks(pages []page, opts Options, packages []goPackage) error
resolveLinks rewrites every page's links in place and reports every broken one at once, so a run names the whole list rather than the first.
func rewriteLinks
func rewriteLinks(p page, targets map[string]string, opts Options) (string, []string)
rewriteLinks rewrites one page. Fenced code and code spans are left alone: text in them is an example, not a link.
func outsideCode
func outsideCode(line string, open *string, fn func(string) string) string
outsideCode applies fn to the parts of a line that are not inside a code span. A span opens with a run of backticks and closes with a run of the same length; open carries an unclosed opener from one line of a paragraph to the next.
func resolveTarget
func resolveTarget(p page, target string, targets map[string]string, opts Options) (string, error)
func sourceURL
func sourceURL(opts Options, kind, repoPath string) string
func pageName
func pageName(p page) string