/*
  Convert the contents of an HTML DOM element into a
  styled text document for an easier reading
  experience or to bring out certain features in the
  document. You can create your own README document.
  
  if (redistribute == true) {
    return credit;
  }
  
  --------------------------------------------------
  
  @DocTyp
  @author: Alexander Hovy
  @param: 
    exports - Contains all the public variables and functions of the module.
    element - The HTML DOM element that will be Docified.
    style - You can optionally set the style to Dark or Light.
    doc - The elements text that will be Docified.
*/
var DocTyp = (function(exports) {
  /*============================================================
  ===========================Variable===========================
  ============================================================*/
  var prefix = 'doctyp-';
  var header = {
    'header1': {pattern: /\#/gm, regex: /^\#{1}(?!\#)(.*?)$/gm},
    'header2': {pattern: /\#/gm, regex: /^\#{2}(?!\#)(.*?)$/gm},
    'header3': {pattern: /\#/gm, regex: /^\#{3}(?!\#)(.*?)$/gm},
    'header4': {pattern: /\#/gm, regex: /^\#{4,}(.*?)$/gm}
  };
  var style = {
    'bold': {pattern: /\*/gm, regex: /\*{1,}(.*?)\*{1,}/gm},
    'italic': {pattern: /\//gm, regex: /\/{1,}(.*?)\/{1,}/gm},
    'underline': {pattern: /\_/gm, regex: /\_{1,}(.*?)\_{1,}/gm},
    'strike': {pattern: /\~/gm, regex: /\~{1,}(.*?)\~{1,}/gm},
    'highlight': {pattern: /\=/gm, regex: /\={1,}(.*?)\={1,}/gm}
  };
  var rule = {
    'header1': {pattern: /\#/gm, regex: /^\#{1}(?!\#)(.*?)$/gm},
    'header2': {pattern: /\#/gm, regex: /^\#{2}(?!\#)(.*?)$/gm},
    'header3': {pattern: /\#/gm, regex: /^\#{3}(?!\#)(.*?)$/gm},
    'header4': {pattern: /\#/gm, regex: /^\#{4,}(.*?)$/gm}
  };
  var block = {
    'header1': {pattern: /\#/gm, regex: /^\#{1}(?!\#)(.*?)$/gm},
    'header2': {pattern: /\#/gm, regex: /^\#{2}(?!\#)(.*?)$/gm},
    'header3': {pattern: /\#/gm, regex: /^\#{3}(?!\#)(.*?)$/gm},
    'header4': {pattern: /\#/gm, regex: /^\#{4,}(.*?)$/gm}
  };
  var list = {
    'header1': {pattern: /\#/gm, regex: /^\#{1}(?!\#)(.*?)$/gm},
    'header2': {pattern: /\#/gm, regex: /^\#{2}(?!\#)(.*?)$/gm},
    'header3': {pattern: /\#/gm, regex: /^\#{3}(?!\#)(.*?)$/gm},
    'header4': {pattern: /\#/gm, regex: /^\#{4,}(.*?)$/gm}
  };
  var link = {
    'header1': {pattern: /\#/gm, regex: /^\#{1}(?!\#)(.*?)$/gm},
    'header2': {pattern: /\#/gm, regex: /^\#{2}(?!\#)(.*?)$/gm},
    'header3': {pattern: /\#/gm, regex: /^\#{3}(?!\#)(.*?)$/gm},
    'header4': {pattern: /\#/gm, regex: /^\#{4,}(.*?)$/gm}
  };
  
  /*============================================================
  ============================Private===========================
  ============================================================*/
  function LoadStyle(style) {
    var link = document.createElement('link');
    link.type = 'text/css';
    link.rel = 'stylesheet';
    link.href = 'Style/' + style.toLowerCase() + '.css';
    link.media = 'none';
    link.onload = function() {
      if (media != 'all') {
        link.media = 'all';
      }
    };
    document.getElementsByTagName('head')[0].appendChild(link);
  }
  //Processing
  function Header(doc) {
    for (key in header) {
      doc = doc.replace(header[key].regex, function(match) {
        var temp = Prepare(match).replace(header[key].pattern, '');
        return '<span class="' + prefix + key + '">' + temp + '</span>';
      });
    }
    return doc;
  }
  function Style(doc) {
    for (key in style) {
      doc = doc.replace(style[key].regex, function(match) {
        var temp = Prepare(match).replace(style[key].pattern, '');
        return '<span class="' + prefix + key + '">' + temp + '</span>';
      });
    }
    return doc;
  }
  function Rule(doc) {
    return doc;
  }
  function Block(doc) {
    return doc;
  }
  function List(doc) {
    return doc;
  }
  function Link(doc) {
    return doc;
  }
  //Cleaning
  function Prepare(doc) {
    return doc.replace(/\<(\/)?span(.*?)\>/gm, '');
  }
  function Clean(doc) {
    return doc.replace(/\n/gm, '<br/>');
  }
  
  /*============================================================
  ============================Public============================
  ============================================================*/
  exports.Docify = function(element, style) {
    //Check if element is an element
    if (element.nodeType && element.nodeType == 1) {
      //Check if user is using their own style
      if (style !== undefined) {
        LoadStyle(style);
      }
      //Cater for older browsers
      var doc = element.innerText ? element.innerText : element.textContent;
      //Processing
      doc = Header(doc);
      doc = Style(doc);
      doc = Rule(doc);
      doc = Block(doc);
      doc = List(doc);
      doc = Clean(doc);
      //Replace text with new text
      element.innerHTML = doc;
    } else {
      throw('The element is not defined or is not a DOM element.');
    }
  };
  
  /*============================================================
  ============================Export============================
  ============================================================*/
  return exports;
})({});

@@ -1508,80 +1508,18 @@
    '
-header1': %7Bpattern: /%5C#/gm, regex: /%5E%5C#%7B1%7D(?!%5C#)(.*?)$/gm%7D,%0A    'header2
+rule-solid
 ': %7B
@@ -1521,33 +1521,33 @@
 d': %7Bpattern: /%5C
-#
+-
 /gm, regex: /%5E%5C#
@@ -1547,109 +1547,34 @@
 x: /
-%5E%5C#%7B2%7D(?!%5C#)(.*?)$/gm%7D,%0A    'header3': %7Bpattern: /%5C#/gm, regex: /%5E%5C#%7B3%7D(?!%5C#)(.*?)$/gm%7D,%0A    'header4
+%5C-%7B4,%7D/gm%7D,%0A    'rule-dash
 ': %7B
@@ -1576,33 +1576,33 @@
 h': %7Bpattern: /%5C
-#
+_
 /gm, regex: /%5E%5C#
@@ -1594,37 +1594,30 @@
 gm, regex: /
-%5E%5C#
+%5C_
 %7B4,%7D
-(.*?)$
 /gm%7D%0A  %7D;%0A  
@@ -3625,32 +3625,184 @@
 ion Rule(doc) %7B%0A
+    for (key in rule) %7B%0A      doc = doc.replace(rule%5Bkey%5D.regex, function(match) %7B%0A        return '%3Chr class=%22' + prefix + key + '%22/%3E';%0A      %7D);%0A    %7D%0A
     return doc;%0A

Update DocTyp.js