Open kafoso opened 9 years ago
For me, it doesn't produce a Syntax error, but the link does not work, undoubtedly due to having quote marks in the link. I suggest that the hashGenerator functions provided are augmented to include a filter for quotes and apostrophes; this should cure the problem fairy easily.
Hi, I was randomly getting those errors and thanks to this post i figured it was because of the quotes in headers. Seeing the advice from @micrology, it was easy to solve thanks to the "hashGenerator" API option. I just added a "replace" to further strip quotes and errors are gone.
//Calls the tocify method on your HTML div.
$("#toc_content").tocify({
context: "#secc_content",
ignoreSelector: ".no_tocify",
// fix quotes in headings...
// function(text, element){} - Your own hash generation function that accepts the text as an
// argument, and returns the hash value.
hashGenerator:function(text, element){
// prettify the text - taken from tocify.js
var hashValue = text.toLowerCase().replace(/\s/g, "");
// strip single and double quotes...
hashValue = hashValue.replace(/["']/g,"");
return hashValue;
}
});
Headings containing a (double) quote symbol, i.e.
"
, will produce an error.This heading, for instance:
... produces the error:
This is likely due do the quote symbol not being escaped.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.