markdown-it-github-headings icon indicating copy to clipboard operation
markdown-it-github-headings copied to clipboard

Size of innertext dependency

Open JanMalch opened this issue 6 years ago • 3 comments

The innertext dependency is dependent on html-entities which results in an extra 46.2 KB or 13.82 KB gzip'd.

Could innertext be replaced with a more lightweight library?

JanMalch avatar Sep 17 '19 09:09 JanMalch

Sure! We'll happily accept pull requests to do this!

Flet avatar Sep 23 '19 15:09 Flet

I'm working on it and noticed the following. Without changing the dependency yet, the following test runs succesfully

test('innertext', function (t) {
  var result = md().use(anchor, { prefix: 'foo-' }).render('# Hello <b>there</b>')
  var expectedResult = `<h1><a id="foo-hello-bthereb" class="anchor" href="#hello-bthereb" aria-hidden="true">${svg}</a>Hello &lt;b&gt;there&lt;/b&gt;</h1>\n`
  t.equals(result, expectedResult, 'works')
  t.end()
})

Is it intended that the id includes the tag-name b?

Using .render('<h1>Hello <b>there</b></h1>') results in no header element at all.

JanMalch avatar Sep 24 '19 09:09 JanMalch

Sorry for the late reply on this... No I don't think that is intended!

Flet avatar Jan 14 '20 00:01 Flet