Help us shape the future of Go! Take the 2026 Go Developer Survey

edit

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package edit creates and applies source-preserving changes to AsciiDoc text. It does not perform filesystem I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(source []byte, edits []TextEdit) ([]byte, error)

Apply validates and applies edits to source. Edits may be supplied in any order, but they must not overlap or share an insertion point. The returned bytes do not alias source or any edit replacement. Every AST and analysis derived from source becomes stale after an edit is applied.

Types

type Editor

type Editor struct {
	// contains filtered or unexported fields
}

Editor applies source-preserving semantic edits to an AsciiDoc document. Every successful operation reparses the updated source before committing it, so subsequent operations always use current syntax and source positions.

func New

func New(source []byte) (*Editor, error)

New creates an editor for a valid AsciiDoc source.

func (*Editor) Bytes

func (editor *Editor) Bytes() []byte

Bytes returns an independent copy of the current edited source.

func (*Editor) SetHeaderAttribute

func (editor *Editor) SetHeaderAttribute(name, value string) error

SetHeaderAttribute sets a document-header attribute. An existing effective or unset declaration is replaced in place; otherwise it is appended to the current document header.

type TextEdit

type TextEdit struct {
	Source      ast.Span
	Replacement []byte
}

TextEdit replaces the half-open Source range with Replacement. An empty range inserts text and an empty replacement deletes the range.

Jump to

Keyboard shortcuts

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