Sha256: 49f633f00ac0fcc78d3b575833b989bf3525197b084dd83af4a7702f8dd81052

Contents?: true

Size: 900 Bytes

Versions: 23

Compression:

Stored size: 900 Bytes

Contents

'use strict'

var xtend = require('xtend')
var removePosition = require('unist-util-remove-position')

module.exports = parse

var lineFeed = '\n'
var lineBreaksExpression = /\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(lineBreaksExpression, lineFeed)

  // BOM.
  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
}

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/remark-parse/lib/parse.js
trusty-cms-5.0.6 node_modules/remark-parse/lib/parse.js
trusty-cms-5.0.5 node_modules/remark-parse/lib/parse.js
trusty-cms-5.0.4 node_modules/remark-parse/lib/parse.js
trusty-cms-5.0.3 node_modules/remark-parse/lib/parse.js
trusty-cms-5.0.2 node_modules/remark-parse/lib/parse.js
trusty-cms-5.0.1 node_modules/remark-parse/lib/parse.js
trusty-cms-4.3.5 node_modules/remark-parse/lib/parse.js
trusty-cms-5.0.0 node_modules/remark-parse/lib/parse.js
trusty-cms-4.3.4 node_modules/remark-parse/lib/parse.js
trusty-cms-4.3.3 node_modules/remark-parse/lib/parse.js
trusty-cms-4.3.2 node_modules/remark-parse/lib/parse.js
trusty-cms-4.3.1 node_modules/remark-parse/lib/parse.js
trusty-cms-4.3 node_modules/remark-parse/lib/parse.js
trusty-cms-4.2.3 node_modules/remark-parse/lib/parse.js
trusty-cms-4.2.2 node_modules/remark-parse/lib/parse.js
trusty-cms-4.2.1 node_modules/remark-parse/lib/parse.js
trusty-cms-4.2 node_modules/remark-parse/lib/parse.js
trusty-cms-4.1.9 node_modules/remark-parse/lib/parse.js
trusty-cms-4.1.8 node_modules/remark-parse/lib/parse.js