     return lhs.text == rhs.text && lhs.start == rhs.start
 }
 
+///This class is where the magic happens.
 public class BumbleBee {
     
+    ///The patterns array holds all the variables that make up a pattern
     var patterns = Array<Matcher>()
     
-    public func add(pattern: String, recursive: Bool, matched: ((String,String,Int) -> (String,Int))?) {
+    ///add a new pattern for processing. The closure is called when a match is found and allows the replacement text and attributes to be applied.
+    public func add(pattern: String, recursive: Bool, matched: ((String,String,Int) -> (String,[NSObject : AnyObject]?))?) {
         patterns.append(Matcher(src: pattern, recursive: recursive, matched: matched))
     }
     
-    public func process(srcText: String) -> String {
+    //The srcText is the raw text to search matches for. A NSAttributedString is return stylized according to the matches.
+    public func process(srcText: String) -> NSAttributedString {
         var pending = Array<Pattern>()
+        var collect = Array<Pattern>()
         var index = 0
         var text = srcText
         for char in text {

//

import Foundation

class Pattern {
    var matched:((String,String,Int) -> (text: String,offset: Int))?
    var start = 0
    var end = -1
    var text: String
    var recursive: Bool
    var current: Character
    var mustFullfill = true
    var index = 0
    var rewindIndex = 0
    init(_ text: String, _ start: Int, _ recursive: Bool, _ matched: ((String,String,Int) -> (String,Int))?) {
        self.mustFullfill = true
        self.recursive = recursive
        self.start = start

class Matcher {
    var src: String
    var recursive: Bool
    var matched:((String,String,Int) -> (String,[NSObject : AnyObject]?))?
    init(src: String,recursive: Bool ,matched:((String,String,Int) -> (String,[NSObject : AnyObject]?))?) {
        self.src = src
        self.matched = matched
        self.recursive = recursive
