Sha256: f276da49bf45db5795ad32dfc772227d5a3b37e50f88afc6f4ea8748291f001a

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 Bytes

Contents

const { spawnSync } = require("child_process");
const path = require("path");

const parser = path.join(__dirname, "./parser.rb");

const parse = (text, _parsers, _opts) => {
  const child = spawnSync("ruby", [parser], { input: text });

  const error = child.stderr.toString();
  if (error) {
    throw new Error(error);
  }

  const response = child.stdout.toString();
  return JSON.parse(response);
};

const pragmaPattern = /^\s*-#\s*@(prettier|format)/;
const hasPragma = (text) => pragmaPattern.test(text);

// These functions are just placeholders until we can actually perform this
// properly. The functions are necessary otherwise the format with cursor
// functions break.
const locStart = (_node) => 0;
const locEnd = (_node) => 0;

module.exports = {
  parse,
  astFormat: "haml",
  hasPragma,
  locStart,
  locEnd
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prettier-1.3.0 src/haml/parser.js