aboutsummaryrefslogtreecommitdiff
path: root/js/lib/blocks.js
blob: 472fa5883ea9627a8383a9b6cb9e1fbd6b976c6b (plain)
  1. "use strict";
  2. var Node = require('./node');
  3. var unescapeString = require('./common').unescapeString;
  4. var C_GREATERTHAN = 62;
  5. var C_NEWLINE = 10;
  6. var C_SPACE = 32;
  7. var C_OPEN_BRACKET = 91;
  8. var CODE_INDENT = 4;
  9. var InlineParser = require('./inlines');
  10. var BLOCKTAGNAME = '(?:article|header|aside|hgroup|iframe|blockquote|hr|body|li|map|button|object|canvas|ol|caption|output|col|p|colgroup|pre|dd|progress|div|section|dl|table|td|dt|tbody|embed|textarea|fieldset|tfoot|figcaption|th|figure|thead|footer|footer|tr|form|ul|h1|h2|h3|h4|h5|h6|video|script|style)';
  11. var HTMLBLOCKOPEN = "<(?:" + BLOCKTAGNAME + "[\\s/>]" + "|" +
  12. "/" + BLOCKTAGNAME + "[\\s>]" + "|" + "[?!])";
  13. var reHtmlBlockOpen = new RegExp('^' + HTMLBLOCKOPEN, 'i');
  14. var reHrule = /^(?:(?:\* *){3,}|(?:_ *){3,}|(?:- *){3,}) *$/;
  15. var reMaybeSpecial = /^[#`~*+_=<>0-9-]/;
  16. var reNonSpace = /[^ \t\n]/;
  17. var reBulletListMarker = /^[*+-]( +|$)/;
  18. var reOrderedListMarker = /^(\d+)([.)])( +|$)/;
  19. var reATXHeaderMarker = /^#{1,6}(?: +|$)/;
  20. var reCodeFence = /^`{3,}(?!.*`)|^~{3,}(?!.*~)/;
  21. var reClosingCodeFence = /^(?:`{3,}|~{3,})(?= *$)/;
  22. var reSetextHeaderLine = /^(?:=+|-+) *$/;
  23. var reLineEnding = /\r\n|\n|\r/;
  24. // Returns true if string contains only space characters.
  25. var isBlank = function(s) {
  26. return !(reNonSpace.test(s));
  27. };
  28. var tabSpaces = [' ', ' ', ' ', ' '];
  29. // Convert tabs to spaces on each line using a 4-space tab stop.
  30. var detabLine = function(text) {
  31. var start = 0;
  32. var offset;
  33. var lastStop = 0;
  34. while ((offset = text.indexOf('\t', start)) !== -1) {
  35. var numspaces = (offset - lastStop) % 4;
  36. var spaces = tabSpaces[numspaces];
  37. text = text.slice(0, offset) + spaces + text.slice(offset + 1);
  38. lastStop = offset + numspaces;
  39. start = lastStop;
  40. }
  41. return text;
  42. };
  43. // Attempt to match a regex in string s at offset offset.
  44. // Return index of match or -1.
  45. var matchAt = function(re, s, offset) {
  46. var res = s.slice(offset).match(re);
  47. if (res === null) {
  48. return -1;
  49. } else {
  50. return offset + res.index;
  51. }
  52. };
  53. // destructively trip final blank lines in an array of strings
  54. var stripFinalBlankLines = function(lns) {
  55. var i = lns.length - 1;
  56. while (!reNonSpace.test(lns[i])) {
  57. lns.pop();
  58. i--;
  59. }
  60. };
  61. // DOC PARSER
  62. // These are methods of a Parser object, defined below.
  63. // Returns true if parent block can contain child block.
  64. var canContain = function(parent_type, child_type) {
  65. return ( parent_type === 'Document' ||
  66. parent_type === 'BlockQuote' ||
  67. parent_type === 'Item' ||
  68. (parent_type === 'List' && child_type === 'Item') );
  69. };
  70. // Returns true if block type can accept lines of text.
  71. var acceptsLines = function(block_type) {
  72. return ( block_type === 'Paragraph' ||
  73. block_type === 'CodeBlock' );
  74. };
  75. // Returns true if block ends with a blank line, descending if needed
  76. // into lists and sublists.
  77. var endsWithBlankLine = function(block) {
  78. while (block) {
  79. if (block._lastLineBlank) {
  80. return true;
  81. }
  82. var t = block.type;
  83. if (t === 'List' || t === 'Item') {
  84. block = block._lastChild;
  85. } else {
  86. break;
  87. }
  88. }
  89. return false;
  90. };
  91. // Break out of all containing lists, resetting the tip of the
  92. // document to the parent of the highest list, and finalizing
  93. // all the lists. (This is used to implement the "two blank lines
  94. // break of of all lists" feature.)
  95. var breakOutOfLists = function(block) {
  96. var b = block;
  97. var last_list = null;
  98. do {
  99. if (b.type === 'List') {
  100. last_list = b;
  101. }
  102. b = b._parent;
  103. } while (b);
  104. if (last_list) {
  105. while (block !== last_list) {
  106. this.finalize(block, this.lineNumber);
  107. block = block._parent;
  108. }
  109. this.finalize(last_list, this.lineNumber);
  110. this.tip = last_list._parent;
  111. }
  112. };
  113. // Add a line to the block at the tip. We assume the tip
  114. // can accept lines -- that check should be done before calling this.
  115. var addLine = function(ln) {
  116. this.tip._strings.push(ln.slice(this.offset));
  117. };
  118. // Add block of type tag as a child of the tip. If the tip can't
  119. // accept children, close and finalize it and try its parent,
  120. // and so on til we find a block that can accept children.
  121. var addChild = function(tag, offset) {
  122. while (!canContain(this.tip.type, tag)) {
  123. this.finalize(this.tip, this.lineNumber - 1);
  124. }
  125. var column_number = offset + 1; // offset 0 = column 1
  126. var newBlock = new Node(tag, [[this.lineNumber, column_number], [0, 0]]);
  127. newBlock._strings = [];
  128. newBlock._string_content = null;
  129. this.tip.appendChild(newBlock);
  130. this.tip = newBlock;
  131. return newBlock;
  132. };
  133. // Parse a list marker and return data on the marker (type,
  134. // start, delimiter, bullet character, padding) or null.
  135. var parseListMarker = function(ln, offset, indent) {
  136. var rest = ln.slice(offset);
  137. var match;
  138. var spaces_after_marker;
  139. var data = { type: null,
  140. tight: true, // lists are tight by default
  141. bulletChar: null,
  142. start: null,
  143. delimiter: null,
  144. padding: null,
  145. markerOffset: indent };
  146. if (rest.match(reHrule)) {
  147. return null;
  148. }
  149. if ((match = rest.match(reBulletListMarker))) {
  150. spaces_after_marker = match[1].length;
  151. data.type = 'Bullet';
  152. data.bulletChar = match[0][0];
  153. } else if ((match = rest.match(reOrderedListMarker))) {
  154. spaces_after_marker = match[3].length;
  155. data.type = 'Ordered';
  156. data.start = parseInt(match[1]);
  157. data.delimiter = match[2];
  158. } else {
  159. return null;
  160. }
  161. var blank_item = match[0].length === rest.length;
  162. if (spaces_after_marker >= 5 ||
  163. spaces_after_marker < 1 ||
  164. blank_item) {
  165. data.padding = match[0].length - spaces_after_marker + 1;
  166. } else {
  167. data.padding = match[0].length;
  168. }
  169. return data;
  170. };
  171. // Returns true if the two list items are of the same type,
  172. // with the same delimiter and bullet character. This is used
  173. // in agglomerating list items into lists.
  174. var listsMatch = function(list_data, item_data) {
  175. return (list_data.type === item_data.type &&
  176. list_data.delimiter === item_data.delimiter &&
  177. list_data.bulletChar === item_data.bulletChar);
  178. };
  179. // Finalize and close any unmatched blocks. Returns true.
  180. var closeUnmatchedBlocks = function() {
  181. // finalize any blocks not matched
  182. while (this.oldtip !== this.lastMatchedContainer) {
  183. var parent = this.oldtip._parent;
  184. this.finalize(this.oldtip, this.lineNumber - 1);
  185. this.oldtip = parent;
  186. }
  187. return true;
  188. };
  189. // 'finalize' is run when the block is closed.
  190. // 'continue' is run to check whether the block is continuing
  191. // at a certain line and offset (e.g. whether a block quote
  192. // contains a `>`. It returns 0 for matched, 1 for not matched,
  193. // and 2 for "we've dealt with this line completely, go to next."
  194. var blocks = {
  195. Document: {
  196. continue: function(parser, container, ln, first_nonspace) {
  197. return 0;
  198. },
  199. finalize: function(parser, block) {
  200. return;
  201. }
  202. },
  203. List: {
  204. continue: function(parser, container, ln, first_nonspace) {
  205. return 0;
  206. },
  207. finalize: function(parser, block) {
  208. var item = block._firstChild;
  209. while (item) {
  210. // check for non-final list item ending with blank line:
  211. if (endsWithBlankLine(item) && item._next) {
  212. block._listData.tight = false;
  213. break;
  214. }
  215. // recurse into children of list item, to see if there are
  216. // spaces between any of them:
  217. var subitem = item._firstChild;
  218. while (subitem) {
  219. if (endsWithBlankLine(subitem) &&
  220. (item._next || subitem._next)) {
  221. block._listData.tight = false;
  222. break;
  223. }
  224. subitem = subitem._next;
  225. }
  226. item = item._next;
  227. }
  228. }
  229. },
  230. BlockQuote: {
  231. continue: function(parser, container, ln, first_nonspace) {
  232. if (first_nonspace - parser.offset <= 3 &&
  233. ln.charCodeAt(first_nonspace) === C_GREATERTHAN) {
  234. parser.offset = first_nonspace + 1;
  235. if (ln.charCodeAt(parser.offset) === C_SPACE) {
  236. parser.offset++;
  237. }
  238. } else {
  239. return 1;
  240. }
  241. return 0;
  242. },
  243. finalize: function(parser, block) {
  244. return;
  245. }
  246. },
  247. Item: {
  248. continue: function(parser, container, ln, first_nonspace) {
  249. if (first_nonspace === ln.length) { // blank
  250. parser.offset = first_nonspace;
  251. } else if (first_nonspace - parser.offset >=
  252. container._listData.markerOffset +
  253. container._listData.padding) {
  254. parser.offset += container._listData.markerOffset +
  255. container._listData.padding;
  256. } else {
  257. return 1;
  258. }
  259. return 0;
  260. },
  261. finalize: function(parser, block) {
  262. return;
  263. }
  264. },
  265. Header: {
  266. continue: function(parser, container, ln, first_nonspace) {
  267. // a header can never container > 1 line, so fail to match:
  268. return 1;
  269. },
  270. finalize: function(parser, block) {
  271. block._string_content = block._strings.join('\n');
  272. }
  273. },
  274. HorizontalRule: {
  275. continue: function(parser, container, ln, first_nonspace) {
  276. // an hrule can never container > 1 line, so fail to match:
  277. return 1;
  278. },
  279. finalize: function(parser, block) {
  280. return;
  281. }
  282. },
  283. CodeBlock: {
  284. continue: function(parser, container, ln, first_nonspace) {
  285. var indent = first_nonspace - parser.offset;
  286. if (container._isFenced) { // fenced
  287. var match = (indent <= 3 &&
  288. ln.charAt(first_nonspace) === container._fenceChar &&
  289. ln.slice(first_nonspace).match(reClosingCodeFence));
  290. if (match && match[0].length >= container._fenceLength) {
  291. // closing fence - we're at end of line, so we can return
  292. parser.finalize(container, parser.lineNumber);
  293. return 2;
  294. } else {
  295. // skip optional spaces of fence offset
  296. var i = container._fenceOffset;
  297. while (i > 0 && ln.charCodeAt(parser.offset) === C_SPACE) {
  298. parser.offset++;
  299. i--;
  300. }
  301. }
  302. } else { // indented
  303. if (indent >= CODE_INDENT) {
  304. parser.offset += CODE_INDENT;
  305. } else if (first_nonspace === ln.length) { // blank
  306. parser.offset = first_nonspace;
  307. } else {
  308. return 1;
  309. }
  310. }
  311. return 0;
  312. },
  313. finalize: function(parser, block) {
  314. if (block._isFenced) { // fenced
  315. // first line becomes info string
  316. block.info = unescapeString(block._strings[0].trim());
  317. if (block._strings.length === 1) {
  318. block._literal = '';
  319. } else {
  320. block._literal = block._strings.slice(1).join('\n') + '\n';
  321. }
  322. } else { // indented
  323. stripFinalBlankLines(block._strings);
  324. block._literal = block._strings.join('\n') + '\n';
  325. }
  326. }
  327. },
  328. HtmlBlock: {
  329. continue: function(parser, container, ln, first_nonspace) {
  330. return (first_nonspace === ln.length ? 1 : 0);
  331. },
  332. finalize: function(parser, block) {
  333. block._literal = block._strings.join('\n');
  334. }
  335. },
  336. Paragraph: {
  337. continue: function(parser, container, ln, first_nonspace) {
  338. return (first_nonspace === ln.length ? 1 : 0);
  339. },
  340. finalize: function(parser, block) {
  341. var pos;
  342. block._string_content = block._strings.join('\n');
  343. // try parsing the beginning as link reference definitions:
  344. while (block._string_content.charCodeAt(0) === C_OPEN_BRACKET &&
  345. (pos =
  346. parser.inlineParser.parseReference(block._string_content,
  347. parser.refmap))) {
  348. block._string_content = block._string_content.slice(pos);
  349. if (isBlank(block._string_content)) {
  350. block.unlink();
  351. break;
  352. }
  353. }
  354. }
  355. }
  356. };
  357. // Analyze a line of text and update the document appropriately.
  358. // We parse markdown text by calling this on each line of input,
  359. // then finalizing the document.
  360. var incorporateLine = function(ln) {
  361. var all_matched = true;
  362. var first_nonspace;
  363. var match;
  364. var data;
  365. var blank;
  366. var indent;
  367. var i;
  368. var allClosed;
  369. var container = this.doc;
  370. this.oldtip = this.tip;
  371. this.offset = 0;
  372. this.lineNumber += 1;
  373. // replace NUL characters for security
  374. if (ln.indexOf('\u0000') !== -1) {
  375. ln = ln.replace(/\0/g, '\uFFFD');
  376. }
  377. // Convert tabs to spaces:
  378. ln = detabLine(ln);
  379. // For each containing block, try to parse the associated line start.
  380. // Bail out on failure: container will point to the last matching block.
  381. // Set all_matched to false if not all containers match.
  382. var lastChild;
  383. while ((lastChild = container._lastChild) && lastChild._open) {
  384. container = lastChild;
  385. match = matchAt(reNonSpace, ln, this.offset);
  386. if (match === -1) {
  387. first_nonspace = ln.length;
  388. } else {
  389. first_nonspace = match;
  390. }
  391. switch (this.blocks[container.type].continue(this, container, ln, first_nonspace)) {
  392. case 0: // we've matched, keep going
  393. break;
  394. case 1: // we've failed to match a block
  395. all_matched = false;
  396. break;
  397. case 2: // we've hit end of line for fenced code close and can return
  398. return;
  399. default:
  400. throw 'continue returned illegal value, must be 0, 1, or 2';
  401. }
  402. if (!all_matched) {
  403. container = container._parent; // back up to last matching block
  404. break;
  405. }
  406. }
  407. blank = first_nonspace === ln.length;
  408. allClosed = (container === this.oldtip);
  409. this.lastMatchedContainer = container;
  410. // Check to see if we've hit 2nd blank line; if so break out of list:
  411. if (blank && container._lastLineBlank) {
  412. this.breakOutOfLists(container);
  413. }
  414. // Unless last matched container is a code block, try new container starts,
  415. // adding children to the last matched container:
  416. while (true) {
  417. var t = container.type;
  418. match = matchAt(reNonSpace, ln, this.offset);
  419. if (match === -1) {
  420. first_nonspace = ln.length;
  421. blank = true;
  422. break;
  423. } else {
  424. first_nonspace = match;
  425. blank = false;
  426. }
  427. indent = first_nonspace - this.offset;
  428. if (t === 'CodeBlock' || t === 'HtmlBlock') {
  429. break;
  430. }
  431. if (indent >= CODE_INDENT) {
  432. // indented code
  433. if (this.tip.type !== 'Paragraph' && !blank) {
  434. this.offset += CODE_INDENT;
  435. allClosed = allClosed ||
  436. this.closeUnmatchedBlocks();
  437. container = this.addChild('CodeBlock', this.offset);
  438. }
  439. break;
  440. }
  441. // this is a little performance optimization:
  442. if (matchAt(reMaybeSpecial, ln, first_nonspace) === -1) {
  443. break;
  444. }
  445. this.offset = first_nonspace;
  446. var cc = ln.charCodeAt(this.offset);
  447. if (cc === C_GREATERTHAN) {
  448. // blockquote
  449. this.offset += 1;
  450. // optional following space
  451. if (ln.charCodeAt(this.offset) === C_SPACE) {
  452. this.offset++;
  453. }
  454. allClosed = allClosed || this.closeUnmatchedBlocks();
  455. container = this.addChild('BlockQuote', first_nonspace);
  456. } else if ((match = ln.slice(this.offset).match(reATXHeaderMarker))) {
  457. // ATX header
  458. this.offset += match[0].length;
  459. allClosed = allClosed || this.closeUnmatchedBlocks();
  460. container = this.addChild('Header', first_nonspace);
  461. container.level = match[0].trim().length; // number of #s
  462. // remove trailing ###s:
  463. container._strings =
  464. [ln.slice(this.offset).replace(/^ *#+ *$/, '').replace(/ +#+ *$/, '')];
  465. break;
  466. } else if ((match = ln.slice(this.offset).match(reCodeFence))) {
  467. // fenced code block
  468. var fenceLength = match[0].length;
  469. allClosed = allClosed || this.closeUnmatchedBlocks();
  470. container = this.addChild('CodeBlock', first_nonspace);
  471. container._isFenced = true;
  472. container._fenceLength = fenceLength;
  473. container._fenceChar = match[0][0];
  474. container._fenceOffset = indent;
  475. this.offset += fenceLength;
  476. } else if (matchAt(reHtmlBlockOpen, ln, this.offset) !== -1) {
  477. // html block
  478. allClosed = allClosed || this.closeUnmatchedBlocks();
  479. container = this.addChild('HtmlBlock', this.offset);
  480. this.offset -= indent; // back up so spaces are part of block
  481. break;
  482. } else if (t === 'Paragraph' &&
  483. container._strings.length === 1 &&
  484. ((match = ln.slice(this.offset).match(reSetextHeaderLine)))) {
  485. // setext header line
  486. allClosed = allClosed || this.closeUnmatchedBlocks();
  487. var header = new Node('Header', container.sourcepos);
  488. header.level = match[0][0] === '=' ? 1 : 2;
  489. header._strings = container._strings;
  490. container.insertAfter(header);
  491. container.unlink();
  492. container = header;
  493. this.tip = header;
  494. this.offset = ln.length;
  495. break;
  496. } else if (matchAt(reHrule, ln, this.offset) !== -1) {
  497. // hrule
  498. allClosed = allClosed || this.closeUnmatchedBlocks();
  499. container = this.addChild('HorizontalRule', first_nonspace);
  500. this.offset = ln.length - 1;
  501. break;
  502. } else if ((data = parseListMarker(ln, this.offset, indent))) {
  503. // list item
  504. allClosed = allClosed || this.closeUnmatchedBlocks();
  505. this.offset += data.padding;
  506. // add the list if needed
  507. if (t !== 'List' ||
  508. !(listsMatch(container._listData, data))) {
  509. container = this.addChild('List', first_nonspace);
  510. container._listData = data;
  511. }
  512. // add the list item
  513. container = this.addChild('Item', first_nonspace);
  514. container._listData = data;
  515. } else {
  516. break;
  517. }
  518. }
  519. // What remains at the offset is a text line. Add the text to the
  520. // appropriate container.
  521. // First check for a lazy paragraph continuation:
  522. if (!allClosed && !blank &&
  523. this.tip.type === 'Paragraph' &&
  524. this.tip._strings.length > 0) {
  525. // lazy paragraph continuation
  526. this.addLine(ln);
  527. } else { // not a lazy continuation
  528. // finalize any blocks not matched
  529. allClosed = allClosed || this.closeUnmatchedBlocks();
  530. if (blank && container.lastChild) {
  531. container.lastChild._lastLineBlank = true;
  532. }
  533. t = container.type;
  534. // Block quote lines are never blank as they start with >
  535. // and we don't count blanks in fenced code for purposes of tight/loose
  536. // lists or breaking out of lists. We also don't set _lastLineBlank
  537. // on an empty list item, or if we just closed a fenced block.
  538. var lastLineBlank = blank &&
  539. !(t === 'BlockQuote' ||
  540. (t === 'CodeBlock' && container._isFenced) ||
  541. (t === 'Item' &&
  542. !container._firstChild &&
  543. container.sourcepos[0][0] === this.lineNumber));
  544. // propagate lastLineBlank up through parents:
  545. var cont = container;
  546. while (cont) {
  547. cont._lastLineBlank = lastLineBlank;
  548. cont = cont._parent;
  549. }
  550. switch (t) {
  551. case 'HtmlBlock':
  552. case 'CodeBlock':
  553. this.addLine(ln);
  554. break;
  555. case 'Header':
  556. case 'HorizontalRule':
  557. // nothing to do; we already added the contents.
  558. break;
  559. default:
  560. this.offset = first_nonspace;
  561. if (acceptsLines(t)) {
  562. this.addLine(ln);
  563. } else if (blank) {
  564. break;
  565. } else {
  566. // create paragraph container for line
  567. container = this.addChild('Paragraph', this.offset);
  568. this.addLine(ln);
  569. }
  570. }
  571. }
  572. this.lastLineLength = ln.length - 1; // -1 for newline
  573. };
  574. // Finalize a block. Close it and do any necessary postprocessing,
  575. // e.g. creating string_content from strings, setting the 'tight'
  576. // or 'loose' status of a list, and parsing the beginnings
  577. // of paragraphs for reference definitions. Reset the tip to the
  578. // parent of the closed block.
  579. var finalize = function(block, lineNumber) {
  580. var above = block._parent || this.top;
  581. block._open = false;
  582. block.sourcepos[1] = [lineNumber, this.lastLineLength + 1];
  583. this.blocks[block.type].finalize(this, block);
  584. this.tip = above;
  585. };
  586. // Walk through a block & children recursively, parsing string content
  587. // into inline content where appropriate. Returns new object.
  588. var processInlines = function(block) {
  589. var node, event, t;
  590. var walker = block.walker();
  591. while ((event = walker.next())) {
  592. node = event.node;
  593. t = node.type;
  594. if (!event.entering && (t === 'Paragraph' || t === 'Header')) {
  595. this.inlineParser.parse(node, this.refmap);
  596. }
  597. }
  598. };
  599. var Document = function() {
  600. var doc = new Node('Document', [[1, 1], [0, 0]]);
  601. doc._string_content = null;
  602. doc._strings = [];
  603. return doc;
  604. };
  605. // The main parsing function. Returns a parsed document AST.
  606. var parse = function(input) {
  607. this.doc = new Document();
  608. this.tip = this.doc;
  609. this.refmap = {};
  610. if (this.options.time) { console.time("preparing input"); }
  611. var lines = input.split(reLineEnding);
  612. var len = lines.length;
  613. if (input.charCodeAt(input.length - 1) === C_NEWLINE) {
  614. // ignore last blank line created by final newline
  615. len -= 1;
  616. }
  617. if (this.options.time) { console.timeEnd("preparing input"); }
  618. if (this.options.time) { console.time("block parsing"); }
  619. for (var i = 0; i < len; i++) {
  620. this.incorporateLine(lines[i]);
  621. }
  622. while (this.tip) {
  623. this.finalize(this.tip, len);
  624. }
  625. if (this.options.time) { console.timeEnd("block parsing"); }
  626. if (this.options.time) { console.time("inline parsing"); }
  627. this.processInlines(this.doc);
  628. if (this.options.time) { console.timeEnd("inline parsing"); }
  629. return this.doc;
  630. };
  631. // The Parser object.
  632. function Parser(options){
  633. return {
  634. doc: new Document(),
  635. blocks: blocks,
  636. tip: this.doc,
  637. oldtip: this.doc,
  638. lineNumber: 0,
  639. offset: 0,
  640. lastMatchedContainer: this.doc,
  641. refmap: {},
  642. lastLineLength: 0,
  643. inlineParser: new InlineParser(),
  644. breakOutOfLists: breakOutOfLists,
  645. addLine: addLine,
  646. addChild: addChild,
  647. incorporateLine: incorporateLine,
  648. finalize: finalize,
  649. processInlines: processInlines,
  650. closeUnmatchedBlocks: closeUnmatchedBlocks,
  651. parse: parse,
  652. options: options || {}
  653. };
  654. }
  655. module.exports = Parser;