graph

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMentionNotFound = errors.New("mention not found")

ErrMentionNotFound is returned by LinkifyMention when the target line is out of range or holds no unlinked, whole-word occurrence of the name to wrap.

View Source
var FenceDelimiterRe = regexp.MustCompile("^\\s*(?:[-*+]\\s+)?(```|~~~)")

FenceDelimiterRe matches a code-fence delimiter line: optional indentation, an optional list-bullet prefix (Logseq nests fences inside bullets), then a backtick or tilde fence marker. Exported so the editor tint (internal/views) classifies delimiter rows with the same grammar the index and renderer use.

Functions

func FilenameFromPageName

func FilenameFromPageName(name string) string

FilenameFromPageName is the inverse of PageNameFromFilename for the cases the App needs to construct a path for: journal page names (YYYY-MM-DD → YYYY_MM_DD.md) and namespace pages (proj/nested → proj___nested.md). Returns "" for any page name whose filename shape isn't covered here — callers should fall back to a more permissive resolution (or treat it as a programmer error) in that case. Used by App.Update's "." handler to derive the journal-file path when creating today's journal on demand.

func InlineCodeSpans added in v2.3.0

func InlineCodeSpans(line string) []search.Span

InlineCodeSpans returns the byte ranges of inline code spans on line — the odd segments of a backtick split, mirroring how parse.go (appendWikiLinks) and render.replaceWikiLinksOutsideInlineCode treat backticks: split the line on "`", even-indexed segments are literal text, odd-indexed segments are inline code. Each returned span includes its leading backtick (and trailing backtick, when the code run is closed). An unpaired trailing backtick still opens a code span that runs to the end of the line — strings.Split leaves that final segment at an odd index too, so parse/render already treat it as code, and this must match.

Exported because internal/render also needs it (hideMarkdownLinkURLsOutsideInlineCode): render and parse must agree byte-for-byte on what counts as inline code.

func IsJournalPageName

func IsJournalPageName(name string) bool

IsJournalPageName reports whether name is a journal page name (YYYY-MM-DD). This is the form PageNameFromFilename produces; it answers "is this page a journal?" without requiring the file to exist on disk.

func LinkifyMention

func LinkifyMention(body string, line int, target string) (string, search.Span, error)

LinkifyMention wraps the first unlinked, whole-word, case-insensitive occurrence of target on the 1-based line in body as [[<matched>]]. The matched bytes are preserved verbatim (Resolve is fold-keyed, so casing need not be normalised). The splice is by absolute byte offset, so line endings (incl. CRLF) and any trailing newline are preserved untouched. span is the matched range in the original body. It returns ErrMentionNotFound when no such occurrence exists — which also guards against double-wrapping an already [[linked]] mention and against a line that changed since detection.

func PageNameFromFilename

func PageNameFromFilename(name string) string

PageNameFromFilename returns the logical page name for a Logseq filename. Journals (YYYY_MM_DD.md) become YYYY-MM-DD; namespace separator "___" becomes "/".

Types

type FenceState added in v2.3.0

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

FenceState tracks fenced-code state across a top-to-bottom line walk. The zero value means "outside any fence". A fence opened with backticks is closed only by backticks (tildes only by tildes), matching CommonMark: the other marker inside an open fence is content.

func (*FenceState) Step