Skip to content

andreoliwa/logseq-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Read, manipulate and save Logseq notes using Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Makefile 0.1%