From bdad96c81483477ff24131dfbc642520c654277b Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Wed, 24 Apr 2019 15:51:43 +0000 Subject: [PATCH] fix(html): ignore HTML tags when generating IDs for headlines --- package-lock.json | 7 ++++++- package.json | 1 + src/utils/heading-handler.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4423ba0fb..deb80e8ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@adobe/helix-pipeline", - "version": "1.5.1", + "version": "1.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -14450,6 +14450,11 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true }, + "strip-markdown": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/strip-markdown/-/strip-markdown-3.0.3.tgz", + "integrity": "sha512-G2DSM9wy3PWxY3miAibWpsTqZgXLXgRoq0yVyaVs9O7FDGEwPO6pmSE8CyzHhU88Z2w1dkFqFmWUklFNsQKwqg==" + }, "style-to-object": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.2.2.tgz", diff --git a/package.json b/package.json index 313432d02..bae1d74ae 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "request-promise-native": "^1.0.5", "retext": "^6.0.0", "retext-smartypants": "^3.0.1", + "strip-markdown": "^3.0.3", "unified": "^7.0.0", "unist-util-find-all-between": "^1.0.2", "unist-util-map": "^1.0.4", diff --git a/src/utils/heading-handler.js b/src/utils/heading-handler.js index 704fd9441..78f5529f1 100644 --- a/src/utils/heading-handler.js +++ b/src/utils/heading-handler.js @@ -11,6 +11,7 @@ */ const fallback = require('mdast-util-to-hast/lib/handlers/heading'); const toString = require('mdast-util-to-string'); +const strip = require('strip-markdown'); const GithubSlugger = require('github-slugger'); /** @@ -39,7 +40,7 @@ class HeadingHandler { handler() { return (h, node) => { // Prepare the heading id - const headingIdentifier = this.slugger.slug(toString(node)); + const headingIdentifier = this.slugger.slug(toString(strip()(node))); // Inject the id after transformation const n = Object.assign({}, node);