Glossary should be output as a normal page

This commit is contained in:
Samy Pessé
2016-02-18 13:58:10 +01:00
parent 202c235c66
commit 6e83240233
4 changed files with 24 additions and 9 deletions
+21
View File
@@ -44,6 +44,15 @@ util.inherits(Glossary, BackboneFile);
Glossary.prototype.type = 'glossary';
// Get templating context
Glossary.prototype.getContext = function() {
return {
glossary: {
path: this.path
}
};
};
// Parse the readme content
Glossary.prototype.parse = function(content) {
var that = this;
@@ -73,4 +82,16 @@ Glossary.prototype.isEmpty = function(id) {
return _.size(this.entries) === 0;
};
// Convert the glossary to a list of annotations
Glossary.prototype.annotations = function() {
return _.map(this.entries, function(entry) {
return {
id: entry.id,
name: entry.name,
description: entry.description,
href: '/' + this.path + '#' + entry.id
};
}, this);
};
module.exports = Glossary;
+1
View File
@@ -169,6 +169,7 @@ Output.prototype.getPageContext = function(page) {
gitbook.getContext(),
this.book.getContext(),
this.book.summary.getContext(),
this.book.glossary.getContext(),
this.book.config.getContext()
);
};
+1 -1
View File
@@ -164,7 +164,7 @@ HTMLPipeline.prototype.applyAnnotations = function() {
replaceText(that.$, this, searchRegex, function(match) {
that.opts.onAnnotation(annotation);
return '<a href="'+that.opts.onRelativeLink(annotation.href) + '#' + annotation.id+'" '
return '<a href="' + that.opts.onRelativeLink(annotation.href) + '" '
+ 'class="glossary-term" title="'+_.escape(annotation.description)+'">'
+ match
+ '</a>';
+1 -8
View File
@@ -166,14 +166,7 @@ Page.prototype.toHTML = function(output) {
},
// Convert glossary entries to annotations
annotations: _.map(that.book.glossary.entries, function(entry) {
return {
id: entry.id,
name: entry.name,
description: entry.description,
href: '/GLOSSARY.html'
};
})
annotations: that.book.glosary.annotations()
};
var pipeline = new HTMLPipeline(that.content, pipelineOpts);