Categorygithub.com/andreoliwa/logseq-go
modulepackage
0.0.0-20250222100956-e28f65d3c641
Repository: https://github.com/andreoliwa/logseq-go.git
Documentation: pkg.go.dev

# README

logseq-go

logseq-go is a Go library to work with a Logseq graph, with support for reading and modifying journals and pages.

⚠️ Note: This library is still in early development, it may destroy your data when pages are modified. Please open issues if you find any bugs.

codecov

Features

  • Read and write journals and pages
  • Rich content model
    • Blocks
    • Formatting via headings, paragraphs, lists, code blocks, etc.
    • Page links via [[Example]]
    • Tags via #Example and #[[Example with space]]
    • Macros via {{macro param1 param2}}
    • Block references via ((block-id))

Usage

Open a graph to access its content:

graph, err := logseq.Open("path/to/graph")

Content can be opened read only:

journalPage, err := graph.Journal(time.Now())
page, err := graph.OpenPage("Example")

for _, block := range page.Blocks() {
  // ...
}

Content can also be opened for writing, by creating a transaction:

tx := graph.NewTransaction()

today, err := tx.OpenJournalPage(time.Now())

today.AddBlock(content.NewBlock(
  content.NewText("Hello!")
))

// Save all the changes made
err = tx.Save()

Limitations

This library is limited to working with Markdown files. As the library provides an AST for the content there might be some issues with formatting that comes out wrong after having been read and saved again.

If this happens to you, please do open an issue with an example of content that is causing the issue.

License

This project is licensed under the MIT license, see LICENSE.

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
FromHit sets the offset to start returning results from.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ParseBlock parses markdown into a block.
ParseNodes parses markdown into a list of nodes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WithBlockTime sets the time format to use for timestamps on blocks added to the journal.
WithBlockTime12Hour sets the time format to use for timestamps on blocks added to the journal to 12 hour format.
WithBlockTime24Hour sets the time format to use for timestamps on blocks added to the journal to 24 hour format.
WithBlockTimeFormatter sets the function to use for formatting the timestamp on blocks added to the journal.
WithIndex enables indexing of the graph in the given directory.
WithInMemoryIndex enables indexing of the graph in memory.
WithListener sets a listener that will be invoked for events that occur while the graph is being opened.
WithMaxHits sets the maximum number of hits to return.
WithQuery sets the query to use for the search.

# Constants

No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

Graph represents a Logseq graph.
PageDeleted is a change that indicates a page was deleted.
PageIndexed is an event that occurs when a page is indexed.
PageUpdated is a change that indicates a page was updated or created.
No description provided by the author
Watcher watches for changes in the graph.

# Interfaces

BlockResult represents a block in a page.
No description provided by the author
OpenEvent is an event that occurs while the graph is being opened.
No description provided by the author
No description provided by the author
SearchResults is a result set from a search.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
SearchOption is an option for doing a search.