Open tguiot opened 4 years ago
This might have been resolved with #23. Can you confirm?
I don't think so. My problem was clearly linked to encoding/decoding accented letters in UTF8. #23 just adds a new link to navigate to top of the page, but I don't see how it would affect the other links to navigate to anchors in the page...
Hi, @tguiot. I think this is https://github.com/prtksxna/persistent-toc/issues/17, which was fixed yesterday in https://github.com/prtksxna/persistent-toc/pull/25.
My bad, I linked to the wrong issue. @PeterBowman is correct ☝🏽
I have a TOC with links to titles with accents, e.g. "Catégories". In wiki, there are actually two span in the content
in the wiki TOC, the anchor is to "#Cat.C3.A9gories", and this is also what appears in the ptoc on the left. So I don't know exactly why it moved to the top of the page when clicking on it. other anchors, without accents, work fine.
I figured it had something to do with the utf8 encoding of those accented characters, so I loaded the ptoc.js in my mediawiki:Common.js and changed this line:
scrollTop: $( $( this ).attr( 'href' ) ).offset().top - headingThreshold
to this:scrollTop: $( decodeURIComponent(($( this ).attr( 'href' )).replace(/\./g,'%'))).offset().top - headingThreshold
this first replaces all dots with the percent sign, so "#Cat.C3.A9gories" becomes "#Cat%C3%A9gories", then decodes the utf8 encoded characters and becomes "#Catégories".
and it worked.