check for parseTags in wrapContent. recenter shrunken elements.
This commit is contained in:
parent
dc623ee0d1
commit
8a39e9aaf4
|
@ -833,7 +833,7 @@ Element.prototype.parseContent = function() {
|
|||
if (this._clines == null
|
||||
|| this._clines.width !== w
|
||||
|| this._clines.content !== this.content) {
|
||||
this._clines = wrapContent(this.content, w, this.align);
|
||||
this._clines = wrapContent(this.content, w, this.parseTags, this.align);
|
||||
this._pcontent = this._clines.join('\n');
|
||||
this.emit('parsed content');
|
||||
return true;
|
||||
|
@ -1299,7 +1299,9 @@ Box.prototype.render = function(stop) {
|
|||
if (this.shrink) {
|
||||
var hw = this._getShrinkSize(content)
|
||||
, h = hw.height
|
||||
, w = hw.width;
|
||||
, w = hw.width
|
||||
, xll = xl
|
||||
, yll = yl;
|
||||
if (this.options.width == null
|
||||
&& (this.options.left == null
|
||||
|| this.options.right == null)) {
|
||||
|
@ -1321,6 +1323,17 @@ Box.prototype.render = function(stop) {
|
|||
yl = yi_ + h + (this.border ? 2 : 0) + this.padding;
|
||||
}
|
||||
}
|
||||
// Recenter shrunken elements.
|
||||
if (xl < xll && this.options.left === 'center') {
|
||||
xll = (xll - xl) / 2 | 0;
|
||||
xi_ += xll;
|
||||
xl += xll;
|
||||
}
|
||||
if (yl < yll && this.options.top === 'center') {
|
||||
yll = (yll - yl) / 2 | 0;
|
||||
yi_ += yll;
|
||||
yl += yll;
|
||||
}
|
||||
}
|
||||
|
||||
var ret = this._lastPos = {
|
||||
|
@ -2348,7 +2361,7 @@ function sp(line, width, align) {
|
|||
return line;
|
||||
}
|
||||
|
||||
function wrapContent(content, width, state) {
|
||||
function wrapContent(content, width, tags, state) {
|
||||
var lines = content.split('\n')
|
||||
, out = [];
|
||||
|
||||
|
@ -2363,15 +2376,19 @@ function wrapContent(content, width, state) {
|
|||
var align = state
|
||||
, cap;
|
||||
|
||||
if (cap = /^{(center|right)}/.exec(line)) {
|
||||
if (tags) {
|
||||
if (cap = /^{(left|center|right)}/.exec(line)) {
|
||||
line = line.substring(cap[0].length);
|
||||
align = state = cap[1];
|
||||
align = state = cap[1] !== 'left'
|
||||
? cap[1]
|
||||
: null;
|
||||
}
|
||||
|
||||
if (cap = /{\/(center|right)}$/.exec(line)) {
|
||||
if (cap = /{\/(left|center|right)}$/.exec(line)) {
|
||||
line = line.slice(0, -cap[0].length);
|
||||
state = null;
|
||||
}
|
||||
}
|
||||
|
||||
var total
|
||||
, i
|
||||
|
|
Loading…
Reference in New Issue