summaryrefslogtreecommitdiffstats
path: root/lib/parse/glossary.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-19 09:47:36 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-19 09:47:36 +0100
commitec586dd3cdf06e9567f5d3e4961022ddc3c94778 (patch)
treecc7825ab73110b4e6fbedee404427b052edffa17 /lib/parse/glossary.js
parent80432161708357bdcf0e00533d9e6d327636dab6 (diff)
downloadgitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.zip
gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.tar.gz
gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.tar.bz2
Clear folder
Diffstat (limited to 'lib/parse/glossary.js')
-rw-r--r--lib/parse/glossary.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/lib/parse/glossary.js b/lib/parse/glossary.js
deleted file mode 100644
index 549e9fd..0000000
--- a/lib/parse/glossary.js
+++ /dev/null
@@ -1,48 +0,0 @@
-var _ = require('lodash');
-var kramed = require('kramed');
-
-// Get all the pairs of header + paragraph in a list of nodes
-function groups(nodes) {
- // A list of next nodes
- var next = nodes.slice(1).concat(null);
-
- return _.reduce(nodes, function(accu, node, idx) {
- // Skip
- if(!(
- node.type === 'heading' &&
- (next[idx] && next[idx].type === 'paragraph')
- )) {
- return accu;
- }
-
- // Add group
- accu.push([
- node,
- next[idx]
- ]);
-
- return accu;
- }, []);
-}
-
-function parseGlossary(src) {
- var nodes = kramed.lexer(src);
-
- return groups(nodes)
- .map(function(pair) {
- // Simplify each group to a simple object with name/description
- return {
- name: pair[0].text,
- id: entryId(pair[0].text),
- description: pair[1].text,
- };
- });
-}
-
-// Normalizes a glossary entry's name to create an ID
-function entryId(name) {
- return name.toLowerCase();
-}
-
-module.exports = parseGlossary;
-module.exports.entryId = entryId;