From ef2a24fe6f76e9c1995bcbef8c331d51d00a490b Mon Sep 17 00:00:00 2001 From: Johan Preynat Date: Wed, 13 Apr 2016 16:00:16 +0200 Subject: [PATCH] Add trailing dots to page.description when longer than 300 characters --- lib/page/html.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/page/html.js b/lib/page/html.js index 329b6269f..5a13dcf90 100644 --- a/lib/page/html.js +++ b/lib/page/html.js @@ -185,7 +185,11 @@ HTMLPipeline.prototype.applyAnnotations = function() { // This can totally be improved HTMLPipeline.prototype.extractDescription = function() { var $p = this.$('p'); - var description = $p.text().trim().slice(0, 300); + + var description = $p.text().trim(); + if (description.length > 300) { + description = description.slice(0, 300).trim()+'...'; + } this.opts.onDescription(description); };