Syntax: Link Colour Question

The scopes section of the syntax documentation suggests I should be able to apply a colour to a scope by using, for example color.green.

This works when I set something in a pattern section, as per the Demo Rainbow syntax (I also double-checked to see it was indeed defined in the theme I was using), but it does not seem to work when I use this for the scope of an element such as the key, in a link definition (see below). Replacing the colour entry with text options such as text.bold, or text.underline work fine for this, but not colours.

The documentation seems to suggest I should be able to set the colour of the link as it is a scope and the text styling seems to be applied just fine. The behaviour I am observing suggests otherwise, or the very real possibility I’ve not taken something into account about how to do this.

  "linkDefinitions": [
    {
      "match": "(\\[\\[)(((d|u|s|w|google|wikipedia|bear|url):)?([^\\[]+?))(\\]\\])",
      "templates": {
        "": "drafts://open?title=[[value]]&allowCreate=true",
        "google": "https://www.google.com/search?q=[[value]]",
        "wikipedia": "https://en.wikipedia.org/wiki/[[value]]",
        "u": "drafts://open?uuid=[[value]]",
        "d": "drafts://open?title=[[value]]&allowCreate=true",
        "bear": "bear://x-callback-url/open-note?title=[[value]]",
        "w": "drafts://workspace?name=[[value]]",
        "s": "drafts://quickSearch?query=[[value]]",
        "url": "[[value_unencoded]]"
      },
      "enabled": true,
      "captures": {
        "value": "5",
        "key":  "4",
        "prefix": "1",
        "suffix": "6",
        "link": "2"
      },
      "scopes": {
        "key": "color.green",
        "value": "",
        "prefix": "markup",
        "suffix": "markup"
      }

I was extra careful to make sure that I dropped the British “u” from “colour” when I was trying this - it wouldn’t be the first time that had caught me out!

Can anyone confirm if this is possible or not, and if it is possible, how to apply a colour to an element of a link definition?


I am testing on:

  • Drafts: 27.5.37 (Beta).
  • MacOS: 11.4.

Not possible. You can set the link color in themes, but text views only support a single color for elements that are active links. This is a platform limitation.

2 Likes

Thanks for clarifying :+1:t2: