Dump glossary index to glossary_index.json

This commit is contained in:
Samy Pessé
2014-08-18 21:32:10 -07:00
parent e1723ad3d5
commit d84acd0b82
2 changed files with 15 additions and 2 deletions
+4 -2
View File
@@ -63,8 +63,6 @@ Indexer.prototype.text = function(nodes) {
// Add page to glossary index
Indexer.prototype.add = function(sections, url) {
if(!(this.glossary && this.glossary.length > 0)) {
console.log('Glossary =', this.glossary);
console.log('No glossary to match');
return;
}
@@ -91,6 +89,10 @@ Indexer.prototype.add = function(sections, url) {
};
Indexer.prototype.dump = function() {
return JSON.stringify(this.idx);
};
function regexEscape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+11
View File
@@ -223,11 +223,22 @@ Generator.prototype.writeSearchIndex = function() {
);
};
// Dump glossary index to disk
Generator.prototype.writeGlossaryIndex = function() {
if (!this.glossaryIndexer) return Q();
return fs.writeFile(
path.join(this.options.output, 'glossary_index.json'),
this.glossaryIndexer.dump()
);
};
Generator.prototype.finish = function() {
return this.copyAssets()
.then(this.copyCover)
.then(this.writeGlossary)
.then(this.writeGlossaryIndex)
.then(this.writeSearchIndex);
};