summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js')
-rw-r--r--tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js
new file mode 100644
index 0000000000..53a50b181e
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js
@@ -0,0 +1,53 @@
+/**
+ * @author Titus Wormer
+ * @copyright 2015 Titus Wormer
+ * @license MIT
+ * @module remark:parse:parse
+ * @fileoverview Parse the document
+ */
+
+'use strict';
+
+var xtend = require('xtend');
+var removePosition = require('unist-util-remove-position');
+
+module.exports = parse;
+
+var C_NEWLINE = '\n';
+var EXPRESSION_LINE_BREAKS = /\r\n|\r/g;
+
+/* Parse the bound file. */
+function parse() {
+ var self = this;
+ var value = String(self.file);
+ var start = {line: 1, column: 1, offset: 0};
+ var content = xtend(start);
+ var node;
+
+ /* Clean non-unix newlines: `\r\n` and `\r` are all
+ * changed to `\n`. This should not affect positional
+ * information. */
+ value = value.replace(EXPRESSION_LINE_BREAKS, C_NEWLINE);
+
+ if (value.charCodeAt(0) === 0xFEFF) {
+ value = value.slice(1);
+
+ content.column++;
+ content.offset++;
+ }
+
+ node = {
+ type: 'root',
+ children: self.tokenizeBlock(value, content),
+ position: {
+ start: start,
+ end: self.eof || xtend(start)
+ }
+ };
+
+ if (!self.options.position) {
+ removePosition(node, true);
+ }
+
+ return node;
+}