'use strict';

var inlineSource = require('inline-source').sync;

/*
 * Filter files to find HTML files.
 * Iterate through each file name and grab
 * the contents of each file and replace
 * with an inlined version.
 */

var inline = function(options) {
  return function(files, metalsmith, done) {
      var htmlFiles = Object.keys(files).filter(function(file) {
        // Make sure the filename ends in either htm or html
        var checkIfHtml = /[.](?:html?)$/.test(file);

        if (checkIfHtml) {
          return file;
        }
      });

      htmlFiles.map(function(path) {
        files[path].contents = new Buffer(inlineSource(files[path].contents.toString(), options)), 'utf8';
      });
    done();
  };
};

module.exports = inline;

@@ -293,26 +293,24 @@
 done) %7B%0A    
-  
 var htmlFile
@@ -362,18 +362,16 @@
 %7B%0A      
-  
 // Make 
@@ -421,18 +421,16 @@
 l%0A      
- 
- 
 var chec
@@ -474,18 +474,16 @@
 %0A%0A      
-  
 if (chec
@@ -489,26 +489,24 @@
 ckIfHtml) %7B%0A
-  
         retu
@@ -524,14 +524,10 @@
     
-  %7D%0A  
+%7D%0A
     
@@ -527,26 +527,24 @@
  %7D%0A    %7D);%0A%0A
-  
     htmlFile
@@ -562,26 +562,24 @@
 ion(path) %7B%0A
-  
       files%5B
@@ -671,18 +671,16 @@
 'utf8';%0A
-  
     %7D);%0A

Fix indentation