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

Commit 93aae56

Browse files
authored
Merge pull request #129 from neon-ninja/dt-ids
ensure dt elements have an id set
2 parents 62e0431 + 0cb3ca5 commit 93aae56

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: _includes/javascript.html

+19
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,22 @@
1212
ga('create', 'UA-37305346-2', 'auto');
1313
ga('send', 'pageview');
1414
</script>
15+
<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
20+
$('dt').each(function () {
21+
if (!this.id) {
22+
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 (
24+
var index = id.indexOf('(');
25+
if (index > 0) {
26+
id = id.substring(0, index);
27+
}
28+
// Strip leading and trailing whitespace, convert spaces to dashes and convert everything to lowercase
29+
id = id.trim().replace(/ /g, '-').toLowerCase();
30+
this.id = id;
31+
}
32+
});
33+
</script>

0 commit comments

Comments
 (0)