Apply link matchers in reverse

This enables consumers to have full control.
This commit is contained in:
Daniel Imms
2017-02-14 20:06:15 -08:00
parent 3b62aa444b
commit c3f31b5f65
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -78,7 +78,7 @@ export class Linkifier {
* this searches the textContent of the rows. You will want to use \s to match
* a space ' ' character for example.
* @param {LinkHandler} handler The callback when the link is called.
* @param {number} matchIndex The index of the link from the regex.match(html)
* @param {number} matchIndex The index of the link from the regex.match(text)
* call. This defaults to 0 (for regular expressions without capture groups).
* @return {number} The ID of the new matcher, this can be used to deregister.
*/
@@ -118,7 +118,7 @@ export class Linkifier {
*/
private _linkifyRow(rowIndex: number): void {
const text = this._rows[rowIndex].textContent;
for (let i = 0; i < this._linkMatchers.length; i++) {
for (let i = this._linkMatchers.length - 1; i >= 0; i--) {
const matcher = this._linkMatchers[i];
const uri = this._findLinkMatch(text, matcher.regex, matcher.matchIndex);
if (uri) {
+1 -1
View File
@@ -1305,7 +1305,7 @@ Terminal.prototype.attachHypertextLinkHandler = function(handler) {
* this searches the textContent of the rows. You will want to use \s to match
* a space ' ' character for example.
* @param {LinkHandler} handler The callback when the link is called.
* @param {number} matchIndex The index of the link from the regex.match(html)
* @param {number} matchIndex The index of the link from the regex.match(text)
* call. This defaults to 0 (for regular expressions without capture groups).
* @return {number} The ID of the new matcher, this can be used to deregister.
*/