Skip to content

Commit

Permalink
Merge pull request #202 from macmillanpublishers/navpatch
Browse files Browse the repository at this point in the history
patch for emty nav item/hyperlink bug
  • Loading branch information
mattretzer authored Sep 26, 2018
2 parents 176d78c + 857e7b7 commit 46fc1f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/htmlmaker/bandaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fs.readFile(file, function processTemplates (err, contents) {
var myId = $(this).attr('id');
if ( myId !== undefined ) {
var newId = "fig-" + myId;
$(this).attr('id', newId);
$(this).attr('id', newId);
}
});

Expand Down Expand Up @@ -63,6 +63,14 @@ fs.readFile(file, function processTemplates (err, contents) {
$(this).append(myText);
});

// remove links to headings with no non-whitespace content from <nav>
navListItems = $("nav[data-type='toc'] li");
navListItems.each(function() {
if($(this).find("a").text().trim() == '') {
$(this).remove();
}
})

var output = $.html();
fs.writeFile(file, output, function(err) {
if(err) {
Expand All @@ -71,4 +79,4 @@ fs.readFile(file, function processTemplates (err, contents) {

console.log("Processing instructions have been evaluated!");
});
});
});

0 comments on commit 46fc1f6

Please sign in to comment.