diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-18 17:50:10 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-18 17:50:10 +0100 |
commit | 3d3302e547929a4f728aefa89ad7634f234fa726 (patch) | |
tree | b6961ce750ea9dc1c6ffea36e3054047238f8d54 /lib | |
parent | 95d81d02a12dc6ae5e9d845e2eb69b7e1dc1debd (diff) | |
download | gitbook-3d3302e547929a4f728aefa89ad7634f234fa726.zip gitbook-3d3302e547929a4f728aefa89ad7634f234fa726.tar.gz gitbook-3d3302e547929a4f728aefa89ad7634f234fa726.tar.bz2 |
Add detection of text direction and provide: 'page.dir'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/page/index.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/page/index.js b/lib/page/index.js index bc12529..d8b5fff 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -1,6 +1,7 @@ var _ = require('lodash'); var path = require('path'); var parsers = require('gitbook-parsers'); +var direction = require('direction'); var error = require('../utils/error'); var pathUtil = require('../utils/path'); @@ -101,6 +102,13 @@ Page.prototype.getContext = function() { var next = article? article.next() : null; var prev = article? article.prev() : null; + // Detect text direction in this page + var dir = this.book.config.get('direction'); + if (!dir) { + dir = direction(this.content); + if (dir == 'neutral') dir = null; + } + return { file: { path: this.path, @@ -112,7 +120,8 @@ Page.prototype.getContext = function() { next: next? next.getContext() : null, previous: prev? prev.getContext() : null, level: article? article.level : null, - content: this.content + content: this.content, + dir: dir } }; }; |