textutil

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeEOL

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

NormalizeEOL applies the given line-ending normalization to data. EOLNone returns data unchanged. Standalone carriage returns are preserved.

func PatchMarkdownFile

func PatchMarkdownFile(path string, out []byte, marker string, eol EOLMode) error

PatchMarkdownFile replaces the lines strictly between <!-- marker begin --> and <!-- marker end --> (exclusive of the marker lines) with a fenced ```text block containing out after trimming surrounding whitespace and normalizing CRLF sequences to LF for insertion. It applies EOL normalization to the patched Markdown written back to path: EOLNone matches the target file's perceived style (if consistent), defaulting to LF for mixed-EOL files; EOLLF and EOLCRLF normalize the entire file to LF or CRLF.

Types

type EOLMode

type EOLMode int

EOLMode represents a line-ending normalization mode.

const (
	EOLNone EOLMode = iota
	EOLLF
	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).

Jump to

Keyboard shortcuts

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