Browse files

stupid line endings bit us. cc @adeelejaz

  • Loading branch information...
1 parent c95fd73 commit 836d110f2eb3c1fc959893b8b9a6612dff9f69bf @paulirish paulirish committed Aug 3, 2012
Showing with 38 additions and 30 deletions.
  1. +8 −0 .editorconfig
  2. +19 −19 lib/app.js
  3. +11 −11 posts/input-number.md
View
8 .editorconfig
@@ -0,0 +1,8 @@
+; editorconfig.org
+root = true
+
+; Unix-style newlines
+[*]
+end_of_line = LF
+indent_style = space
+indent_size = 2
View
38 lib/app.js
@@ -1,6 +1,6 @@
// Native modules
var fs = require('fs');
-var request = require('request');
+var request = require('request');
// Third-party modules
var Backbone = require('backbone');
@@ -10,7 +10,7 @@ var async = require('async');
//polyfill or no
Handlebars.registerHelper('polyfillaction', function(tags) {
- if(tags && tags.indexOf('polyfill') > -1) {
+ if(tags && tags.indexOf('polyfill') > -1) {
return 'with <b class=polyfill>polyfill</b>';
}
if(tags && tags.indexOf('fallback') > -1) {
@@ -29,7 +29,7 @@ Handlebars.registerHelper('featuretag', function(feature) {
});
Handlebars.registerHelper('testurl', function(url) {
- return /caniuse/.exec(url) != null? 'View browser share %': 'Learn more';
+ return /caniuse/.exec(url) != null? 'View browser share %': 'Learn more';
});
// File paths
@@ -53,7 +53,7 @@ exports.Feature = Backbone.Model.extend({
var i, len, parts, key, val, posttags;
var obj = { contents: '' };
var docs = this.get('contents').split('\n\n');
- var lines = docs[0].split('\n');
+ var lines = docs[0].split('\n|\r');
if(this.has('editfrag')) {
obj.editurl = paths.githuburl + this.get('editfrag') + '.md';
@@ -62,43 +62,43 @@ exports.Feature = Backbone.Model.extend({
for (i = 0, len = lines.length; i < len; i++) {
parts = lines[i].trim().split(':');
-
+
if (parts.length < 2) {
console.error(lines);
- throw new Error('Invalid key: val ... ' + obj.slug);
+ throw new Error('Invalid key: val ... ' + obj.slug);
}
-
+
key = parts[0];
val = parts.slice(1).join(':').trim();
-
+
if(key == 'tags') {
posttags = val.split(' ');
//if it is not whitespace separated it must be comma separated
if(posttags.length === 1) {
posttags.join(' ').split(',');
- }
+ }
posttags = posttags.map(function(tag) {
tag = tag.trim();
//catch use of tags like polyfill, gtie9
tag = /([^,]*)/.exec(tag)[1];
return tag;
-
+
});
val = posttags.join(' ');
- }
-
+ }
+
if(key == 'kind') {
obj.moreurl = paths.caniuseurl + obj.slug;
- }
-
+ }
+
obj[key] = (key === 'polyfillurls') ? "" + Markdown(val) : "" + val.trim();
}
obj.contents = "" + Markdown(docs.slice(1).join("\n\n"));
-
+
// Update the model to use the metadata and contents
this.set(obj);
}
@@ -139,7 +139,7 @@ exports.Markup = Backbone.View.extend({
// Read in the template and compile via handlebars to a reusable
// property that can be accessed in render.
var source = fs.readFileSync(paths.template).toString();
- this.template = Handlebars.compile(source);
+ this.template = Handlebars.compile(source);
},
// Triggered only when argument checkurls is passed to CLI
@@ -150,7 +150,7 @@ exports.Markup = Backbone.View.extend({
var callback = callback;
async.forEachSeries(
- this.collection.toArray(),
+ this.collection.toArray(),
function(feature, callback) {
var req = request({
method: 'GET',
@@ -170,7 +170,7 @@ exports.Markup = Backbone.View.extend({
updateUrlCallback();
});
},
-
+
render: function() {
console.log("rendering to the file…");
@@ -179,4 +179,4 @@ exports.Markup = Backbone.View.extend({
fs.writeFileSync(paths.output, html);
console.log("Your index page is now ready")
}
-});
+});
View
22 posts/input-number.md
@@ -1,11 +1,11 @@
-feature: <input type=number>
-status: use
-tags: polyfill fallback
-kind: html
-polyfillurls: [Number polyfill](https://github.com/jonstipe/number-polyfill)
-
-A number input will fallback to a plain text input if it's not supported.
-
-So far, Chrome, Safari and Opera support it. Jonathan Stipe's [Number polyfill](https://github.com/jonstipe/number-polyfill) doesn't need any additional code changes but does require jQuery and CSS to style buttons.
-
-Safari on iOS and the Browser on Android 4.0 (Ice Cream Sandwich) do show number input, but do not use "step", "min" or "max" attributes and neither show increment/decrement buttons.
+feature: <input type=number>
+status: use
+tags: polyfill fallback
+kind: html
+polyfillurls: [Number polyfill](https://github.com/jonstipe/number-polyfill)
+
+A number input will fallback to a plain text input if it's not supported.
+
+So far, Chrome, Safari and Opera support it. Jonathan Stipe's [Number polyfill](https://github.com/jonstipe/number-polyfill) doesn't need any additional code changes but does require jQuery and CSS to style buttons.
+
+Safari on iOS and the Browser on Android 4.0 (Ice Cream Sandwich) do show number input, but do not use "step", "min" or "max" attributes and neither show increment/decrement buttons.

7 comments on commit 836d110

@adeelejaz

me bad.. I apologize for the oversight :( I did the commit from the work machine running Windows for GitHub....

@paulirish
H5BP member
@adeelejaz

I use Sublime Text 2, beta build. What chaos did this cause btw?

@paulirish
H5BP member
@adeelejaz

Darn. It never crossed my mind. Plugin installed. Thanks!

@s10wen

@paulirish is there any online resource that documents positives and negatives of indentation formatting?

Would be great if there was a unified model and everyone followed it.

Personally I used to use 1 Tab, but changed to 2 Spaces to keep inline with H5BP, but never knew the reason behind it.

@paulirish
H5BP member
Please sign in to comment.