Skip to content

Commit

Permalink
Don't autolink inside a tags (fixes #88)
Browse files Browse the repository at this point in the history
  • Loading branch information
bterlson committed Apr 29, 2016
1 parent 29712f5 commit 0fadc4a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
Expand Down
17 changes: 16 additions & 1 deletion lib/autolinker.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
1 change: 1 addition & 0 deletions test/autolinking.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ <h1>Autolinking 2</h1>
<p>Strict mode shoud link. But Scrict Mode should not.</p>
<p>%Percent% should autolink.</p>
<p>Vars to dfns should be vars not dfns: _Lowercase_.</p>
<p>Also, no autolinks in <a href="#">anchors: Lowercase</a>.</p>
</emu-clause>
1 change: 1 addition & 0 deletions test/autolinking.html.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<p><emu-xref href="#sec-foo"><a href="#sec-foo">Strict mode</a></emu-xref> shoud link. But Scrict Mode should not.</p>
<p><emu-xref href="#sec-foo"><a href="#sec-foo">%Percent%</a></emu-xref> should autolink.</p>
<p>Vars to dfns should be vars not dfns: <var>Lowercase</var>.</p>
<p>Also, no autolinks in <a href="#">anchors: Lowercase</a>.</p>
</emu-clause>
</body>

0 comments on commit 0fadc4a

Please sign in to comment.