From 0fadc4ae95044e476d57a82a5577ece40ec604a4 Mon Sep 17 00:00:00 2001 From: Brian Terlson Date: Fri, 29 Apr 2016 12:03:40 -0700 Subject: [PATCH] Don't autolink inside a tags (fixes #88) --- lib/Spec.js | 2 +- lib/autolinker.js | 17 ++++++++++++++++- package.json | 2 +- test/autolinking.html | 1 + test/autolinking.html.baseline | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/Spec.js b/lib/Spec.js index e781d2d4..d5ab73eb 100644 --- a/lib/Spec.js +++ b/lib/Spec.js @@ -225,7 +225,7 @@ module.exports = class Spec { if (!classAttr) continue; const lang = classAttr.replace(/lang(uage)?\-/, ''); - let input = codes[i].textContent + let input = codes[i].textContent; // remove leading and trailing blank lines input = input.replace(/^(\s*[\r\n])+|([\r\n]\s*)+$/g, ''); diff --git a/lib/autolinker.js b/lib/autolinker.js index 3b4e450d..cf6bfae0 100644 --- a/lib/autolinker.js +++ b/lib/autolinker.js @@ -1,7 +1,22 @@ 'use strict'; const escape = require('html-escape'); const utils = require('./utils'); -const NO_CLAUSE_AUTOLINK = ['PRE', 'CODE', 'EMU-CLAUSE', 'EMU-PRODUCTION', 'EMU-GRAMMAR', 'EMU-XREF', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'EMU-EQN', 'EMU-ALG', 'EMU-VAR', 'EMU-VAL', 'VAR']; +const NO_CLAUSE_AUTOLINK = [ + 'PRE', + 'CODE', + 'EMU-CLAUSE', + 'EMU-PRODUCTION', + 'EMU-GRAMMAR', + 'EMU-XREF', + 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', + 'EMU-EQN', + 'EMU-ALG', + 'EMU-VAR', + 'EMU-VAL', + 'VAR', + 'A' +]; + const clauseTextNodesUnder = utils.textNodesUnder(NO_CLAUSE_AUTOLINK); exports.link = function(spec) { diff --git a/package.json b/package.json index 444a95c1..885044bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ecmarkup", - "version": "3.2.1", + "version": "3.2.2", "description": "Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.", "main": "lib/ecmarkup.js", "scripts": { diff --git a/test/autolinking.html b/test/autolinking.html index 98f8d93e..798ef4c7 100644 --- a/test/autolinking.html +++ b/test/autolinking.html @@ -17,4 +17,5 @@

Autolinking 2

Strict mode shoud link. But Scrict Mode should not.

%Percent% should autolink.

Vars to dfns should be vars not dfns: _Lowercase_.

+

Also, no autolinks in anchors: Lowercase.

diff --git a/test/autolinking.html.baseline b/test/autolinking.html.baseline index 1e00a7d1..e8f10fff 100644 --- a/test/autolinking.html.baseline +++ b/test/autolinking.html.baseline @@ -15,5 +15,6 @@

Strict mode shoud link. But Scrict Mode should not.

%Percent% should autolink.

Vars to dfns should be vars not dfns: Lowercase.

+

Also, no autolinks in anchors: Lowercase.

\ No newline at end of file