| 1 | /*global Autolinker */ |
| 2 | /** |
| 3 | * @abstract |
| 4 | * @class Autolinker.matcher.Matcher |
| 5 | * |
| 6 | * An abstract class and interface for individual matchers to find matches in |
| 7 | * an input string with linkified versions of them. |
| 8 | * |
| 9 | * Note that Matchers do not take HTML into account - they must be fed the text |
| 10 | * nodes of any HTML string, which is handled by {@link Autolinker#parse}. |
| 11 | */ |
| 12 | Autolinker.matcher.Matcher = Autolinker.Util.extend( Object, { |
| 13 | |
| 14 | /** |
| 15 | * @cfg {Autolinker.AnchorTagBuilder} tagBuilder (required) |
| 16 | * |
| 17 | * Reference to the AnchorTagBuilder instance to use to generate HTML tags |
| 18 | * for {@link Autolinker.match.Match Matches}. |
| 19 | */ |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * @constructor |
| 24 | * @param {Object} cfg The configuration properties for the Matcher |
| 25 | * instance, specified in an Object (map). |
| 26 | */ |
| 27 | constructor : function( cfg ) { |
| 28 | // @if DEBUG |
| 29 | if( !cfg.tagBuilder ) throw new Error( '`tagBuilder` cfg required' ); |
| 30 | // @endif |
| 31 | |
| 32 | this.tagBuilder = cfg.tagBuilder; |
| 33 | }, |
| 34 | |
| 35 | |
| 36 | /** |
| 37 | * Parses the input `text` and returns the array of {@link Autolinker.match.Match Matches} |
| 38 | * for the matcher. |
| 39 | * |
| 40 | * @abstract |
| 41 | * @param {String} text The text to scan and replace matches in. |
| 42 | * @return {Autolinker.match.Match[]} |
| 43 | */ |
| 44 | parseMatches : Autolinker.Util.abstractMethod |
| 45 | |
| 46 | } ); |