Skip to content
Snippets Groups Projects
Commit 0cb3ca5b authored by Nick Young's avatar Nick Young Committed by GitHub
Browse files

Add javascript comments to the dt-ids snippet

parent 39973eed
Branches
Tags
No related merge requests found
......@@ -13,15 +13,21 @@
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>
\ No newline at end of file
</script>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment