/*
 * textnodes
 * 
 *
 * Copyright (c) 2014 Mark Florian
 * Licensed under the MIT license.
 */

(function($) {

  var rNonWhiteSpace = /\S/;

  function getChildTextNodes($el, list, includeWhiteSpace) {
    $el.contents().each(function () {
      console.log("called");
      if (this.nodeType === 3) {
        if (
            includeWhiteSpace &&
            rNonWhiteSpace.test(this.textContent || this.innerText)
           ) {
          list.push(this);
        }
      } else if (this.nodeType === 1) {
        getChildTextNodes($(this), list);
      }
    });
  }

  $.fn.textNodes = function (includeWhiteSpace) {
    var textNodes = [];
    getChildTextNodes(this, textNodes, includeWhiteSpace);
    return $(textNodes);
  };

}(jQuery));

/*
 * textnodes
 * 
 *
 * Copyright (c) 2014 Mark Florian
 * Licensed under the MIT license.
 */

(function($) {

  // Collection method.
  $.fn.textnodes = function() {
    return this.each(function(i) {
      // Do something awesome to each selected element.
      $(this).html('awesome' + i);
    });
  };

  // Static method.
  $.textnodes = function(options) {
    // Override default options with passed-in options.
    options = $.extend({}, $.textnodes.options, options);
    // Return something awesome.
    return 'awesome' + options.punctuation;
  };

  // Static method default options.
  $.textnodes.options = {
    punctuation: '.'
  };

  // Custom selector.
  $.expr[':'].textnodes = function(elem) {
    // Is this element awesome?
    return $(elem).text().indexOf('awesome') !== -1;
  };

}(jQuery));

--- 
+++ 
@@ -8,28 +8,31 @@
 
 (function($) {
 
-  var rNonWhiteSpace = /\S/;
+  // Collection method.
+  $.fn.textnodes = function() {
+    return this.each(function(i) {
+      // Do something awesome to each selected element.
+      $(this).html('awesome' + i);
+    });
+  };
 
-  function getChildTextNodes($el, list, includeWhiteSpace) {
-    $el.contents().each(function () {
-      console.log("called");
-      if (this.nodeType === 3) {
-        if (
-            includeWhiteSpace &&
-            rNonWhiteSpace.test(this.textContent || this.innerText)
-           ) {
-          list.push(this);
-        }
-      } else if (this.nodeType === 1) {
-        getChildTextNodes($(this), list);
-      }
-    });
-  }
+  // Static method.
+  $.textnodes = function(options) {
+    // Override default options with passed-in options.
+    options = $.extend({}, $.textnodes.options, options);
+    // Return something awesome.
+    return 'awesome' + options.punctuation;
+  };
 
-  $.fn.textNodes = function (includeWhiteSpace) {
-    var textNodes = [];
-    getChildTextNodes(this, textNodes, includeWhiteSpace);
-    return $(textNodes);
+  // Static method default options.
+  $.textnodes.options = {
+    punctuation: '.'
+  };
+
+  // Custom selector.
+  $.expr[':'].textnodes = function(elem) {
+    // Is this element awesome?
+    return $(elem).text().indexOf('awesome') !== -1;
   };
 
 }(jQuery));
Add first draft of plugin.
