content

package
v0.0.0-...-504b4e1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(node Node) string

Types

type AdvancedCommand

type AdvancedCommand struct {

	// Type is the type of the advanced command.
	Type string

	// Value is the value of the advanced command. Specific to the type of
	// command.
	Value string
	// contains filtered or unexported fields
}

AdvancedCommand represents an unknown command that is a BEGIN..END section within a block.

See https://docs.logseq.com/#/page/advanced%20commands

func NewAdvancedCommand

func NewAdvancedCommand(variant string, value string) *AdvancedCommand

func (*AdvancedCommand) NextSibling

func (n *AdvancedCommand) NextSibling() Node

func (*AdvancedCommand) Parent

func (n *AdvancedCommand) Parent() HasChildren

func (*AdvancedCommand) PreviousSibling

func (n *AdvancedCommand) PreviousSibling() Node

func (*AdvancedCommand) RemoveSelf

func (n *AdvancedCommand) RemoveSelf()

func (*AdvancedCommand) ReplaceWith

func (n *AdvancedCommand) ReplaceWith(node Node)

func (*AdvancedCommand) WithType

func (h *AdvancedCommand) WithType(variant string) *AdvancedCommand

WithType sets the type of the advanced command.

func (*AdvancedCommand) WithValue

func (h *AdvancedCommand) WithValue(value string) *AdvancedCommand

WithValue sets the value of the advanced command.

type AutoLink struct {

	// URL is where this link points to.
	URL string
	// contains filtered or unexported fields
}
func NewAutoLink(url string) *AutoLink

func (*AutoLink) GetURL

func (l *AutoLink) GetURL() string

GetURL returns the URL of this link.

func (*AutoLink) NextSibling

func (n *AutoLink) NextSibling() Node

func (*AutoLink) Parent

func (n *AutoLink) Parent() HasChildren

func (*AutoLink) PreviousSibling

func (n *AutoLink) PreviousSibling() Node

func (*AutoLink) RemoveSelf

func (n *AutoLink) RemoveSelf()

func (*AutoLink) ReplaceWith

func (n *AutoLink) ReplaceWith(node Node)
func (l *AutoLink) ReplaceWithLink(text ...Node) *Link

ReplaceWithLink replaces this node with a new `Link` node containing the given text.

func (*AutoLink) WithURL

func (l *AutoLink) WithURL(target string) *AutoLink

WithURL sets the URL of this link.

type Block

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

Block is a piece of information in an outline, either belonging to a page or another block.

func NewBlock

func NewBlock(children ...Node) *Block

func (*Block) AddChild

func (c *Block) AddChild(node Node)

func (*Block) AddChildren

func (c *Block) AddChildren(nodes ...Node)

func (*Block) Blocks

func (b *Block) Blocks() BlockList

Blocks gets all of the children that are blocks.

func (*Block) Children

func (c *Block) Children() NodeList

func (*Block) Content

func (b *Block) Content() NodeList

Content gets the content part of this block, which is all children that are not blocks.

func (*Block) FirstChild

func (c *Block) FirstChild() Node

func (*Block) GomegaString

func (n *Block) GomegaString() string

func (*Block) ID

func (b *Block) ID() string

ID gets the identifier of the block. If the block does not have an ID this will return an empty string.

func (*Block) InsertChildAfter

func (c *Block) InsertChildAfter(node Node, after Node) bool

func (*Block) InsertChildBefore

func (c *Block) InsertChildBefore(node Node, before Node) bool

func (*Block) LastChild

func (c *Block) LastChild() Node

func (*Block) PrependChild

func (c *Block) PrependChild(node Node)

func (*Block) PrependChildren

func (c *Block) PrependChildren(nodes ...Node)

func (*Block) Properties

func (b *Block) Properties() *Properties

Properties gets the properties node for this block. This follows the Logseq implementation where properties at the start of the block are the ones that are indexed.

If such properties do not exist, they are created to allow for easy manipulation of properties.

func (*Block) RemoveChild

func (c *Block) RemoveChild(node Node) bool

func (*Block) RemoveChildren

func (c *Block) RemoveChildren(nodes ...Node)

func (*Block) ReplaceChild

func (c *Block) ReplaceChild(oldNode Node, newNode Node) bool

func (*Block) SetChildren

func (c *Block) SetChildren(nodes ...Node)

func (*Block) WithID

func (b *Block) WithID() *Block

WithID ensures that the block has an ID. If the block already has an ID this will do nothing.

type BlockEmbed

type BlockEmbed struct {
	ID string
	// contains filtered or unexported fields
}

func NewBlockEmbed

func NewBlockEmbed(id string) *BlockEmbed

func (*BlockEmbed) NextSibling

func (n *BlockEmbed) NextSibling() Node

func (*BlockEmbed) Parent

func (n *BlockEmbed) Parent() HasChildren

func (*BlockEmbed) PreviousSibling

func (n *BlockEmbed) PreviousSibling() Node

func (*BlockEmbed) RemoveSelf

func (n *BlockEmbed) RemoveSelf()

func (*BlockEmbed) ReplaceWith

func (n *BlockEmbed) ReplaceWith(node Node)

type BlockList

type BlockList []*Block

func (BlockList) Filter

func (l BlockList) Filter(predicate func(block *Block) bool) BlockList

func (BlockList) FilterDeep

func (l BlockList) FilterDeep(predicate func(block *Block) bool) BlockList

func (BlockList) Find

func (l BlockList) Find(predicate func(block *Block) bool) *Block

func (BlockList) FindDeep

func (l BlockList) FindDeep(predicate func(block *Block) bool) *Block

type BlockNode

type BlockNode interface {
	Node
	// contains filtered or unexported methods
}

type BlockRef

type BlockRef struct {

	// ID is the id of the block to reference.
	ID string
	// contains filtered or unexported fields
}

func NewBlockRef

func NewBlockRef(id string) *BlockRef

func (*BlockRef) NextSibling

func (n *BlockRef) NextSibling() Node

func (*BlockRef) Parent

func (n *BlockRef) Parent() HasChildren

func (*BlockRef) PreviousSibling

func (n *BlockRef) PreviousSibling() Node

func (*BlockRef) RemoveSelf

func (n *BlockRef) RemoveSelf()

func (*BlockRef) ReplaceWith

func (n *BlockRef) ReplaceWith(node Node)

func (*BlockRef) WithID

func (l *BlockRef) WithID(id string) *BlockRef

type Blockquote

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

func NewBlockquote

func NewBlockquote(children ...Node) *Blockquote

func (*Blockquote) AddChild

func (c *Blockquote) AddChild(node Node)

func (*Blockquote) AddChildren

func (c *Blockquote) AddChildren(nodes ...Node)

func (*Blockquote) Children

func (c *Blockquote) Children() NodeList

func (*Blockquote) FirstChild

func (c *Blockquote) FirstChild() Node

func (*Blockquote) InsertChildAfter

func (c *Blockquote) InsertChildAfter(node Node, after Node) bool

func (*Blockquote) InsertChildBefore

func (c *Blockquote) InsertChildBefore(node Node, before Node) bool

func (*Blockquote) LastChild

func (c *Blockquote) LastChild() Node

func (*Blockquote) PrependChild

func (c *Blockquote) PrependChild(node Node)

func (*Blockquote) PrependChildren

func (c *Blockquote) PrependChildren(nodes ...Node)

func (*Blockquote) PreviousLineType

func (p *Blockquote) PreviousLineType() PreviousLineType

func (*Blockquote) RemoveChild

func (c *Blockquote) RemoveChild(node Node) bool

func (*Blockquote) RemoveChildren

func (c *Blockquote) RemoveChildren(nodes ...Node)

func (*Blockquote) ReplaceChild

func (c *Blockquote) ReplaceChild(oldNode Node, newNode Node) bool

func (*Blockquote) SetChildren

func (c *Blockquote) SetChildren(nodes ...Node)

func (*Blockquote) SetPreviousLineType

func (p *Blockquote) SetPreviousLineType(previousLineType PreviousLineType)

func (*Blockquote) WithPreviousLineType

func (b *Blockquote) WithPreviousLineType(t PreviousLineType) *Blockquote

type Cloze

type Cloze struct {
	Answer string

	Cue string
	// contains filtered or unexported fields
}

func NewCloze

func NewCloze(answer string) *Cloze

func NewClozeWithCue

func NewClozeWithCue(answer string, cue string) *Cloze

func (*Cloze) NextSibling

func (n *Cloze) NextSibling() Node

func (*Cloze) Parent

func (n *Cloze) Parent() HasChildren

func (*Cloze) PreviousSibling

func (n *Cloze) PreviousSibling() Node

func (*Cloze) RemoveSelf

func (n *Cloze) RemoveSelf()

func (*Cloze) ReplaceWith

func (n *Cloze) ReplaceWith(node Node)

type CodeBlock

type CodeBlock struct {

	// Language is the programming language of this code block.
	Language string

	// Code is the raw value of the code block.
	Code string
	// contains filtered or unexported fields
}

func NewCodeBlock

func NewCodeBlock(code string) *CodeBlock

func (*CodeBlock) NextSibling

func (n *CodeBlock) NextSibling() Node

func (*CodeBlock) Parent

func (n *CodeBlock) Parent() HasChildren

func (*CodeBlock) PreviousLineType

func (p *CodeBlock) PreviousLineType() PreviousLineType

func (*CodeBlock) PreviousSibling

func (n *CodeBlock) PreviousSibling() Node

func (*CodeBlock) RemoveSelf

func (n *CodeBlock) RemoveSelf()

func (*CodeBlock) ReplaceWith

func (n *CodeBlock) ReplaceWith(node Node)

func (*CodeBlock) SetPreviousLineType

func (p *CodeBlock) SetPreviousLineType(previousLineType PreviousLineType)

func (*CodeBlock) WithCode

func (c *CodeBlock) WithCode(code string) *CodeBlock

WithCode sets the code of the code block.

func (*CodeBlock) WithLanguage

func (c *CodeBlock) WithLanguage(language string) *CodeBlock

WithLanguage sets the language of the code block.

func (*CodeBlock) WithPreviousLineType

func (c *CodeBlock) WithPreviousLineType(previousLineType PreviousLineType) *CodeBlock

type CodeSpan

type CodeSpan struct {

	// Value is the text of this node.
	Value string
	// contains filtered or unexported fields
}

func NewCodeSpan

func NewCodeSpan(text string) *CodeSpan

func (*CodeSpan) NextSibling

func (n *CodeSpan) NextSibling() Node

func (*CodeSpan) Parent

func (n *CodeSpan) Parent() HasChildren

func (*CodeSpan) PreviousSibling

func (n *CodeSpan) PreviousSibling() Node

func (*CodeSpan) RemoveSelf

func (n *CodeSpan) RemoveSelf()

func (*CodeSpan) ReplaceWith

func (n *CodeSpan) ReplaceWith(node Node)

type Emphasis

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

func NewEmphasis

func NewEmphasis(children ...Node) *Emphasis

func (*Emphasis) AddChild

func (c *Emphasis) AddChild(node Node)

func (*Emphasis) AddChildren

func (c *Emphasis) AddChildren(nodes ...Node)

func (*Emphasis) Children

func (c *Emphasis) Children() NodeList

func (*Emphasis) FirstChild

func (c *Emphasis) FirstChild() Node

func (*Emphasis) InsertChildAfter

func (c *Emphasis) InsertChildAfter(node Node, after Node) bool

func (*Emphasis) InsertChildBefore

func (c *Emphasis) InsertChildBefore(node Node, before Node) bool

func (*Emphasis) LastChild

func (c *Emphasis) LastChild() Node

func (*Emphasis) PrependChild

func (c *Emphasis) PrependChild(node Node)

func (*Emphasis) PrependChildren

func (c *Emphasis) PrependChildren(nodes ...Node)

func (*Emphasis) RemoveChild

func (c *Emphasis) RemoveChild(node Node) bool

func (*Emphasis) RemoveChildren

func (c *Emphasis) RemoveChildren(nodes ...Node)

func (*Emphasis) ReplaceChild

func (c *Emphasis) ReplaceChild(oldNode Node, newNode Node) bool

func (*Emphasis) SetChildren

func (c *Emphasis) SetChildren(nodes ...Node)

type HasChildren

type HasChildren interface {
	Node

	// Children gets all the direct children of this node.
	Children() NodeList

	// FirstChild gets the first child of this node. Can be nil if there are
	// no children. Can be the same as LastChild if there is only one child.
	FirstChild() Node

	// LastChild gets the last child of this node. Can be nil if there are no
	// children. Can be the same as FirstChild if there is only one child.
	LastChild() Node

	// SetChildren sets the children of this node, this will remove any
	// existing children.
	SetChildren(node ...Node)

	// AddChild adds a child to this node. The child will be added to the end
	// of the list of children. Nodes can only have one parent, if the node
	// already has a parent it will be removed from that parent.
	AddChild(node Node)

	// AddChildren adds multiple children to this node. The children will be
	// added to the end of the list of children. Nodes can only have one
	// parent, if any of the nodes already have a parent they will be removed
	AddChildren(nodes ...Node)

	// PrependChild adds a child to the start of this node. Nodes can only
	// have one parent, if the node already has a parent it will be removed
	// from that parent.
	PrependChild(node Node)

	// PrependChildren adds multiple children to the start of this node. Nodes
	// can only have one parent, if any of the nodes already have a parent
	// they will be removed from that parent.
	PrependChildren(nodes ...Node)

	// RemoveChild removes a child from this node. Returns true if the child
	// was removed, false if the child was not a child of this node.
	RemoveChild(node Node) bool

	// RemoveChildren removes multiple children from this node. Returns true
	// if all of the children were removed, false if any of the children were
	// not a child of this node.
	RemoveChildren(nodes ...Node)

	// ReplaceChild replaces a child of this node with another node. Returns
	// true if the child was replaced, false if the old node was not a child
	// of this node.
	ReplaceChild(oldNode Node, newNode Node) bool

	// InsertChildBefore inserts a node before another node. Returns true if
	// the node was inserted, false if the before node was not a child of
	// this node.
	InsertChildBefore(node Node, before Node) bool

	// InsertChildBefore inserts a node before another node. Returns true if
	// the node was inserted, false if the before node was not a child of
	// this node.
	InsertChildAfter(node Node, after Node) bool
}

type HasLinkURL

type HasLinkURL interface {
	Node

	// GetURL gets the target of this link.
	GetURL() string
}

HasLinkURL is used for nodes that are links, such as `Link` and `AutoLink`.

type Hashtag

type Hashtag struct {

	// Page is the target of the link.
	To string
	// contains filtered or unexported fields
}

func NewHashtag

func NewHashtag(target string) *Hashtag

func (*Hashtag) GetTo

func (l *Hashtag) GetTo() string

func (*Hashtag) NextSibling

func (n *Hashtag) NextSibling() Node

func (*Hashtag) Parent

func (n *Hashtag) Parent() HasChildren

func (*Hashtag) PreviousSibling

func (n *Hashtag) PreviousSibling() Node

func (*Hashtag) RemoveSelf

func (n *Hashtag) RemoveSelf()

func (*Hashtag) ReplaceWith

func (n *Hashtag) ReplaceWith(node Node)

func (*Hashtag) WithTo

func (l *Hashtag) WithTo(target string) *Hashtag

type Heading

type Heading struct {

	// Level is the level of this heading.
	Level int
	// contains filtered or unexported fields
}

func NewHeading

func NewHeading(level int, children ...Node) *Heading

func (*Heading) AddChild

func (c *Heading) AddChild(node Node)

func (*Heading) AddChildren

func (c *Heading) AddChildren(nodes ...Node)

func (*Heading) Children

func (c *Heading) Children() NodeList

func (*Heading) FirstChild

func (c *Heading) FirstChild() Node

func (*Heading) InsertChildAfter

func (c *Heading) InsertChildAfter(node Node, after Node) bool

func (*Heading) InsertChildBefore

func (c *Heading) InsertChildBefore(node Node, before Node) bool

func (*Heading) LastChild

func (c *Heading) LastChild() Node

func (*Heading) PrependChild

func (c *Heading) PrependChild(node Node)

func (*Heading) PrependChildren

func (c *Heading) PrependChildren(nodes ...Node)

func (*Heading) RemoveChild

func (c *Heading) RemoveChild(node Node) bool

func (*Heading) RemoveChildren

func (c *Heading) RemoveChildren(nodes ...Node)

func (*Heading) ReplaceChild

func (c *Heading) ReplaceChild(oldNode Node, newNode Node) bool

func (*Heading) SetChildren

func (c *Heading) SetChildren(nodes ...Node)

type Image

type Image struct {

	// URL is the URL of the image.
	URL string

	// Title is the title of the image.
	Title string
	// contains filtered or unexported fields
}

func NewImage

func NewImage(url string, nodes ...Node) *Image

func (*Image) AddChild

func (c *Image) AddChild(node Node)

func (*Image) AddChildren

func (c *Image) AddChildren(nodes ...Node)

func (*Image) Children

func (c *Image) Children() NodeList

func (*Image) FirstChild

func (c *Image) FirstChild() Node

func (*Image) InsertChildAfter

func (c *Image) InsertChildAfter(node Node, after Node) bool

func (*Image) InsertChildBefore

func (c *Image) InsertChildBefore(node Node, before Node) bool

func (*Image) LastChild

func (c *Image) LastChild() Node

func (*Image) PrependChild

func (c *Image) PrependChild(node Node)

func (*Image) PrependChildren

func (c *Image) PrependChildren(nodes ...Node)

func (*Image) RemoveChild

func (c *Image) RemoveChild(node Node) bool

func (*Image) RemoveChildren

func (c *Image) RemoveChildren(nodes ...Node)

func (*Image) ReplaceChild

func (c *Image) ReplaceChild(oldNode Node, newNode Node) bool

func (*Image) SetChildren

func (c *Image) SetChildren(nodes ...Node)

func (*Image) WithTitle

func (i *Image) WithTitle(title string) *Image

WithTitle sets the title of the image.

func (*Image) WithURL

func (i *Image) WithURL(src string) *Image

WithURL sets the source of the image.

type InlineNode

type InlineNode interface {
	Node
	// contains filtered or unexported methods
}
type Link struct {

	// URL is the target of the link.
	URL string
	// Title of this link as displayed on hover in a browser.
	Title string
	// contains filtered or unexported fields
}
func NewLink(url string, text ...Node) *Link

func (*Link) AddChild

func (c *Link) AddChild(node Node)

func (*Link) AddChildren

func (c *Link) AddChildren(nodes ...Node)

func (*Link) Children

func (c *Link) Children() NodeList

func (*Link) FirstChild

func (c *Link) FirstChild() Node

func (*Link) GetURL

func (l *Link) GetURL() string

GetURL returns the URL of this link.

func (*Link) InsertChildAfter

func (c *Link) InsertChildAfter(node Node, after Node) bool

func (*Link) InsertChildBefore

func (c *Link) InsertChildBefore(node Node, before Node) bool

func (*Link) LastChild

func (c *Link) LastChild() Node

func (*Link) PrependChild

func (c *Link) PrependChild(node Node)

func (*Link) PrependChildren

func (c *Link) PrependChildren(nodes ...Node)

func (*Link) RemoveChild

func (c *Link) RemoveChild(node Node) bool

func (*Link) RemoveChildren

func (c *Link) RemoveChildren(nodes ...Node)

func (*Link) ReplaceChild

func (c *Link) ReplaceChild(oldNode Node, newNode Node) bool

func (*Link) SetChildren

func (c *Link) SetChildren(nodes ...Node)

func (*Link) WithTitle

func (l *Link) WithTitle(title string) *Link

WithTitle sets the title of this link. The title is the text displayed on hover in a browser.

func (*Link) WithURL

func (l *Link) WithURL(url string) *Link

WithURL sets the URL of this link.

type List

type List struct {

	// Type is the type of the list.
	Type ListType

	// Marker is the marker of the list.
	Marker byte
	// contains filtered or unexported fields
}

func NewList

func NewList(typ ListType, items ...*ListItem) *List

func NewListFromMarker

func NewListFromMarker(marker byte, items ...*ListItem) *List

func NewOrderedList

func NewOrderedList(items ...*ListItem) *List

func NewUnorderedList

func NewUnorderedList(items ...*ListItem) *List

func (*List) AddChild

func (c *List) AddChild(node Node)

func (*List) AddChildren

func (c *List) AddChildren(nodes ...Node)

func (*List) Children

func (c *List) Children() NodeList

func (*List) FirstChild

func (c *List) FirstChild() Node

func (*List) InsertChildAfter

func (c *List) InsertChildAfter(node Node, after Node) bool

func (*List) InsertChildBefore

func (c *List) InsertChildBefore(node Node, before Node) bool

func (*List) LastChild

func (c *List) LastChild() Node

func (*List) PrependChild

func (c *List) PrependChild(node Node)

func (*List) PrependChildren

func (c *List) PrependChildren(nodes ...Node)

func (*List) PreviousLineType

func (p *List) PreviousLineType() PreviousLineType

func (*List) RemoveChild

func (c *List) RemoveChild(node Node) bool

func (*List) RemoveChildren

func (c *List) RemoveChildren(nodes ...Node)

func (*List) ReplaceChild

func (c *List) ReplaceChild(oldNode Node, newNode Node) bool

func (*List) SetChildren

func (c *List) SetChildren(nodes ...Node)

func (*List) SetPreviousLineType

func (p *List) SetPreviousLineType(previousLineType PreviousLineType)

func (*List) WithMarker

func (l *List) WithMarker(marker byte) *List

WithMarker sets the marker of the list.

func (*List) WithPreviousLineType

func (c *List) WithPreviousLineType(t PreviousLineType) *List

func (*List) WithType

func (l *List) WithType(typ ListType) *List

WithType sets the type of the list.

type ListItem

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

func NewListItem

func NewListItem(items ...Node) *ListItem

func (*ListItem) AddChild

func (c *ListItem) AddChild(node Node)

func (*ListItem) AddChildren

func (c *ListItem) AddChildren(nodes ...Node)

func (*ListItem) Children

func (c *ListItem) Children() NodeList

func (*ListItem) FirstChild

func (c *ListItem) FirstChild() Node

func (*ListItem) InsertChildAfter

func (c *ListItem) InsertChildAfter(node Node, after Node) bool

func (*ListItem) InsertChildBefore

func (c *ListItem) InsertChildBefore(node Node, before Node) bool

func (*ListItem) LastChild

func (c *ListItem) LastChild() Node

func (*ListItem) PrependChild

func (c *ListItem) PrependChild(node Node)

func (*ListItem) PrependChildren

func (c *ListItem) PrependChildren(nodes ...Node)

func (*ListItem) RemoveChild

func (c *ListItem) RemoveChild(node Node) bool

func (*ListItem) RemoveChildren

func (c *ListItem) RemoveChildren(nodes ...Node)

func (*ListItem) ReplaceChild

func (c *ListItem) ReplaceChild(oldNode Node, newNode Node) bool

func (*ListItem) SetChildren

func (c *ListItem) SetChildren(nodes ...Node)

type ListSection

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

func (*ListSection) AddChild

func (c *ListSection) AddChild(node Node)

func (*ListSection) AddChildren

func (c *ListSection) AddChildren(nodes ...Node)

func (*ListSection) Children

func (c *ListSection) Children() NodeList

func (*ListSection) FirstChild

func (c *ListSection) FirstChild() Node

func (*ListSection) InsertChildAfter

func (c *ListSection) InsertChildAfter(node Node, after Node) bool

func (*ListSection) InsertChildBefore

func (c *ListSection) InsertChildBefore(node Node, before Node) bool

func (*ListSection) LastChild

func (c *ListSection) LastChild() Node

func (*ListSection) PrependChild

func (c *ListSection) PrependChild(node Node)

func (*ListSection) PrependChildren

func (c *ListSection) PrependChildren(nodes ...Node)

func (*ListSection) RemoveChild

func (c *ListSection) RemoveChild(node Node) bool

func (*ListSection) RemoveChildren

func (c *ListSection) RemoveChildren(nodes ...Node)

func (*ListSection) ReplaceChild

func (c *ListSection) ReplaceChild(oldNode Node, newNode Node) bool

func (*ListSection) SetChildren

func (c *ListSection) SetChildren(nodes ...Node)

type ListType

type ListType int
const (
	ListTypeOrdered ListType = iota
	ListTypeUnordered
)

type Logbook

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

Logbook represents a logbook of a task. Logseq will manage these automatically when a task changes state. They are used both for tracking if a task has been completed, for use with repeating tasks and for time tracking if the user has enabled that feature.

These are commonly part of a `Block` with a task marker.

A logbook node can only contain children of type `LogbookEntry`.

func NewLogbook

func NewLogbook(entries ...LogbookEntry) *Logbook

func (*Logbook) AddChild

func (c *Logbook) AddChild(node Node)

func (*Logbook) AddChildren

func (c *Logbook) AddChildren(nodes ...Node)

func (*Logbook) Children

func (c *Logbook) Children() NodeList

func (*Logbook) FirstChild

func (c *Logbook) FirstChild() Node

func (*Logbook) InsertChildAfter

func (c *Logbook) InsertChildAfter(node Node, after Node) bool

func (*Logbook) InsertChildBefore

func (c *Logbook) InsertChildBefore(node Node, before Node) bool

func (*Logbook) LastChild

func (c *Logbook) LastChild() Node

func (*Logbook) PrependChild

func (c *Logbook) PrependChild(node Node)

func (*Logbook) PrependChildren

func (c *Logbook) PrependChildren(nodes ...Node)

func (*Logbook) PreviousLineType

func (p *Logbook) PreviousLineType() PreviousLineType

func (*Logbook) RemoveChild

func (c *Logbook) RemoveChild(node Node) bool

func (*Logbook) RemoveChildren

func (c *Logbook) RemoveChildren(nodes ...Node)

func (*Logbook) ReplaceChild

func (c *Logbook) ReplaceChild(oldNode Node, newNode Node) bool

func (*Logbook) SetChildren

func (c *Logbook) SetChildren(nodes ...Node)

func (*Logbook) SetPreviousLineType

func (p *Logbook) SetPreviousLineType(previousLineType PreviousLineType)

func (*Logbook) WithPreviousLineType

func (l *Logbook) WithPreviousLineType(t PreviousLineType) *Logbook

type LogbookEntry

type LogbookEntry interface {
	Node
	// contains filtered or unexported methods
}

LogbookEntry represents a single entry in a logbook.

type LogbookEntryRaw

type LogbookEntryRaw struct {
	Value string
	// contains filtered or unexported fields
}

LogbookEntryRaw represents a raw logbook entry, this is used for entries that are not supported by this library.

func NewLogbookEntryRaw

func NewLogbookEntryRaw(value string) *LogbookEntryRaw

func (*LogbookEntryRaw) NextSibling

func (n *LogbookEntryRaw) NextSibling() Node

func (*LogbookEntryRaw) Parent

func (n *LogbookEntryRaw) Parent() HasChildren

func (*LogbookEntryRaw) PreviousSibling

func (n *LogbookEntryRaw) PreviousSibling() Node

func (*LogbookEntryRaw) RemoveSelf

func (n *LogbookEntryRaw) RemoveSelf()

func (*LogbookEntryRaw) ReplaceWith

func (n *LogbookEntryRaw) ReplaceWith(node Node)

func (*LogbookEntryRaw) WithValue

func (t *LogbookEntryRaw) WithValue(value string) *LogbookEntryRaw

WithValue sets the value of the logbook entry.

type Macro

type Macro struct {

	// Name gets the name of this macro.
	Name string

	// Arguments gets the arguments of this macro.
	Arguments []string
	// contains filtered or unexported fields
}

Macro represents a macro, which in the source is on the form `{{macro-name arg1, arg2, ..., argN}}`.

Macros share their syntax with some built-ins, such as `{{query}}` and `{{embed}}`, but are otherwise user-defined. If a supported built-in is found it will be parsed as its own node type, such as `Query`, `PageEmbed` or `BlockEmbed`.

In Logseq arguments are optional, but must be comma separated. Arguments can be quoted, in which case they can contain commas. In this library arguments will be normalized, if a comma is in the argument it will be quoted in the output.

func NewMacro

func NewMacro(name string, args ...string) *Macro

NewMacro creates a new macro with the given name and arguments.

func (*Macro) NextSibling

func (n *Macro) NextSibling() Node

func (*Macro) Parent

func (n *Macro) Parent() HasChildren

func (*Macro) PreviousSibling

func (n *Macro) PreviousSibling() Node

func (*Macro) RemoveSelf

func (n *Macro) RemoveSelf()

func (*Macro) ReplaceWith

func (n *Macro) ReplaceWith(node Node)

func (*Macro) WithArguments

func (m *Macro) WithArguments(args ...string) *Macro

WithArguments sets the arguments of the macro.

func (*Macro) WithName

func (m *Macro) WithName(name string) *Macro

WithName sets the name of the macro.

type Node

type Node interface {
	// Parent gets the parent of this node.
	Parent() HasChildren

	// NextSibling gets the next sibling of this node.
	NextSibling() Node

	// PreviousSibling gets the previous sibling of this node.
	PreviousSibling() Node

	// RemoveSelf this node from its parent.
	RemoveSelf()

	// ReplaceWith replaces this node with the given node.
	ReplaceWith(node Node)
	// contains filtered or unexported methods
}

Node is the basic building block of a document. Nodes represent a single element in the document, such as a paragraph, heading, list or text.

func AddAutomaticParagraphs

func AddAutomaticParagraphs(nodes []Node) []Node

AddAutomaticParagraphs wraps all nodes that are not blocks in paragraphs. This enables the user to create nodes without having to think too much about the structure of the document.

type NodeList

type NodeList []Node

func (NodeList) Filter

func (n NodeList) Filter(predicate NodePredicate) NodeList

func (NodeList) FilterDeep

func (n NodeList) FilterDeep(predicate NodePredicate) NodeList

func (NodeList) Find

func (n NodeList) Find(predicate NodePredicate) Node

func (NodeList) FindDeep

func (n NodeList) FindDeep(predicate NodePredicate) Node

func (NodeList) Map

func (n NodeList) Map(mapper func(node Node) Node) NodeList

type NodePredicate

type NodePredicate func(node Node) bool

func IsOfType

func IsOfType[T Node]() NodePredicate

func IsPageReference

func IsPageReference() NodePredicate

type PageEmbed

type PageEmbed struct {
	To string
	// contains filtered or unexported fields
}

func NewPageEmbed

func NewPageEmbed(to string) *PageEmbed

func (*PageEmbed) NextSibling

func (n *PageEmbed) NextSibling() Node

func (*PageEmbed) Parent

func (n *PageEmbed) Parent() HasChildren

func (*PageEmbed) PreviousSibling

func (n *PageEmbed) PreviousSibling() Node

func (*PageEmbed) RemoveSelf

func (n *PageEmbed) RemoveSelf()

func (*PageEmbed) ReplaceWith

func (n *PageEmbed) ReplaceWith(node Node)
type PageLink struct {

	// To is the target of the link.
	To string
	// contains filtered or unexported fields
}
func NewPageLink(target string) *PageLink

func (*PageLink) GetTo

func (l *PageLink) GetTo() string

func (*PageLink) NextSibling

func (n *PageLink) NextSibling() Node

func (*PageLink) Parent

func (n *PageLink) Parent() HasChildren

func (*PageLink) PreviousSibling

func (n *PageLink) PreviousSibling() Node

func (*PageLink) RemoveSelf

func (n *PageLink) RemoveSelf()

func (*PageLink) ReplaceWith

func (n *PageLink) ReplaceWith(node Node)

func (*PageLink) WithTo

func (l *PageLink) WithTo(target string) *PageLink

type PageRef

type PageRef interface {
	Node

	GetTo() string
	// contains filtered or unexported methods
}

PageRef is a reference to a page, such as a `PageLink` or `Hashtag`.

type Paragraph

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

func NewParagraph

func NewParagraph(children ...Node) *Paragraph

func (*Paragraph) AddChild

func (c *Paragraph) AddChild(node Node)

func (*Paragraph) AddChildren

func (c *Paragraph) AddChildren(nodes ...Node)

func (*Paragraph) Children

func (c *Paragraph) Children() NodeList

func (*Paragraph) FirstChild

func (c *Paragraph) FirstChild() Node

func (*Paragraph) InsertChildAfter

func (c *Paragraph) InsertChildAfter(node Node, after Node) bool

func (*Paragraph) InsertChildBefore

func (c *Paragraph) InsertChildBefore(node Node, before Node) bool

func (*Paragraph) LastChild

func (c *Paragraph) LastChild() Node

func (*Paragraph) PrependChild

func (c *Paragraph) PrependChild(node Node)

func (*Paragraph) PrependChildren

func (c *Paragraph) PrependChildren(nodes ...Node)

func (*Paragraph) PreviousLineType

func (p *Paragraph) PreviousLineType() PreviousLineType

func (*Paragraph) RemoveChild

func (c *Paragraph) RemoveChild(node Node) bool

func (*Paragraph) RemoveChildren

func (c *Paragraph) RemoveChildren(nodes ...Node)

func (*Paragraph) ReplaceChild

func (c *Paragraph) ReplaceChild(oldNode Node, newNode Node) bool

func (*Paragraph) SetChildren

func (c *Paragraph) SetChildren(nodes ...Node)

func (*Paragraph) SetPreviousLineType

func (p *Paragraph) SetPreviousLineType(previousLineType PreviousLineType)

func (*Paragraph) WithPreviousLineType

func (p *Paragraph) WithPreviousLineType(t PreviousLineType) *Paragraph

type PreviousLineAware

type PreviousLineAware interface {
	// PreviousLineType gets the type of the previous line.
	PreviousLineType() PreviousLineType

	// SetPreviousLineType sets the type of the previous line.
	SetPreviousLineType(PreviousLineType)
}

PreviousLineAware is an interface that can be implemented by block nodes to get information about the previous line.

This information is used when generating Markdown output to keep the Markdown close to the original input.

Most implementations of this interface are encouraged to also provide a helper method `WithPreviousLineType` that sets the previous line type and returns the node.

type PreviousLineType

type PreviousLineType int

PreviousLineType contains information about the previous line, commonly saved while parsing.

const (
	// PreviousLineTypeAutomatic is the default value, which lets block nodes
	// pick what kind of previous line type they want.
	PreviousLineTypeAutomatic PreviousLineType = iota
	// PreviousLineTypeBlank is used when the previous line was blank.
	PreviousLineTypeBlank
	// PreviousLineTypeNonBlank is used when the previous line was not blank.
	// Such as when something interrupts as paragraph.
	PreviousLineTypeNonBlank
)

type Properties

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

Properties is a collection of Property nodes.

func NewProperties

func NewProperties(children ...*Property) *Properties

NewProperties creates a new Properties node with the given Property children.

func (*Properties) AddChild

func (c *Properties) AddChild(node Node)

func (*Properties) AddChildren

func (c *Properties) AddChildren(nodes ...Node)

func (*Properties) Children

func (c *Properties) Children() NodeList

func (*Properties) FirstChild

func (c *Properties) FirstChild() Node

func (*Properties) Get

func (p *Properties) Get(key string) NodeList

Get gets the value of a Property by name. Will return an empty slice if no Property with the given name exists.

func (*Properties) GetAsNode

func (p *Properties) GetAsNode(key string) *Property

GetAsNode gets a Property node by name. Will return nil if no Property with the given name exists.

func (*Properties) InsertChildAfter

func (c *Properties) InsertChildAfter(node Node, after Node) bool

func (*Properties) InsertChildBefore

func (c *Properties) InsertChildBefore(node Node, before Node) bool

func (*Properties) LastChild

func (c *Properties) LastChild() Node

func (*Properties) PrependChild

func (c *Properties) PrependChild(node Node)

func (*Properties) PrependChildren

func (c *Properties) PrependChildren(nodes ...Node)

func (*Properties) PreviousLineType

func (p *Properties) PreviousLineType() PreviousLineType

func (*Properties) Remove

func (p *Properties) Remove(key string)

Remove a Property node by name. If a Property with the given name does not exist this does nothing.

func (*Properties) RemoveChild

func (c *Properties) RemoveChild(node Node) bool

func (*Properties) RemoveChildren

func (c *Properties) RemoveChildren(nodes ...Node)

func (*Properties) ReplaceChild

func (c *Properties) ReplaceChild(oldNode Node, newNode Node) bool

func (*Properties) Set

func (p *Properties) Set(key string, nodes ...Node)

Set a Property node by name. If a Property with the given name already exists, it will be replaced.

func (*Properties) SetChildren

func (c *Properties) SetChildren(nodes ...Node)

func (*Properties) SetPreviousLineType

func (p *Properties) SetPreviousLineType(previousLineType PreviousLineType)

func (*Properties) WithPreviousLineType

func (p *Properties) WithPreviousLineType(t PreviousLineType) *Properties

type Property

type Property struct {

	// Name is the name of the property.
	Name string
	// contains filtered or unexported fields
}

Property is a node that represents a property, which is a key that can have multiple values.

func NewProperty

func NewProperty(name string, children ...Node) *Property

NewProperty creates a new Property node with the given name and values.

func (*Property) AddChild

func (c *Property) AddChild(node Node)

func (*Property) AddChildren

func (c *Property) AddChildren(nodes ...Node)

func (*Property) Children

func (c *Property) Children() NodeList

func (*Property) FirstChild

func (c *Property) FirstChild() Node

func (*Property) InsertChildAfter

func (c *Property) InsertChildAfter(node Node, after Node) bool

func (*Property) InsertChildBefore

func (c *Property) InsertChildBefore(node Node, before Node) bool

func (*Property) LastChild

func (c *Property) LastChild() Node

func (*Property) PrependChild

func (c *Property) PrependChild(node Node)

func (*Property) PrependChildren

func (c *Property) PrependChildren(nodes ...Node)

func (*Property) RemoveChild

func (c *Property) RemoveChild(node Node) bool

func (*Property) RemoveChildren

func (c *Property) RemoveChildren(nodes ...Node)

func (*Property) ReplaceChild

func (c *Property) ReplaceChild(oldNode Node, newNode Node) bool

func (*Property) SetChildren

func (c *Property) SetChildren(nodes ...Node)

func (*Property) WithName

func (p *Property) WithName(name string) *Property

WithName sets the name of the property.

type Query

type Query struct {
	Query string
	// contains filtered or unexported fields
}

Query represents a simple query in the source, on the form `{{query datalog query}}`.

func NewQuery

func NewQuery(query string) *Query

func (*Query) NextSibling

func (n *Query) NextSibling() Node

func (*Query) Parent

func (n *Query) Parent() HasChildren

func (*Query) PreviousSibling

func (n *Query) PreviousSibling() Node

func (*Query) RemoveSelf

func (n *Query) RemoveSelf()

func (*Query) ReplaceWith

func (n *Query) ReplaceWith(node Node)

type QueryCommand

type QueryCommand struct {
	Query string
	// contains filtered or unexported fields
}

QueryCommand is a command represented by #+BEGIN_QUERY..#+END_QUERY in a block.

func NewQueryCommand

func NewQueryCommand(query string) *QueryCommand

func (*QueryCommand) NextSibling

func (n *QueryCommand) NextSibling() Node

func (*QueryCommand) Parent

func (n *QueryCommand) Parent() HasChildren

func (*QueryCommand) PreviousSibling

func (n *QueryCommand) PreviousSibling() Node

func (*QueryCommand) RemoveSelf

func (n *QueryCommand) RemoveSelf()

func (*QueryCommand) ReplaceWith

func (n *QueryCommand) ReplaceWith(node Node)

func (*QueryCommand) WithQuery

func (h *QueryCommand) WithQuery(query string) *QueryCommand

WithQuery sets the query for the command.

type QuoteCommand

type QuoteCommand struct {
	Quote string
	// contains filtered or unexported fields
}

QuoteCommand is a command represented by #+BEGIN_QUOTE..#+END_QUOTE in a block.

func (*QuoteCommand) NextSibling

func (n *QuoteCommand) NextSibling() Node

func (*QuoteCommand) Parent

func (n *QuoteCommand) Parent() HasChildren

func (*QuoteCommand) PreviousSibling

func (n *QuoteCommand) PreviousSibling() Node

func (*QuoteCommand) RemoveSelf

func (n *QuoteCommand) RemoveSelf()

func (*QuoteCommand) ReplaceWith

func (n *QuoteCommand) ReplaceWith(node Node)

type RawHTML

type RawHTML struct {

	// HTML is the HTML of this node.
	HTML string
	// contains filtered or unexported fields
}

func NewRawHTML

func NewRawHTML(html string) *RawHTML

func (*RawHTML) NextSibling

func (n *RawHTML) NextSibling() Node

func (*RawHTML) Parent

func (n *RawHTML) Parent() HasChildren

func (*RawHTML) PreviousSibling

func (n *RawHTML) PreviousSibling() Node

func (*RawHTML) RemoveSelf

func (n *RawHTML) RemoveSelf()

func (*RawHTML) ReplaceWith

func (n *RawHTML) ReplaceWith(node Node)

func (*RawHTML) WithHTML

func (h *RawHTML) WithHTML(html string) *RawHTML

WithHTML sets the HTML.

type RawHTMLBlock

type RawHTMLBlock struct {

	// HTML is the HTML of this node.
	HTML string
	// contains filtered or unexported fields
}

func NewRawHTMLBlock

func NewRawHTMLBlock(html string) *RawHTMLBlock

func (*RawHTMLBlock) NextSibling

func (n *RawHTMLBlock) NextSibling() Node

func (*RawHTMLBlock) Parent

func (n *RawHTMLBlock) Parent() HasChildren

func (*RawHTMLBlock) PreviousSibling

func (n *RawHTMLBlock) PreviousSibling() Node

func (*RawHTMLBlock) RemoveSelf

func (n *RawHTMLBlock) RemoveSelf()

func (*RawHTMLBlock) ReplaceWith

func (n *RawHTMLBlock) ReplaceWith(node Node)

func (*RawHTMLBlock) WithHTML

func (h *RawHTMLBlock) WithHTML(html string) *RawHTMLBlock

WithHTML sets the HTML.

type RawText

type RawText struct {

	// Value is the text of this node.
	Value string
	// contains filtered or unexported fields
}

RawText is used to wrap a string of text that should not be processed as Markdown. This is useful for when you want to include pre-generated Markdown.

func NewRawText

func NewRawText(text string) *RawText

func (*RawText) NextSibling

func (n *RawText) NextSibling() Node

func (*RawText) Parent

func (n *RawText) Parent() HasChildren

func (*RawText) PreviousSibling

func (n *RawText) PreviousSibling() Node

func (*RawText) RemoveSelf

func (n *RawText) RemoveSelf()

func (*RawText) ReplaceWith

func (n *RawText) ReplaceWith(node Node)

type Strikethrough

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

func NewStrikethrough

func NewStrikethrough(children ...Node) *Strikethrough

func (*Strikethrough) AddChild

func (c *Strikethrough) AddChild(node Node)

func (*Strikethrough) AddChildren

func (c *Strikethrough) AddChildren(nodes ...Node)

func (*Strikethrough) Children

func (c *Strikethrough) Children() NodeList

func (*Strikethrough) FirstChild

func (c *Strikethrough) FirstChild() Node

func (*Strikethrough) InsertChildAfter

func (c *Strikethrough) InsertChildAfter(node Node, after Node) bool

func (*Strikethrough) InsertChildBefore

func (c *Strikethrough) InsertChildBefore(node Node, before Node) bool

func (*Strikethrough) LastChild

func (c *Strikethrough) LastChild() Node

func (*Strikethrough) PrependChild

func (c *Strikethrough) PrependChild(node Node)

func (*Strikethrough) PrependChildren

func (c *Strikethrough) PrependChildren(nodes ...Node)

func (*Strikethrough) RemoveChild

func (c *Strikethrough) RemoveChild(node Node) bool

func (*Strikethrough) RemoveChildren

func (c *Strikethrough) RemoveChildren(nodes ...Node)

func (*Strikethrough) ReplaceChild

func (c *Strikethrough) ReplaceChild(oldNode Node, newNode Node) bool

func (*Strikethrough) SetChildren

func (c *Strikethrough) SetChildren(nodes ...Node)

type Strong

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

func NewStrong

func NewStrong(children ...Node) *Strong

func (*Strong) AddChild

func (c *Strong) AddChild(node Node)

func (*Strong) AddChildren

func (c *Strong) AddChildren(nodes ...Node)

func (*Strong) Children

func (c *Strong) Children() NodeList

func (*Strong) FirstChild

func (c *Strong) FirstChild() Node

func (*Strong) InsertChildAfter

func (c *Strong) InsertChildAfter(node Node, after Node) bool

func (*Strong) InsertChildBefore

func (c *Strong) InsertChildBefore(node Node, before Node) bool

func (*Strong) LastChild

func (c *Strong) LastChild() Node

func (*Strong) PrependChild

func (c *Strong) PrependChild(node Node)

func (*Strong) PrependChildren

func (c *Strong) PrependChildren(nodes ...Node)

func (*Strong) RemoveChild

func (c *Strong) RemoveChild(node Node) bool

func (*Strong) RemoveChildren

func (c *Strong) RemoveChildren(nodes ...Node)

func (*Strong) ReplaceChild

func (c *Strong) ReplaceChild(oldNode Node, newNode Node) bool

func (*Strong) SetChildren

func (c *Strong) SetChildren(nodes ...Node)

type TaskMarker

type TaskMarker struct {
	Status TaskStatus
	// contains filtered or unexported fields
}

func NewTaskMarker

func NewTaskMarker(t TaskStatus) *TaskMarker

func (*TaskMarker) NextSibling

func (n *TaskMarker) NextSibling() Node

func (*TaskMarker) Parent

func (n *TaskMarker) Parent() HasChildren

func (*TaskMarker) PreviousSibling

func (n *TaskMarker) PreviousSibling() Node

func (*TaskMarker) RemoveSelf

func (n *TaskMarker) RemoveSelf()

func (*TaskMarker) ReplaceWith

func (n *TaskMarker) ReplaceWith(node Node)

func (*TaskMarker) WithStatus

func (t *TaskMarker) WithStatus(status TaskStatus) *TaskMarker

WithStatus sets the status of the task marker.

type TaskStatus

type TaskStatus int

TaskStatus is the type of a task.

const (
	TaskStatusNone TaskStatus = iota
	// TaskStatusTodo is a TODO task.
	TaskStatusTodo
	// TaskStatusDoing is a DOING task.
	TaskStatusDoing
	// TaskStatusDone is a DONE task.
	TaskStatusDone
	// TaskStatusLater is a LATER task.
	TaskStatusLater
	// TaskStatusNow is a NOW task.
	TaskStatusNow
	// TaskStatusCancelled is a CANCELLED task.
	TaskStatusCancelled
	// TaskStatusCanceled is a CANCELED task.
	TaskStatusCanceled
	// TaskStatusInProgress is a IN-PROGRESS task.
	TaskStatusInProgress
	// TaskStatusWait is a WAIT task.
	TaskStatusWait
	// TaskStatusWaiting is a WAITING task.
	TaskStatusWaiting
)

type Text

type Text struct {

	// Value is the text of this node.
	Value string

	HardLineBreak bool

	SoftLineBreak bool
	// contains filtered or unexported fields
}

func NewText

func NewText(text string) *Text

func (*Text) NextSibling

func (n *Text) NextSibling() Node

func (*Text) Parent

func (n *Text) Parent() HasChildren

func (*Text) PreviousSibling

func (n *Text) PreviousSibling() Node

func (*Text) RemoveSelf

func (n *Text) RemoveSelf()

func (*Text) ReplaceWith

func (n *Text) ReplaceWith(node Node)

func (*Text) WithHardLineBreak

func (t *Text) WithHardLineBreak() *Text

func (*Text) WithNoLineBreak

func (t *Text) WithNoLineBreak() *Text

func (*Text) WithSoftLineBreak

func (t *Text) WithSoftLineBreak() *Text

func (*Text) WithValue

func (t *Text) WithValue(value string) *Text

WithValue sets the value of the text.

type ThematicBreak

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

func NewThematicBreak

func NewThematicBreak() *ThematicBreak

func (*ThematicBreak) NextSibling

func (n *ThematicBreak) NextSibling() Node

func (*ThematicBreak) Parent

func (n *ThematicBreak) Parent() HasChildren

func (*ThematicBreak) PreviousSibling

func (n *ThematicBreak) PreviousSibling() Node

func (*ThematicBreak) RemoveSelf

func (n *ThematicBreak) RemoveSelf()

func (*ThematicBreak) ReplaceWith

func (n *ThematicBreak) ReplaceWith(node Node)

Jump to

Keyboard shortcuts

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