graph

package
v0.0.0-...-3b80095 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockPrefix is the prefix for a block opener.
	BlockPrefix = "- "
	// BlockContentPrefix is the prefix for a continued block content line.
	BlockContentPrefix = "  "
	// IndentMarker is the character used to indicate indentation.
	IndentMarker = "\t"
	// PropIndicator helps identify properties.
	PropIndicator = ":: "
)

Variables

View Source
var ErrEmptyBlock = errors.New("empty block")
View Source
var ErrInvalidLine = errors.New("invalid line")
View Source
var ErrInvalidLogseqLine = errors.New("invalid Logseq line")

ErrInvalidLogseqLine is returned when a line is not a valid Logseq line.

View Source
var ErrMismatchedDepth = errors.New("mismatched depth")
View Source
var ErrPropNotBoolean = errors.New("property is not a boolean")
View Source
var ErrPropNotFound = errors.New("property not found")

Functions

func LineIsProp

func LineIsProp(line string) bool

LineIsProp returns true if the line describes a Logseq property.

Types

type Block

type Block struct {
	// Lines is the content of the block.
	Lines []*LogseqLine
	// Props is a map of properties for the block.
	Props map[string]*Prop
	// Depth is the indentation level of the block.
	Depth int
}

Block represents a single block in a Logseq page.

func NewBlock

func NewBlock(lines []*LogseqLine) (*Block, error)

NewBlock creates a new block from a slice of lines.

func (*Block) GetProp

func (b *Block) GetProp(field string) (*Prop, error)

GetProp returns a property from the block.

type LogseqLine

type LogseqLine struct {
	// Raw is the raw text of the line.
	Raw string
	// Adjusted is the line with outline structures removed.
	Adjusted string
	// Depth is the indentation level of the line.
	Depth int
	// IsProp is true if the line indicates a property.
	IsProp bool
}

LogseqLine holds the data for a single line in a Logseq page.

func NewLogseqLine

func NewLogseqLine(line string) (*LogseqLine, error)

NewLogseqLine creates a new LogseqLine.

type Page

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

func NewPage

func NewPage(sourceFile string) *Page

func (*Page) IsPublic

func (p *Page) IsPublic() bool

type PageTally

type PageTally struct {
	PublicPageCount  int
	PrivatePageCount int
	TotalPageCount   int
}

func NewPageTally

func NewPageTally(pages []*Page) *PageTally

NewPageTally creates a new PageTally struct.

func (PageTally) Render

func (pt PageTally) Render() string

Render renders a table tallying the number of public and private pages.

type Prop

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

Prop represents a Logseq property.

func NewProp

func NewProp(line string) (*Prop, error)

func (*Prop) AsBoolean

func (p *Prop) AsBoolean() (bool, error)

AsBoolean returns the value of the property as a boolean, or false with an ErrPropNotBoolean if the value is not a boolean.

func (*Prop) AsString

func (p *Prop) AsString() string

AsString returns the original string value of the property.

Jump to

Keyboard shortcuts

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