summaryrefslogtreecommitdiffstats
path: root/lib/parse/parseGlossary.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parse/parseGlossary.js')
-rw-r--r--lib/parse/parseGlossary.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/parse/parseGlossary.js b/lib/parse/parseGlossary.js
new file mode 100644
index 0000000..f56c751
--- /dev/null
+++ b/lib/parse/parseGlossary.js
@@ -0,0 +1,22 @@
+var parseStructureFile = require('./parseStructureFile');
+var Glossary = require('../models/glossary');
+
+/**
+ Parse glossary
+
+ @param {Book} book
+ @return {Promise<Book>}
+*/
+function parseGlossary(book) {
+ return parseStructureFile(book, 'glossary')
+ .spread(function(file, entries) {
+ if (!file) {
+ return book;
+ }
+
+ var glossary = Glossary.createFromEntries(file, entries);
+ return book.set('glossary', glossary);
+ });
+}
+
+module.exports = parseGlossary;