Skip to content

Commit

Permalink
Fix a bug in annotated.js when the chapter RST filename had hyphens
Browse files Browse the repository at this point in the history
Hyphens (-) in the RST filename broke the annotated.js code used
with the annotated RST directive. This commit fixes the bug.
Hyphens may be freely used in the RST filename.
  • Loading branch information
markkuriekkinen committed Oct 8, 2021
1 parent a4b36bd commit 3c1a40b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions directives/static/js/annotated.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jQuery(function ($) {
"Unexpected classes on code comment: " + $(this).attr("class")
);
}
var classBits = commentClass[0]
.substring(commentPrefix.length)
.split("-");
if (classBits.length != 2) {
var classEnd = commentClass[0].substring(commentPrefix.length);
var classSepIndex = classEnd.lastIndexOf('-');
if (classSepIndex === -1) {
console.error(
"Unexpected classes on code comment: " + $(this).attr("class")
);
classSepIndex = classEnd.length;
}
var exampleName = classBits[0];
var commentNumber = classBits[1];
var exampleName = classEnd.substring(0, classSepIndex);
var commentNumber = classEnd.substring(classSepIndex + 1);
var commentID = exampleName + "-" + commentNumber;

/* find all target locations for current commentary box */
Expand Down

0 comments on commit 3c1a40b

Please sign in to comment.