Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not unique Ids and ids with spaces? #27

Open
anakenabcn opened this issue Jun 18, 2018 · 5 comments
Open

Not unique Ids and ids with spaces? #27

anakenabcn opened this issue Jun 18, 2018 · 5 comments
Labels

Comments

@anakenabcn
Copy link

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?

@gajus gajus added the question label Jun 18, 2018
@gajus
Copy link
Owner

gajus commented Jun 18, 2018

Please produce an example of expected vs actual result.

@anakenabcn
Copy link
Author

anakenabcn commented Jun 19, 2018

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

@gajus
Copy link
Owner

gajus commented Jun 19, 2018

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.

@anakenabcn
Copy link
Author

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

@joeljv91
Copy link
Contributor

I fixed the bug please check the pull request.

#28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants