Documentation
¶
Index ¶
- Variables
- func AppendRawMarkdownToJournal(graph *logseq.Graph, date time.Time, rawMarkdown string) (int, error)
- func FlatMarkdownToOutline(input string, opts OutlineOptions) string
- func InsertMarkdown(opts *InsertMarkdownOptions) error
- func IsAncestor(block, ancestor *content.Block) bool
- func IsValidMarkdownFile(filePath string) bool
- func ReadFromStdin() string
- func SortAndRemoveDuplicates(elements []string) []string
- func TidyUpOneFile(graph *logseq.Graph, path string) int
- type ChangedContents
- type ChangedPage
- type InsertMarkdownOptions
- type OutlineOptions
Constants ¶
This section is empty.
Variables ¶
var ErrPageIsNil = errors.New("page is nil")
ErrPageIsNil is returned when a page is nil.
var PageColor = color.New(color.FgHiWhite).SprintfFunc() //nolint:gochecknoglobals
PageColor is a color function for page names.
Functions ¶
func AppendRawMarkdownToJournal ¶
func AppendRawMarkdownToJournal(graph *logseq.Graph, date time.Time, rawMarkdown string) (int, error)
AppendRawMarkdownToJournal appends raw Markdown content to the journal page for the given date. I tried appending blocks with `logseq-go` but there is and with text containing brackets. e.g. "[something]" is escaped like "\[something\]" and this breaks links.
func FlatMarkdownToOutline ¶ added in v0.8.0
func FlatMarkdownToOutline(input string, opts OutlineOptions) string
FlatMarkdownToOutline converts flat Markdown to a Logseq bullet outline. It strips YAML frontmatter before parsing and prepends it unchanged to the result. It is idempotent: if the conversion is a no-op, the original input is returned.
func InsertMarkdown ¶ added in v0.8.0
func InsertMarkdown(opts *InsertMarkdownOptions) error
InsertMarkdown inserts Markdown content to a page or journal. If Page is provided, adds to that page. Otherwise, adds to journal for Date. If Key is provided, it searches for an existing block containing that key (case-insensitive) and updates it. Otherwise, creates a new block. If ParentText is provided, it searches for the first block containing that text and inserts the content as a child block. Otherwise, appends to the end.
func IsAncestor ¶
IsAncestor checks if ancestor is an ancestor of block by traversing up the parent chain. Returns true if ancestor is found in the parent hierarchy of block, false otherwise. Returns true if block and ancestor are the same block.
func IsValidMarkdownFile ¶
IsValidMarkdownFile checks if a file is a Markdown file, by looking at its extension, not its content.
func ReadFromStdin ¶
func ReadFromStdin() string
ReadFromStdin reads from stdin and returns the content as a string. It doesn't return an error and aborts the program if it fails because it's an internal function.
func SortAndRemoveDuplicates ¶
Types ¶
type ChangedContents ¶
ChangedContents is the result of a check function that modifies file contents directly without a transaction.
func RemoveUnnecessaryBracketsFromTags ¶
func RemoveUnnecessaryBracketsFromTags(oldContents string) ChangedContents
RemoveUnnecessaryBracketsFromTags removes unnecessary brackets from hashtags. logseq-go rewrites tags correctly when saving the transaction, removing unnecessary brackets. But, when reading the file, the AST doesn't provide the information if a tag has brackets or not. So I would have to rewrite the file to fix them, and I don't want to do it every time there is a tag without spaces. Also, as of 2024-12-30, logseq-go has a bug when reading properties with spaces in values, which causes them to be partially removed from the file, destroying data. I will report it soon.
type ChangedPage ¶
ChangedPage is the result of a check function that modifies Markdown through a Page and a transaction.
func CheckForbiddenReferences ¶
func CheckForbiddenReferences(page logseq.Page) ChangedPage
CheckForbiddenReferences checks if a page has forbidden references to other pages or tags.
func CheckRunningTasks ¶
func CheckRunningTasks(page logseq.Page) ChangedPage
CheckRunningTasks checks if a page has running tasks (DOING, etc.).
func RemoveDoubleSpaces ¶
func RemoveDoubleSpaces(page logseq.Page) ChangedPage
RemoveDoubleSpaces removes double spaces from text, page links, and tags, except for tables.
func RemoveEmptyBullets ¶
func RemoveEmptyBullets(page logseq.Page) ChangedPage
type InsertMarkdownOptions ¶
type InsertMarkdownOptions struct {
Graph *logseq.Graph
Date time.Time
Page string // Page name to add content to (empty = journal)
Content string
ParentText string // Partial text to search for in parent blocks
Key string // Unique key to search for existing block (case-insensitive)
}
InsertMarkdownOptions contains options for inserting Markdown content.
type OutlineOptions ¶ added in v0.8.0
type OutlineOptions struct {
// KeepBreaks preserves blank lines between blocks as empty "- " bullet lines.
KeepBreaks bool
}
OutlineOptions configures the flat-Markdown-to-outline conversion.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api provides the Logseq HTTP API client and graph-opening utilities.
|
Package api provides the Logseq HTTP API client and graph-opening utilities. |
|
Package groom implements the grooming business logic for Logseq tasks.
|
Package groom implements the grooming business logic for Logseq tasks. |
|
Package logseqext provides generic extensions to the logseq-go library.
|
Package logseqext provides generic extensions to the logseq-go library. |