ghissue

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ghissue provides a Goldmark extension for GitHub issue and PR references. It transforms references like #123 or owner/repo#123 into clickable links that point to the actual issue or pull request on GitHub.

Index

Constants

This section is empty.

Variables

View Source
var KindGitHubIssue = ast.NewNodeKind("GitHubIssue")

KindGitHubIssue is a NodeKind of the GitHubIssue node.

Functions

func DetectRepository

func DetectRepository() string

DetectRepository attempts to detect the GitHub repository from git remote

func NewHTMLRenderer

func NewHTMLRenderer(config *Config) renderer.NodeRenderer

NewHTMLRenderer creates a new HTML renderer for GitHub issue/PR references

func NewParser

func NewParser(config *Config) parser.InlineParser

NewParser creates a new inline parser for GitHub issue/PR references

func NewTransformer

func NewTransformer(config *Config) parser.ASTTransformer

NewTransformer creates a new AST transformer for GitHub issue/PR references

Types

type Config

type Config struct {
	// Repository is the default repository in the format "owner/repo"
	// Used for resolving references like #123
	Repository string

	// GitHubToken is an optional GitHub personal access token for API calls
	// If not provided, unauthenticated requests will be made (rate limited)
	GitHubToken string
}

Config holds configuration for the GitHub issue extension

type Extender

type Extender struct {
	// contains filtered or unexported fields
}

Extender implements goldmark.Extender to add GitHub issue/PR reference support

func New

func New(opts ...Option) *Extender

New creates a new GitHub issue/PR Extender with the given options

func (*Extender) Extend

func (e *Extender) Extend(m goldmark.Markdown)

Extend extends the Goldmark parser and renderer with GitHub issue/PR functionality

type GitHubIssue

type GitHubIssue struct {
	ast.BaseInline

	// Repository in the format "owner/repo"
	// Empty string means use the default repository
	Repository []byte

	// Number is the issue or PR number
	Number []byte

	// IsExternal indicates if this was an external reference (owner/repo#123)
	// vs an internal reference (#123)
	IsExternal bool
}

GitHubIssue represents a GitHub issue or PR reference in markdown

func NewExternalGitHubIssue

func NewExternalGitHubIssue(repo, number []byte) *GitHubIssue

NewExternalGitHubIssue creates a new GitHubIssue node for external references

func NewGitHubIssue

func NewGitHubIssue(repo, number []byte) *GitHubIssue

NewGitHubIssue creates a new GitHubIssue node

func (*GitHubIssue) Dump

func (n *GitHubIssue) Dump(source []byte, level int)

Dump implements Node.Dump

func (*GitHubIssue) Kind

func (n *GitHubIssue) Kind() ast.NodeKind

Kind implements Node.Kind

type HTMLRenderer

type HTMLRenderer struct {
	// contains filtered or unexported fields
}

HTMLRenderer renders GitHubIssue nodes as HTML links

func (*HTMLRenderer) RegisterFuncs

func (r *HTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)

RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs

type Option

type Option func(*Config)

Option is a functional option for configuring the extension

func WithGitHubToken

func WithGitHubToken(token string) Option

WithGitHubToken sets the GitHub API token for authenticated requests

func WithRepository

func WithRepository(repo string) Option

WithRepository sets the default repository for issue/PR references

Jump to

Keyboard shortcuts

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