# orion.core.linkScanner

Link scanners are declarative services that specify patterns of text to replace with link anchors. Scanners contribute a regular expression pattern to match in the source text. They then provide a link to be inserted for each match. These scanners are used by the text link service to convert text into a DOM node with appropriate anchor and text nodes as children.

## Service methods

None.

## Service attributes

Implementations of `orion.core.linkScanner` must define the following attributes:

pattern
  A regular expression string to locate links in the source text
words
  A `Number` identifying the number of white-space delimited words in each match
anchor
  A template of the URL for each match. The template may contain variables of the form %1, %2, etc, which are substituted by each of the words in the match.

## Examples

The following scanner will replace text of the form "bug 123456" with links of the form " https://bugs.eclipse.org/123456

    var provider = new eclipse.PluginProvider();
    var serviceImpl = {};
    var serviceProperties = {
      pattern: "bug\\s\\d{4,7}",
      words: 2,
      anchor: "https://bugs.eclipse.org/%2"
    };
    provider.registerServiceProvider("orion.core.linkScanner", serviceImpl, serviceProperties);
    provider.connect();

This scanner will replace email addresses with mailto: URLs:

    var provider = new eclipse.PluginProvider();
    var serviceImpl = {};
    var serviceProperties = {
      pattern: "\\bA-Z0-9._%-+@A-Z0-9.-+\\.A-Z{2,4}\\b",
      words: 1,
      anchor: "mailto:%1"
    };
    provider.registerServiceProvider("orion.core.linkScanner", serviceImpl, serviceProperties);
    provider.connect();