From 3dc30632755713179f345f4af024bd904c6162d0 Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Fri, 22 Dec 2017 16:53:42 +0100 Subject: tools: move eslint from tools to tools/node_modules This is required because we need to add the babel-eslint dependency and it has to be able to resolve "eslint". babel-eslint is required to support future ES features such as async iterators and import.meta. Refs: https://github.com/nodejs/node/pull/17755 PR-URL: https://github.com/nodejs/node/pull/17820 Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum --- .../remark-parse/lib/tokenize/heading-atx.js | 150 +++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js (limited to 'tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js') diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js new file mode 100644 index 0000000000..e5fdedc537 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js @@ -0,0 +1,150 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module remark:parse:tokenize:heading-atx + * @fileoverview Tokenise an ATX-style heading. + */ + +'use strict'; + +module.exports = atxHeading; + +var C_NEWLINE = '\n'; +var C_TAB = '\t'; +var C_SPACE = ' '; +var C_HASH = '#'; + +var MAX_ATX_COUNT = 6; + +/* Tokenise an ATX-style heading. */ +function atxHeading(eat, value, silent) { + var self = this; + var settings = self.options; + var length = value.length + 1; + var index = -1; + var now = eat.now(); + var subvalue = ''; + var content = ''; + var character; + var queue; + var depth; + + /* Eat initial spacing. */ + while (++index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + index--; + break; + } + + subvalue += character; + } + + /* Eat hashes. */ + depth = 0; + + while (++index <= length) { + character = value.charAt(index); + + if (character !== C_HASH) { + index--; + break; + } + + subvalue += character; + depth++; + } + + if (depth > MAX_ATX_COUNT) { + return; + } + + if ( + !depth || + (!settings.pedantic && value.charAt(index + 1) === C_HASH) + ) { + return; + } + + length = value.length + 1; + + /* Eat intermediate white-space. */ + queue = ''; + + while (++index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + index--; + break; + } + + queue += character; + } + + /* Exit when not in pedantic mode without spacing. */ + if ( + !settings.pedantic && + queue.length === 0 && + character && + character !== C_NEWLINE + ) { + return; + } + + if (silent) { + return true; + } + + /* Eat content. */ + subvalue += queue; + queue = ''; + content = ''; + + while (++index < length) { + character = value.charAt(index); + + if (!character || character === C_NEWLINE) { + break; + } + + if ( + character !== C_SPACE && + character !== C_TAB && + character !== C_HASH + ) { + content += queue + character; + queue = ''; + continue; + } + + while (character === C_SPACE || character === C_TAB) { + queue += character; + character = value.charAt(++index); + } + + while (character === C_HASH) { + queue += character; + character = value.charAt(++index); + } + + while (character === C_SPACE || character === C_TAB) { + queue += character; + character = value.charAt(++index); + } + + index--; + } + + now.column += subvalue.length; + now.offset += subvalue.length; + subvalue += content + queue; + + return eat(subvalue)({ + type: 'heading', + depth: depth, + children: self.tokenizeInline(content, now) + }); +} -- cgit v1.2.3