Documentation
¶
Index ¶
- Variables
- func FilenameFromPageName(name string) string
- func IsJournalFilename(name string) bool
- func IsJournalPageName(name string) bool
- func LinkifyMention(body string, line int, target string) (string, search.Span, error)
- func PageNameFromFilename(name string) string
- type Index
- type LinkHit
- type PageMeta
- type Ref
- type TodoBullet
- type TodoHit
- type UnlinkedRef
Constants ¶
This section is empty.
Variables ¶
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.
Functions ¶
func FilenameFromPageName ¶
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 IsJournalFilename ¶
IsJournalFilename reports whether the filename matches Logseq's journal pattern.
func IsJournalPageName ¶
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 ¶
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 ¶
PageNameFromFilename returns the logical page name for a Logseq filename. Journals (YYYY_MM_DD.md) become YYYY-MM-DD; namespace separator "___" becomes "/".
Types ¶
type Index ¶
type Index struct {
GraphPath string
Pages []PageMeta
ByName map[string]*PageMeta // case-preserving (filename-derived)
ByNameFold map[string]*PageMeta // case-folded (lowercase key) — for [[ALPHA]] → Alpha
Backlinks map[string][]Ref
Todos []TodoBullet
Journals []string // journal page names, sorted ascending
}
Index is the read-only in-memory view of a Logseq graph.
func BuildIndex ¶
BuildIndex walks <graphPath>/pages and <graphPath>/journals once and returns the populated Index. Unreadable files are logged to stderr and skipped.
type LinkHit ¶
LinkHit is one wiki-link occurrence in a page body.
func ExtractWikiLinks ¶
ExtractWikiLinks returns every [[link]] in body, skipping fenced code blocks. Targets like [[A|alias]] are recorded as "A". An unterminated fence in body causes following lines to be skipped — that matches how a markdown renderer would treat the rest of the page as code.
type PageMeta ¶
type PageMeta struct {
Name string // logical page name (e.g., "proj/nested" or "2026-05-24")
Path string // absolute filesystem path
IsJournal bool //
ModTime time.Time // file modification time; zero if stat failed
}
PageMeta is the indexed metadata for one .md file in the graph.
type Ref ¶
type Ref struct {
FromPage string
LineNumber int // 1-based
Context string // the source line, trimmed
}
Ref points from one page's body to another page name.
type TodoBullet ¶
type TodoBullet struct {
Page string
LineNumber int // 1-based
Marker string // TODO | LATER | DOING | WAITING
Priority string // "" | "A" | "B" | "C"
Text string // remainder after marker (and priority), trimmed
Ordinal int // 0-based index among open todos on the same page (document order)
}
TodoBullet is one open task bullet (TODO/LATER/DOING/WAITING).
type TodoHit ¶
type TodoHit struct {
Marker string // TODO | LATER | DOING | WAITING
Priority string // "" | "A" | "B" | "C"
Text string
Line int // 1-based
}
TodoHit is one open task bullet occurrence in a page body.
func ExtractTodos ¶
ExtractTodos returns open TODO/LATER/DOING/WAITING bullets in body. DONE and CANCELED are intentionally ignored (we only surface open tasks). An unterminated fence in body causes following lines to be skipped — that matches how a markdown renderer would treat the rest of the page as code.
type UnlinkedRef ¶
type UnlinkedRef struct {
FilePath string
PageName string
Line int
Context string
Match search.Span
}
UnlinkedRef is a bare-text mention of a page elsewhere in the graph that is not already a [[link]]. PageName is the referencing page (for the row label and navigation); Match locates the mention within Context.
func FilterUnlinked ¶
func FilterUnlinked(hits []search.Hit, target, targetPath string, read func(path string) (string, error)) []UnlinkedRef
FilterUnlinked turns raw ripgrep hits for `target` into unlinked references, dropping any hit that is in the target's own file, inside a fenced code block, or already inside a [[…]] link. read returns a file's body; a read error drops every hit from that file (we can't verify its fence state).