parser

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package parser extracts URLs from markdown content using goldmark.

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
	Line     int      // Line number (1-indexed)
	Column   int      // Column position (1-indexed)
	Text     string   // Link text or alt text for images
	Type     LinkType // Type of link

	// For reference links.
	RefName    string // Reference name (e.g., "myref" in [text][myref])
	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 and returns all links.

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