summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/utils/page.js7
-rw-r--r--test/glossary.js2
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/utils/page.js b/lib/utils/page.js
index 9b33b96..f24013f 100644
--- a/lib/utils/page.js
+++ b/lib/utils/page.js
@@ -237,13 +237,16 @@ function normalizeHtml(src, options) {
});
// Replace glossary terms
- _.each(options.glossary, function(term) {
+ var glossary = _.sortBy(options.glossary, function(term) {
+ return -term.name.length;
+ });
+ _.each(glossary, function(term) {
var r = new RegExp( "\\b(" + pregQuote(term.name.toLowerCase()) + ")\\b" , 'gi' );
var includedInFiles = false;
$("*").each(function() {
// Ignore codeblocks
- if (_.contains(["code", "pre"], this.name.toLowerCase())) return;
+ if (_.contains(["code", "pre", "a"], this.name.toLowerCase())) return;
replaceText($, this, r, function(match) {
// Add to files index in glossary
diff --git a/test/glossary.js b/test/glossary.js
index 14c3cf7..fb573d9 100644
--- a/test/glossary.js
+++ b/test/glossary.js
@@ -76,7 +76,7 @@ describe('Glossary', function () {
it('should correctly select the longest term', function() {
readme.should.be.html({
- ".page-inner a[href='GLOSSARY.html#test-long']": {
+ ".page-inner a[href='GLOSSARY.html#test_long']": {
count: 1,
text: "test long"
}