Skip to content

Commit 785763a

Browse files
committed
Merge pull request Codeception#28 from splinter89/patch-1
fix anchors in TOC for headings with 2+ spaces
2 parents 3c79533 + 116fbf4 commit 785763a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

_layouts/doc.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
<script type="text/javascript">
2626
$(document).ready(function () {
2727
$('#toc').toc({
28-
'selectors': 'h2,h3,h4',
29-
'prefix': 'toc',
30-
'container': '#page',
31-
'anchorName': function(i, heading, prefix) { //custom function for anchor name
32-
return $(heading).text().replace(' ','-');
33-
},
28+
selectors: 'h2,h3,h4',
29+
container: '#page',
30+
anchorName: function (i, heading, prefix) {
31+
return $(heading).text().replace(/\s/g, '-').replace(/[^\w-]/g, '');
32+
},
3433
});
3534
});
3635
</script>
@@ -50,4 +49,4 @@
5049

5150

5251
</div>
53-
</div>
52+
</div>

0 commit comments

Comments
 (0)