marktab

package
v1.3.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package marktab handles reading and parsing of marktab files, inspired by the crontab file format. Marktab files are text files that define rules and actions to execute when gosuki detects a bookmark with tags matching the defined rule.

Marktab Format:

Each line in a marktab file represents a rule. A rule consists of three fields: trigger, pattern, and command. The syntax for each line is as follows:

#  *  *   *
#  |  |   |_____ shell command to execute
#  |  |_________ pattern to match on the url or title
#  |____________ trigger keyword to detect on the tags

Example:

notify		.*		my_notify_script

The syntax of each line expects an expression made of three field: trigger, pattern and command.

Trigger:

The keyword to detect in the bookmark tags. When gosuki parses bookmark tags and finds this trigger keyword, it evaluates the pattern rule. If the pattern matches, the corresponding command is executed.

Pattern:

A regular expression used for matching against a part of the bookmark URL or title. Once a trigger is detected, the pattern is evaluated to determine if there's a match with the bookmark data.

Command:

The shell command to execute when both the trigger and pattern are matched in a bookmark tag. This command can be any valid shell command and it allows for flexibility in performing various actions.

Index

Constants

View Source
const InvalidFormat = "invalid format"

Variables

This section is empty.

Functions

func PreloadRules

func PreloadRules() error

Types

type ErrorType

type ErrorType int
const (
	// No error
	OK ErrorType = iota

	ErrBadPattern

	ErrBadTrigger

	ErrBadRule
)

marktab parsing errors

type MarkTab

type MarkTab struct {
	Rules []Rule // Rules contains all the parsed rules from the marktab file.
}

MarkTab represents a collection of rules defined in the marktab file as lines.

var (
	CachedRules *MarkTab
)

func (*MarkTab) LoadMarktabs

func (mt *MarkTab) LoadMarktabs() error

type MarktabError

type MarktabError struct {
	ErrorType
	Rule    *Rule
	Context string
	// contains filtered or unexported fields
}

func (MarktabError) Error

func (mte MarktabError) Error() error

TODO:

type Rule

type Rule struct {
	Trigger string // keyword to detect in the bookmark tags
	Pattern string // regular expression used for matching against the bookmark URL or title.
	Command string // shell command to execute when both the trigger and pattern match the bookmark tags.
	// contains filtered or unexported fields
}

func (Rule) Match

func (rule Rule) Match(bk *gosuki.Bookmark) bool

Match checks if a bookmark matches the rule based on its title, URL, and tags. It returns true if both the trigger (part of the tag) or the pattern match is satisfied, otherwise it returns false.

Jump to

Keyboard shortcuts

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