Browse the docs

recognizers

Adds thing types: a pattern that makes text a typed thing, with an Open link, so macros can take it and Actions for This can list them.

Details #

A recognizer teaches Switchboard a new kind of thing. When the text you copy or select looks like ACME-1234, a recognizer can say "this is an Acme ticket" and give it an Open link. Macros then take it with an input of type thing:acme-ticket, and Actions for This lists the macros that fit.

Declare it in switchboard.json under adds.recognizers. Every entry has an id (lowercase, digits and . _ -, up to 64 characters, starting with a letter), which is also the thing type a macro's input names (thing:ticket), a title (1 to 80 characters, the type's name) and a pattern, a regular expression. Ids must be unique within the list.

{
  "adds": {
    "recognizers": [
      { "id": "ticket", "title": "Acme ticket", "pattern": "\\bACME-\\d+\\b", "url": "https://acme.example/browse/$0", "symbol": "ticket" }
    ]
  }
}

An extension that only adds recognizers still ships an entry; it can be an empty defineExtension({}).

Gotchas #

  • A type you add yourself in Library ▸ Thing Types with the same name wins over the extension's.

  • Don't use built-in type names (url, email, file...) as an id.

  • Texts longer than 2000 characters are not tested as a whole thing, and text searches stop at 100,000 characters.

  • Unknown keys in an entry are refused.

Full example #

The Full example above is a working extension with two thing types, an Acme ticket and a repo issue that uses named groups. You can download it from the Full example section and edit it into your own.

See also #