parser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package parser extracts URLs from markdown content using goldmark. It supports various markdown link formats including inline links, reference links, images, autolinks, and HTML anchor tags. URLs inside code blocks are ignored.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	URL      string // The actual URL
	FilePath string // Which file it was found in
	Text     string // Link text or alt text for images

	// For reference links.
	RefName string   // Reference name (e.g., "myref" in [text][myref])
	Line    int      // Line number (1-indexed)
	Column  int      // Column position (1-indexed)
	Type    LinkType // Type of link

	RefDefLine int // Line where [ref]: url is defined (0 if not reference)
}

Link represents a URL found in a file.

func ExtractLinks(filePath string) ([]Link, error)

ExtractLinks reads a file and returns all HTTP/HTTPS links found.

func ExtractLinksFromContent

func ExtractLinksFromContent(content []byte, filePath string) ([]Link, error)

ExtractLinksFromContent extracts links from markdown content.

func ExtractLinksFromMultipleFiles

func ExtractLinksFromMultipleFiles(filePaths []string) ([]Link, error)

ExtractLinksFromMultipleFiles processes multiple files concurrently and returns all links. Uses a worker pool bounded by the number of CPU cores for optimal parallelism.

type LinkType

type LinkType int

LinkType represents the type of link found in markdown.

const (
	// LinkTypeInline represents a standard markdown link: [text](url).
	LinkTypeInline LinkType = iota
	// LinkTypeReference represents a reference-style link: [text][ref] with [ref]: url.
	LinkTypeReference
	// LinkTypeImage represents an image: ![alt](url).
	LinkTypeImage
	// LinkTypeAutolink represents a bare URL that's auto-linked.
	LinkTypeAutolink
	// LinkTypeHTML represents a link in HTML: <a href="url">.
	LinkTypeHTML
)

func (LinkType) String

func (t LinkType) String() string

String returns the string representation of a LinkType.

Jump to

Keyboard shortcuts

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