mdpatch

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mdpatch replaces HTML-comment marker blocks in Markdown files and normalizes line endings for documentation snapshot workflows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPatchedContent

func BuildPatchedContent(path string, data []byte, marker string, opts PatchOptions) ([]byte, error)

BuildPatchedContent returns the file bytes after replacing the marker block without writing to disk.

func NormalizeEOL

func NormalizeEOL(data []byte, mode EOLMode) []byte

NormalizeEOL applies the given line-ending normalization to data. EOLNone returns data unchanged.

func ParseFence

func ParseFence(s string) (string, error)

ParseFence parses -fence values: text, none, or a language tag.

func PatchMarkdownFile

func PatchMarkdownFile(path string, out []byte, marker string, opts PatchOptions) error

PatchMarkdownFile replaces the lines strictly between <!-- marker begin --> and <!-- marker end --> with fenced or raw content per opts.Fence.

func ValidateMarker

func ValidateMarker(marker string) error

ValidateMarker checks that marker is safe to embed in HTML comment markers.

Types

type EOLMode

type EOLMode int

EOLMode represents a line-ending normalization mode.

const (
	// EOLNone leaves line endings unchanged except where patch logic applies its own rules.
	EOLNone EOLMode = iota
	// EOLLF normalizes all line endings to LF.
	EOLLF
	// EOLCRLF normalizes all line endings to CRLF.
	EOLCRLF
)

func ParseEOLMode

func ParseEOLMode(s string) (EOLMode, error)

ParseEOLMode parses a string into an EOLMode. Valid values are "none", "lf", and "crlf" (case-sensitive).

type PatchOptions

type PatchOptions struct {
	EOL   EOLMode
	Fence string // "text", "none", or a fenced-code language tag (e.g. "go")
}

PatchOptions configures marker-block replacement.

Jump to

Keyboard shortcuts

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