diff --git a/src/Slugger.js b/src/Slugger.js index 51064211c1..00f63e48f1 100644 --- a/src/Slugger.js +++ b/src/Slugger.js @@ -13,6 +13,9 @@ module.exports = class Slugger { let slug = value .toLowerCase() .trim() + // remove html tags + .replace(/<[!\/a-z].*?>/ig, '') + // remove unwanted chars .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '') .replace(/\s/g, '-'); diff --git a/src/TextRenderer.js b/src/TextRenderer.js index 652004d50c..48c36e6999 100644 --- a/src/TextRenderer.js +++ b/src/TextRenderer.js @@ -20,6 +20,10 @@ module.exports = class TextRenderer { return text; } + html(text) { + return text; + } + text(text) { return text; } diff --git a/test/specs/new/headings_id.html b/test/specs/new/headings_id.html index 6f0ae49e32..68d8ab4bcc 100644 --- a/test/specs/new/headings_id.html +++ b/test/specs/new/headings_id.html @@ -1,3 +1,5 @@ +

Heading with html

+

Heading with some italic text

@@ -10,4 +12,4 @@

Or even code

What about strikethrough

- \ No newline at end of file + diff --git a/test/specs/new/headings_id.md b/test/specs/new/headings_id.md index fa8a4d82ca..0852c3718f 100644 --- a/test/specs/new/headings_id.md +++ b/test/specs/new/headings_id.md @@ -1,3 +1,5 @@ +### Heading with html + ### Heading with a [link](http://github.com/) ### Heading with some _italic text_ @@ -11,4 +13,4 @@ ## And a ref [link][destination] -[destination]: /some/url "link to nowhere" \ No newline at end of file +[destination]: /some/url "link to nowhere"