Skip to content

Commit

Permalink
Merge pull request #129 from neon-ninja/dt-ids
Browse files Browse the repository at this point in the history
ensure dt elements have an id set
  • Loading branch information
rgaiacs authored Feb 18, 2017
2 parents 62e0431 + 0cb3ca5 commit 93aae56
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions _includes/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,22 @@
ga('create', 'UA-37305346-2', 'auto');
ga('send', 'pageview');
</script>
<script>
// This snippet fixes a bug caused by Github's pages-gem using kramdown v1.11.1.
// In order for anchor links to point to the correct place in the glossary, they must have an id
// This snippet ensures every definition term has an id
// See https://github.com/swcarpentry/styles/pull/129
$('dt').each(function () {
if (!this.id) {
var id = $(this).text();
// If there's a ( in the name (e.g., "comma-separated values (CSV)") - just take everything up to the first (
var index = id.indexOf('(');
if (index > 0) {
id = id.substring(0, index);
}
// Strip leading and trailing whitespace, convert spaces to dashes and convert everything to lowercase
id = id.trim().replace(/ /g, '-').toLowerCase();
this.id = id;
}
});
</script>

0 comments on commit 93aae56

Please sign in to comment.