|
|
@ -9,17 +9,17 @@ var assign = require('object-assign'); |
|
|
|
var Renderer = require('./renderer'); |
|
|
|
var LexerBlock = require('./lexer_block'); |
|
|
|
var LexerInline = require('./lexer_inline'); |
|
|
|
|
|
|
|
var defaults = require('./defaults'); |
|
|
|
|
|
|
|
// Main class
|
|
|
|
//
|
|
|
|
function Parser(options) { |
|
|
|
this.options = {}; |
|
|
|
this.state = null; |
|
|
|
this.options = assign({}, defaults); |
|
|
|
this.state = null; |
|
|
|
|
|
|
|
this.lexerInline = new LexerInline(); |
|
|
|
this.lexerBlock = new LexerBlock(); |
|
|
|
this.renderer = new Renderer(); |
|
|
|
this.inline = new LexerInline(); |
|
|
|
this.block = new LexerBlock(); |
|
|
|
this.renderer = new Renderer(); |
|
|
|
|
|
|
|
if (options) { this.set(options); } |
|
|
|
} |
|
|
@ -34,13 +34,13 @@ Parser.prototype.render = function (src) { |
|
|
|
var tokens, tok, i, l; |
|
|
|
|
|
|
|
// Parse blocks
|
|
|
|
tokens = this.lexerBlock.parse(src, this.options); |
|
|
|
tokens = this.block.parse(src, this.options); |
|
|
|
|
|
|
|
// Parse inlines
|
|
|
|
for (i = 0, l = tokens.length; i < l; i++) { |
|
|
|
tok = tokens[i]; |
|
|
|
if (tok.type === 'inline') { |
|
|
|
tok.children = this.lexerInline.parse(tok.content, this.options); |
|
|
|
tok.children = this.inline.parse(tok.content, this.options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|