.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / remark-parse / lib / parse.js
1 'use strict';
2
3 var xtend = require('xtend');
4 var removePosition = require('unist-util-remove-position');
5
6 module.exports = parse;
7
8 var C_NEWLINE = '\n';
9 var EXPRESSION_LINE_BREAKS = /\r\n|\r/g;
10
11 /* Parse the bound file. */
12 function parse() {
13   var self = this;
14   var value = String(self.file);
15   var start = {line: 1, column: 1, offset: 0};
16   var content = xtend(start);
17   var node;
18
19   /* Clean non-unix newlines: `\r\n` and `\r` are all
20    * changed to `\n`.  This should not affect positional
21    * information. */
22   value = value.replace(EXPRESSION_LINE_BREAKS, C_NEWLINE);
23
24   if (value.charCodeAt(0) === 0xFEFF) {
25     value = value.slice(1);
26
27     content.column++;
28     content.offset++;
29   }
30
31   node = {
32     type: 'root',
33     children: self.tokenizeBlock(value, content),
34     position: {
35       start: start,
36       end: self.eof || xtend(start)
37     }
38   };
39
40   if (!self.options.position) {
41     removePosition(node, true);
42   }
43
44   return node;
45 }