Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 0cb3ca5

Browse files
authored
Add javascript comments to the dt-ids snippet
1 parent 39973ee commit 0cb3ca5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

_includes/javascript.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,21 @@
1313
ga('send', 'pageview');
1414
</script>
1515
<script>
16+
// This snippet fixes a bug caused by Github's pages-gem using kramdown v1.11.1.
17+
// In order for anchor links to point to the correct place in the glossary, they must have an id
18+
// This snippet ensures every definition term has an id
19+
// See https://github.com/swcarpentry/styles/pull/129
1620
$('dt').each(function () {
1721
if (!this.id) {
1822
var id = $(this).text();
23+
// If there's a ( in the name (e.g., "comma-separated values (CSV)") - just take everything up to the first (
1924
var index = id.indexOf('(');
2025
if (index > 0) {
2126
id = id.substring(0, index);
2227
}
28+
// Strip leading and trailing whitespace, convert spaces to dashes and convert everything to lowercase
2329
id = id.trim().replace(/ /g, '-').toLowerCase();
2430
this.id = id;
2531
}
2632
});
27-
</script>
33+
</script>

0 commit comments

Comments
 (0)