diff options
author | Johan Preynat <johan.preynat@gmail.com> | 2016-04-13 16:00:16 +0200 |
---|---|---|
committer | Johan Preynat <johan.preynat@gmail.com> | 2016-04-13 16:00:16 +0200 |
commit | ef2a24fe6f76e9c1995bcbef8c331d51d00a490b (patch) | |
tree | 30002ba95be3f2fe5621d9c370f26b5a78dc0494 /lib/page/html.js | |
parent | 038cd0155bcf1920d5bac65970698c2ce6e1593b (diff) | |
download | gitbook-ef2a24fe6f76e9c1995bcbef8c331d51d00a490b.zip gitbook-ef2a24fe6f76e9c1995bcbef8c331d51d00a490b.tar.gz gitbook-ef2a24fe6f76e9c1995bcbef8c331d51d00a490b.tar.bz2 |
Add trailing dots to page.description when longer than 300 characters
Diffstat (limited to 'lib/page/html.js')
-rw-r--r-- | lib/page/html.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/page/html.js b/lib/page/html.js index 329b626..5a13dcf 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); }; |