Skip to content

Commit

Permalink
WIP: Move properties to prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Sep 28, 2015
1 parent 1d567e7 commit 3d4c80f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
29 changes: 15 additions & 14 deletions lib/rules_block/state_block.js
Expand Up @@ -27,20 +27,6 @@ function StateBlock(src, md, env, tokens) {
this.tShift = []; // offsets of the first non-space characters (tabs not expanded)
this.sCount = []; // indents for each line (tabs expanded)

// block parser variables
this.blkIndent = 0; // required block content indent
// (for example, if we are in list)
this.line = 0; // line index in src
this.lineMax = 0; // lines count
this.tight = false; // loose/tight mode for lists
this.parentType = 'root'; // if `list`, block parser stops on two newlines
this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)

this.level = 0;

// renderer
this.result = '';

// Create caches
// Generate markers.
s = this.src;
Expand Down Expand Up @@ -87,6 +73,21 @@ function StateBlock(src, md, env, tokens) {
this.lineMax = this.bMarks.length - 1; // don't count last fake line
}

// block parser variables
StateBlock.prototype.blkIndent = 0; // required block content indent
// (for example, if we are in list)
StateBlock.prototype.line = 0; // line index in src
StateBlock.prototype.lineMax = 0; // lines count
StateBlock.prototype.tight = false; // loose/tight mode for lists
StateBlock.prototype.parentType = 'root'; // if `list`, block parser stops on two newlines
StateBlock.prototype.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)

StateBlock.prototype.level = 0;

// renderer
StateBlock.prototype.result = '';


// Push new token to "stream".
//
StateBlock.prototype.push = function (type, tag, nesting) {
Expand Down
10 changes: 6 additions & 4 deletions lib/rules_inline/state_inline.js
Expand Up @@ -11,17 +11,19 @@ function StateInline(src, md, env, outTokens) {
this.md = md;
this.tokens = outTokens;

this.pos = 0;
this.posMax = this.src.length;
this.level = 0;
this.pending = '';
this.pendingLevel = 0;

this.cache = {}; // Stores { start: end } pairs. Useful for backtrack
// optimization of pairs parse (emphasis, strikes).
}


StateInline.prototype.pos = 0;
StateInline.prototype.level = '';
StateInline.prototype.pending = '';
StateInline.prototype.pendingLevel = 0;


// Flush pending text
//
StateInline.prototype.pushPending = function () {
Expand Down

0 comments on commit 3d4c80f

Please sign in to comment.