linkhandler

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: GPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package linkhandler makes dictionary links in Markdown look words up in Bob.

Bob's Markdown view opens a link through macOS, and macOS can hand a URL only to an application bundle that registered its scheme. bob-mdict is a background process, not an application, so it keeps a tiny helper beside its data: an AppleScript applet, compiled on this machine by the system's own osacompile, that receives `bobmdict://lookup?text=…` and passes the text to Bob through Bob's documented AppleScript request (path "translate", action "translateText").

The applet is generated locally rather than shipped because a file created on the machine carries no download quarantine, so Gatekeeper never assesses it and an ad-hoc signature is all it needs. No developer certificate is involved, whichever way bob-mdict itself was installed.

Index

Constants

View Source
const AppName = "MDict Lookup.app"

AppName is the helper's bundle name. It is what macOS shows when it asks whether the helper may control Bob, so it says what the helper is for.

View Source
const Scheme = "bobmdict"

Scheme is the URL scheme the helper registers.

Variables

View Source
var ErrUnsupported = errors.New("dictionary lookup links need macOS")

ErrUnsupported means links cannot be handled on this system.

Functions

func BackURL

func BackURL(to string, port int) string

BackURL is the link that returns to to, one step back along the path the reader took.

func Ensure

func Ensure(ctx context.Context, dir string) (string, error)

Ensure installs or refreshes the helper in dir and registers it with Launch Services. It returns the helper's path. It is cheap when the helper is already current.

func LookupURL

func LookupURL(query string) string

LookupURL returns the link that looks query up in Bob, or "" for a query no dictionary link would carry.

func NavigateURL(query, from string, port int) string

NavigateURL is LookupURL for a link on the page of from: the helper tells the service where the reader came from before asking Bob, so the page that opens can offer the way back.

func PlayURL

func PlayURL(port int, token string, options PlayOptions) string

PlayURL returns the link that plays a recording through the service on port, identified by its opaque resource token.

Types

type PlayOptions

type PlayOptions struct {
	Volume, Rate int
	Normalize    bool
}

PlayOptions are the reader's playback settings a play link carries: volume and rate as percentages, and whether to match loudness.

Jump to

Keyboard shortcuts

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