Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified file reading to fix (hopefully) newline selector issues

  • Loading branch information...
commit 3333498b271ec07532a305aaf18fc2bead0fc1c9 1 parent 91b357f
@bmavity authored
View
1  .gitignore
@@ -1,2 +1,3 @@
*.swp
.DS_Store
+node_modules
View
3  package.json
@@ -1,12 +1,11 @@
{
"name": "scss",
"description": "JavaScript Implementation of SCSS (Sassy CSS)",
- "version": "0.2.0",
+ "version": "0.2.1",
"contributors": [
{ "name": "Brian Mavity", "email": "brian@brianmavity.com" }
],
"main": "./src/index.js",
- "directories": { "lib": "./src" },
"engines": { "node": ">= 0.2.0" },
"dependencies": {
"ometa": "0.2.1"
View
2  specs/cssSelectorSpecs.js
@@ -1,4 +1,4 @@
-var vows = require('vows'),
+var vows = require('vows'),
assert = require('assert'),
selectorGrammar = require(__dirname + '/grammarInvoker');
View
20 specs/grammarInvoker.js
@@ -3,14 +3,19 @@ var sys = require('sys'),
ometa = require('ometa'),
creatingParser = false;
+var fixReadFile = function(rawFile) {
+ return rawFile.slice(1).replace(/\\n/g, '\n');
+};
+
var createParser = function(parserInitializer) {
if(!creatingParser) {
creatingParser = true;
- fs.readFile(__dirname + '/../src/cssSelector.ometa', function(err, contents) {
+ //fs.readFile(__dirname + '/../src/cssSelector.ometa', 'utf8', function(err, contents) {
+ fs.readFile(__dirname + '/../../ometa-js/newLineGrammar.ometa', 'utf8', function(err, contents) {
if(err) {
parserInitializer.setParser(err);
} else {
- ometa.createParser(contents.toString(), parserInitializer.setParser);
+ ometa.createParser(fixReadFile(contents), parserInitializer.setParser);
}
creatingParser = false;
});
@@ -57,7 +62,8 @@ var parse = function(selector, callback) {
if(err) {
callback(err);
} else {
- callback(null, css.toString());
+ //callback(null, css.toString());
+ callback(null, css.join(''));
}
});
}
@@ -67,3 +73,11 @@ var parse = function(selector, callback) {
module.exports.parse = parse;
module.exports.reset = parserInitializer.reset;
+var ssss = 'a,\nb';
+console.log(ssss);
+parse(ssss, function(err, shiznit) {
+ if(err) {
+ console.log(err);
+ }
+ console.log(shiznit);
+});
View
2  src/cssSelector.ometa
@@ -1,4 +1,4 @@
-ometa CssSelector <: Parser {
+ometa CssSelector <: Parser {
crChar = '\r',
ffChar = '\f',
nlChar = '\n',
View
15 src/index.js
@@ -4,15 +4,22 @@ var sys = require('sys'),
rule = 'scssFile',
createdParser;
+var fixReadFile = function(rawFile) {
+ return rawFile.slice(1).replace(/\\n/g, '\n');
+};
+
var getParser = function(callback) {
if(!createdParser) {
- fs.readFile(__dirname + '/CssSelector.ometa', function(err, cssSelectorContents) {
- ometa.createParser(cssSelectorContents.toString(), function(err, cssSelectorParser) {
- fs.readFile(__dirname + '/scss.ometa', function(err, contents) {
+ fs.readFile(__dirname + '/CssSelector.ometa', 'utf8', function(err, cssSelectorContents) {
+ var selectorFile = fixReadFile(cssSelectorContents);
+ console.log(selectorFile);
+ ometa.createParser(selectorFile, function(err, cssSelectorParser) {
+ fs.readFile(__dirname + '/scss.ometa', 'utf8', function(err, contents) {
+ var contentFile = fixReadFile(contents);
if(err) {
callback(err);
} else {
- ometa.createParser(contents.toString(), function(err, parser) {
+ ometa.createParser(contentFile, function(err, parser) {
if(err) {
callback(err);
} else {
View
3  src/scss.ometa
@@ -1,4 +1,4 @@
-ometa Scss <: Parser {
+ometa Scss <: Parser {
selector = foreign(CssSelector, 'selectors_group'):sel -> { self.addSelector(sel) },
propertyValue = '$' letterOrDigit+:val -> ('$' + val.join(''))
@@ -38,7 +38,6 @@ Scss.initialize = function() {
};
this.addMixin = function(mixinName) {
- console.log('mixin:' + mixinName);
var block = createBlock();
mixins[mixinName] = block;
currentBlock = block;
Please sign in to comment.
Something went wrong with that request. Please try again.