contents icon indicating copy to clipboard operation
contents copied to clipboard

Not unique Ids and ids with spaces?

Open anakenabcn opened this issue 7 years ago • 5 comments
trafficstars

Hi,

I think i'm facing some bug with your library i'm using 4.0.2 version and all ids are like

#Wath is some think id

any ideas?

anakenabcn avatar Jun 18 '18 16:06 anakenabcn

Please produce an example of expected vs actual result.

gajus avatar Jun 18 '18 19:06 gajus

Well this is my code

    // Use Contents library to create dynamically the table of contents
    let $articleContainer = $('#table-contents-content');
    let $tableContentsContainer = $('#table-contents-container');
    let contents = $articleContainer.find('h2,h3').get();

    // Append list to table contents
    $tableContentsContainer.append(Contents({articles: contents}).list());

This is an example of h2:

<h2>How much weight can I lose</h2>

And this is the link auto generated by library: <a href="#How much weight can I lose"...

I expected something like that:

<a href="#how-much-weight-can-i-lose"...

And if I introduce two h2 tag with the same name the same name is generated as id and in the docs says the ids will be different with numbers.

#how-much-weight-can-i-lose #how-much-weight-can-i-lose1 #how-much-weight-can-i-lose2 ...

I'm doing something wrong?

Thanks

anakenabcn avatar Jun 19 '18 07:06 anakenabcn

Looks like a bug.

It is a not a library that I use actively.

But if you patch it up, I am happy to merge a fix.

gajus avatar Jun 19 '18 15:06 gajus

Yes, it's a bug. I will try to patch it up.

anakenabcn avatar Jun 20 '18 08:06 anakenabcn

I fixed the bug please check the pull request.

#28

joeljv91 avatar Jun 20 '18 08:06 joeljv91