editnotetext

package
v1.25.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoValue = errors.New("give one of title, old or section")
	ErrNoMatch = errors.New("text not found in the note")
	ErrMany    = errors.New("text found more than once in the note")
)

Functions

func Process

func Process(ctx context.Context, db bun.IDB, input Input) *run

Process changes a part of a note through patchnote, the path of a full edit: a locked note refuses, the text replaced goes to the history as an edit's would, the #tags and the title follow the new text, the links the new title.

func Retitle

func Retitle(content, title string) string

Retitle gives content with title in its first heading, else a heading added on top, as the app renames a note. TODO: the marks and #tags of that heading are replaced too, like the app's rename; keep them if renamed headings lose tags.

Types

type Input

type Input struct {
	ID    string `json:"-"`
	Title string `json:"title,omitempty" binding:"optional"` // the new title: the first heading takes it, or one is added on top
	Old   string `json:"old,omitempty" binding:"optional"`   // an exact text, with its case, to find once (or every time with all)
	New   string `json:"new,omitempty" binding:"optional"`   // what replaces old or the body of section, empty to delete it
	All   bool   `json:"all,omitempty" binding:"optional"`   // replace every occurrence of old instead of refusing more than one
	// Section is the words of a heading: what follows it, down to the next heading of its level or higher, becomes New.
	Section string `json:"section,omitempty" binding:"optional"`
}

Input is one change of a note's text: Title renames it, Old is replaced by New, or Section has its body replaced by New.

type Result

type Result struct {
	Note     readitem.Result `json:"note"`
	Replaced int             `json:"replaced"`
}

Result is the note as saved, and how many times old or section was replaced (1 for a rename).

Jump to

Keyboard shortcuts

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