linkrewrite

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package linkrewrite handles Markdown link rewriting across different output formats. It transforms .md file references in HTML content to appropriate targets (anchor links for single-page, page links for multi-page site).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizePath

func NormalizePath(path string) string

NormalizePath normalizes a chapter file path for consistent map lookups.

func RewriteLinks(htmlContent string, currentFile string, targets map[string]Target, mode Mode) string

RewriteLinks rewrites Markdown .md links in HTML content to the appropriate targets based on the output mode.

Types

type Mode

type Mode string

Mode determines how links are rewritten.

const (
	// ModeSingle rewrites .md links to #anchor links within a single page.
	ModeSingle Mode = "single"
	// ModeSite rewrites .md links to separate page filenames.
	ModeSite Mode = "site"
)

type Target

type Target struct {
	ChapterID    string
	PageFilename string
}

Target describes the rewrite destination for a chapter.

Jump to

Keyboard shortcuts

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