summaryrefslogtreecommitdiffstats
path: root/lib/page/html.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/page/html.js')
-rw-r--r--lib/page/html.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/page/html.js b/lib/page/html.js
index bd9ec91..bce6cd2 100644
--- a/lib/page/html.js
+++ b/lib/page/html.js
@@ -14,6 +14,9 @@ function HTMLPipeline(htmlString, opts) {
_.bindAll(this);
this.opts = _.defaults(opts || {}, {
+ // Called once the description has been found
+ onDescription: function(description) { },
+
// Calcul new href for a relative link
onRelativeLink: _.identity,
@@ -178,11 +181,21 @@ HTMLPipeline.prototype.applyAnnotations = function() {
});
};
+// Extract page description from html
+// This can totally be improved
+HTMLPipeline.prototype.extractDescription = function() {
+ var $p = this.$('p').first();
+ var description = $p.text().trim().slice(0, 155);
+
+ this.opts.onDescription(description);
+};
+
// Write content to the pipeline
HTMLPipeline.prototype.output = function() {
var that = this;
return Promise()
+ .then(this.extractDescription)
.then(this.transformImages)
.then(this.transformHeadings)
.then(this.transformCodeBlocks)