diff options
Diffstat (limited to 'lib/output/modifiers')
-rw-r--r-- | lib/output/modifiers/__tests__/annotateText.js | 6 | ||||
-rw-r--r-- | lib/output/modifiers/annotateText.js | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/output/modifiers/__tests__/annotateText.js b/lib/output/modifiers/__tests__/annotateText.js index 40b1e6c..67e7a10 100644 --- a/lib/output/modifiers/__tests__/annotateText.js +++ b/lib/output/modifiers/__tests__/annotateText.js @@ -12,7 +12,7 @@ describe('annotateText', function() { it('should annotate text', function() { var $ = cheerio.load('<p>This is a word, and multiple words</p>'); - annotateText(entries, $); + annotateText(entries, 'GLOSSARY.md', $); var links = $('a'); expect(links.length).toBe(2); @@ -31,14 +31,14 @@ describe('annotateText', function() { it('should not annotate scripts', function() { var $ = cheerio.load('<script>This is a word, and multiple words</script>'); - annotateText(entries, $); + annotateText(entries, 'GLOSSARY.md', $); expect($('a').length).toBe(0); }); it('should not annotate when has class "no-glossary"', function() { var $ = cheerio.load('<p class="no-glossary">This is a word, and multiple words</p>'); - annotateText(entries, $); + annotateText(entries, 'GLOSSARY.md', $); expect($('a').length).toBe(0); }); }); diff --git a/lib/output/modifiers/annotateText.js b/lib/output/modifiers/annotateText.js index d8443cf..2b4b439 100644 --- a/lib/output/modifiers/annotateText.js +++ b/lib/output/modifiers/annotateText.js @@ -62,9 +62,10 @@ function replaceText($, el, search, replace, text_only ) { Annotate text using a list of GlossaryEntry @param {List<GlossaryEntry>} + @param {String} glossaryFilePath @param {HTMLDom} $ */ -function annotateText(entries, $) { +function annotateText(entries, glossaryFilePath, $) { entries.forEach(function(entry) { var entryId = entry.getID(); var name = entry.getName(); @@ -81,7 +82,7 @@ function annotateText(entries, $) { ) return; replaceText($, this, searchRegex, function(match) { - return '<a href="/GLOSSARY.md#' + entryId + '" ' + return '<a href="/' + glossaryFilePath + '#' + entryId + '" ' + 'class="glossary-term" title="' + escape(description) + '">' + match + '</a>'; |