Ver Fonte

refactor(subParsers): change name and directory of subparsers

BREAKING CHANGE: makeHtml subparsers names changed, by prepending 'makehtml.' to them.
Example: 'anchors', subparser is now named 'makehtml.anchors'.

Event names were also changed to reflect this.
Example: 'anchors.before' is now named 'makehtml.anchors.before'.

**To migrate:**

If you have a listener extension, replace the old event name with the new one. Example:

Replace this

```js
showdown.extension('myext', function() {
  return [{
    type: 'listener',
    listeners: {
      'anchors.before': function (event, text, converter, options, globals) {
        //... some code
        return text;
      }
  }];
});
```

with this
```js
showdown.extension('myext', function() {
  return [{
    type: 'listener',
    listeners: {
      'makehtml.anchors.before': function (event, text, converter, options, globals) {
        //... some code
        return text;
      }
  }];
});
```
Estevao Soares dos Santos há 7 anos atrás
pai
commit
3db9200d2c
49 ficheiros alterados com 761 adições e 1258 exclusões
  1. 2 1
      Gruntfile.js
  2. 476 973
      dist/showdown.js
  3. 0 0
      dist/showdown.js.map
  4. 0 1
      dist/showdown.min.js
  5. 0 0
      dist/showdown.min.js.map
  6. 13 13
      src/converter.js
  7. 0 32
      src/subParsers/blockGamut.js
  8. 0 11
      src/subParsers/ellipsis.js
  9. 0 8
      src/subParsers/hashBlock.js
  10. 0 15
      src/subParsers/horizontalRule.js
  11. 3 3
      src/subParsers/makehtml/anchors.js
  12. 7 7
      src/subParsers/makehtml/autoLinks.js
  13. 32 0
      src/subParsers/makehtml/blockGamut.js
  14. 6 6
      src/subParsers/makehtml/blockQuotes.js
  15. 7 7
      src/subParsers/makehtml/codeBlocks.js
  16. 5 5
      src/subParsers/makehtml/codeSpans.js
  17. 3 3
      src/subParsers/makehtml/completeHTMLDocument.js
  18. 3 3
      src/subParsers/makehtml/detab.js
  19. 11 0
      src/subParsers/makehtml/ellipsis.js
  20. 3 3
      src/subParsers/makehtml/emoji.js
  21. 3 3
      src/subParsers/makehtml/encodeAmpsAndAngles.js
  22. 3 3
      src/subParsers/makehtml/encodeBackslashEscapes.js
  23. 3 3
      src/subParsers/makehtml/encodeCode.js
  24. 3 3
      src/subParsers/makehtml/escapeSpecialCharsWithinTagAttributes.js
  25. 6 6
      src/subParsers/makehtml/githubCodeBlocks.js
  26. 8 0
      src/subParsers/makehtml/hashBlock.js
  27. 4 4
      src/subParsers/makehtml/hashCodeTags.js
  28. 1 1
      src/subParsers/makehtml/hashElement.js
  29. 5 5
      src/subParsers/makehtml/hashHTMLBlocks.js
  30. 6 6
      src/subParsers/makehtml/hashHTMLSpans.js
  31. 4 4
      src/subParsers/makehtml/hashPreCodeTags.js
  32. 9 9
      src/subParsers/makehtml/headers.js
  33. 15 0
      src/subParsers/makehtml/horizontalRule.js
  34. 3 3
      src/subParsers/makehtml/images.js
  35. 3 3
      src/subParsers/makehtml/italicsAndBold.js
  36. 9 9
      src/subParsers/makehtml/lists.js
  37. 3 3
      src/subParsers/makehtml/metadata.js
  38. 3 3
      src/subParsers/makehtml/outdent.js
  39. 5 5
      src/subParsers/makehtml/paragraphs.js
  40. 1 1
      src/subParsers/makehtml/runExtension.js
  41. 49 0
      src/subParsers/makehtml/spanGamut.js
  42. 18 0
      src/subParsers/makehtml/strikethrough.js
  43. 2 2
      src/subParsers/makehtml/stripLinkDefinitions.js
  44. 6 6
      src/subParsers/makehtml/tables.js
  45. 3 3
      src/subParsers/makehtml/underline.js
  46. 15 0
      src/subParsers/makehtml/unescapeSpecialChars.js
  47. 0 49
      src/subParsers/spanGamut.js
  48. 0 18
      src/subParsers/strikethrough.js
  49. 0 15
      src/subParsers/unescapeSpecialChars.js

+ 2 - 1
Gruntfile.js

@@ -23,8 +23,9 @@ module.exports = function (grunt) {
           'src/options.js',
           'src/showdown.js',
           'src/helpers.js',
+          'src/subParsers/makehtml/*.js',
+          'src/subParsers/makemd/*.js',
           'src/converter.js',
-          'src/subParsers/*.js',
           'src/loader.js'
         ],
         dest: 'dist/<%= pkg.name %>.js'

Diff do ficheiro suprimidas por serem muito extensas
+ 476 - 973
dist/showdown.js


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/showdown.js.map


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 1
dist/showdown.min.js


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/showdown.min.js.map


+ 13 - 13
src/converter.js

@@ -298,7 +298,7 @@ showdown.Converter = function (converterOptions) {
     text = '\n\n' + text + '\n\n';
 
     // detab
-    text = showdown.subParser('detab')(text, options, globals);
+    text = showdown.subParser('makehtml.detab')(text, options, globals);
 
     /**
      * Strip any lines consisting only of spaces and tabs.
@@ -310,19 +310,19 @@ showdown.Converter = function (converterOptions) {
 
     //run languageExtensions
     showdown.helper.forEach(langExtensions, function (ext) {
-      text = showdown.subParser('runExtension')(ext, text, options, globals);
+      text = showdown.subParser('makehtml.runExtension')(ext, text, options, globals);
     });
 
     // run the sub parsers
-    text = showdown.subParser('metadata')(text, options, globals);
-    text = showdown.subParser('hashPreCodeTags')(text, options, globals);
-    text = showdown.subParser('githubCodeBlocks')(text, options, globals);
-    text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
-    text = showdown.subParser('hashCodeTags')(text, options, globals);
-    text = showdown.subParser('stripLinkDefinitions')(text, options, globals);
-    text = showdown.subParser('blockGamut')(text, options, globals);
-    text = showdown.subParser('unhashHTMLSpans')(text, options, globals);
-    text = showdown.subParser('unescapeSpecialChars')(text, options, globals);
+    text = showdown.subParser('makehtml.metadata')(text, options, globals);
+    text = showdown.subParser('makehtml.hashPreCodeTags')(text, options, globals);
+    text = showdown.subParser('makehtml.githubCodeBlocks')(text, options, globals);
+    text = showdown.subParser('makehtml.hashHTMLBlocks')(text, options, globals);
+    text = showdown.subParser('makehtml.hashCodeTags')(text, options, globals);
+    text = showdown.subParser('makehtml.stripLinkDefinitions')(text, options, globals);
+    text = showdown.subParser('makehtml.blockGamut')(text, options, globals);
+    text = showdown.subParser('makehtml.unhashHTMLSpans')(text, options, globals);
+    text = showdown.subParser('makehtml.unescapeSpecialChars')(text, options, globals);
 
     // attacklab: Restore dollar signs
     text = text.replace(/¨D/g, '$$');
@@ -331,11 +331,11 @@ showdown.Converter = function (converterOptions) {
     text = text.replace(/¨T/g, '¨');
 
     // render a complete html document instead of a partial if the option is enabled
-    text = showdown.subParser('completeHTMLDocument')(text, options, globals);
+    text = showdown.subParser('makehtml.completeHTMLDocument')(text, options, globals);
 
     // Run output modifiers
     showdown.helper.forEach(outputModifiers, function (ext) {
-      text = showdown.subParser('runExtension')(ext, text, options, globals);
+      text = showdown.subParser('makehtml.runExtension')(ext, text, options, globals);
     });
 
     // update metadata

+ 0 - 32
src/subParsers/blockGamut.js

@@ -1,32 +0,0 @@
-/**
- * These are all the transformations that form block-level
- * tags like paragraphs, headers, and list items.
- */
-showdown.subParser('blockGamut', function (text, options, globals) {
-  'use strict';
-
-  text = globals.converter._dispatch('blockGamut.before', text, options, globals);
-
-  // we parse blockquotes first so that we can have headings and hrs
-  // inside blockquotes
-  text = showdown.subParser('blockQuotes')(text, options, globals);
-  text = showdown.subParser('headers')(text, options, globals);
-
-  // Do Horizontal Rules:
-  text = showdown.subParser('horizontalRule')(text, options, globals);
-
-  text = showdown.subParser('lists')(text, options, globals);
-  text = showdown.subParser('codeBlocks')(text, options, globals);
-  text = showdown.subParser('tables')(text, options, globals);
-
-  // We already ran _HashHTMLBlocks() before, in Markdown(), but that
-  // was to escape raw HTML in the original Markdown source. This time,
-  // we're escaping the markup we've just created, so that we don't wrap
-  // <p> tags around block-level tags.
-  text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
-  text = showdown.subParser('paragraphs')(text, options, globals);
-
-  text = globals.converter._dispatch('blockGamut.after', text, options, globals);
-
-  return text;
-});

+ 0 - 11
src/subParsers/ellipsis.js

@@ -1,11 +0,0 @@
-showdown.subParser('ellipsis', function (text, options, globals) {
-  'use strict';
-
-  text = globals.converter._dispatch('ellipsis.before', text, options, globals);
-
-  text = text.replace(/\.\.\./g, '…');
-
-  text = globals.converter._dispatch('ellipsis.after', text, options, globals);
-
-  return text;
-});

+ 0 - 8
src/subParsers/hashBlock.js

@@ -1,8 +0,0 @@
-showdown.subParser('hashBlock', function (text, options, globals) {
-  'use strict';
-  text = globals.converter._dispatch('hashBlock.before', text, options, globals);
-  text = text.replace(/(^\n+|\n+$)/g, '');
-  text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
-  text = globals.converter._dispatch('hashBlock.after', text, options, globals);
-  return text;
-});

+ 0 - 15
src/subParsers/horizontalRule.js

@@ -1,15 +0,0 @@
-/**
- * Turn Markdown link shortcuts into XHTML <a> tags.
- */
-showdown.subParser('horizontalRule', function (text, options, globals) {
-  'use strict';
-  text = globals.converter._dispatch('horizontalRule.before', text, options, globals);
-
-  var key = showdown.subParser('hashBlock')('<hr />', options, globals);
-  text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
-  text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
-  text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
-
-  text = globals.converter._dispatch('horizontalRule.after', text, options, globals);
-  return text;
-});

+ 3 - 3
src/subParsers/anchors.js → src/subParsers/makehtml/anchors.js

@@ -1,10 +1,10 @@
 /**
  * Turn Markdown link shortcuts into XHTML <a> tags.
  */
-showdown.subParser('anchors', function (text, options, globals) {
+showdown.subParser('makehtml.anchors', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('anchors.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.anchors.before', text, options, globals);
 
   var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) {
     if (showdown.helper.isUndefined(title)) {
@@ -93,6 +93,6 @@ showdown.subParser('anchors', function (text, options, globals) {
     });
   }
 
-  text = globals.converter._dispatch('anchors.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.anchors.after', text, options, globals);
   return text;
 });

+ 7 - 7
src/subParsers/autoLinks.js → src/subParsers/makehtml/autoLinks.js

@@ -33,7 +33,7 @@ var simpleURLRegex  = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'
       return function (wholeMatch, b, mail) {
         var href = 'mailto:';
         b = b || '';
-        mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
+        mail = showdown.subParser('makehtml.unescapeSpecialChars')(mail, options, globals);
         if (options.encodeEmails) {
           href = showdown.helper.encodeEmailAddress(href + mail);
           mail = showdown.helper.encodeEmailAddress(mail);
@@ -44,27 +44,27 @@ var simpleURLRegex  = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'
       };
     };
 
-showdown.subParser('autoLinks', function (text, options, globals) {
+showdown.subParser('makehtml.autoLinks', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('autoLinks.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.autoLinks.before', text, options, globals);
 
   text = text.replace(delimUrlRegex, replaceLink(options));
   text = text.replace(delimMailRegex, replaceMail(options, globals));
 
-  text = globals.converter._dispatch('autoLinks.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.autoLinks.after', text, options, globals);
 
   return text;
 });
 
-showdown.subParser('simplifiedAutoLinks', function (text, options, globals) {
+showdown.subParser('makehtml.simplifiedAutoLinks', function (text, options, globals) {
   'use strict';
 
   if (!options.simplifiedAutoLink) {
     return text;
   }
 
-  text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.simplifiedAutoLinks.before', text, options, globals);
 
   if (options.excludeTrailingPunctuationFromURLs) {
     text = text.replace(simpleURLRegex2, replaceLink(options));
@@ -73,7 +73,7 @@ showdown.subParser('simplifiedAutoLinks', function (text, options, globals) {
   }
   text = text.replace(simpleMailRegex, replaceMail(options, globals));
 
-  text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.simplifiedAutoLinks.after', text, options, globals);
 
   return text;
 });

+ 32 - 0
src/subParsers/makehtml/blockGamut.js

@@ -0,0 +1,32 @@
+/**
+ * These are all the transformations that form block-level
+ * tags like paragraphs, headers, and list items.
+ */
+showdown.subParser('makehtml.blockGamut', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('makehtml.blockGamut.before', text, options, globals);
+
+  // we parse blockquotes first so that we can have headings and hrs
+  // inside blockquotes
+  text = showdown.subParser('makehtml.blockQuotes')(text, options, globals);
+  text = showdown.subParser('makehtml.headers')(text, options, globals);
+
+  // Do Horizontal Rules:
+  text = showdown.subParser('makehtml.horizontalRule')(text, options, globals);
+
+  text = showdown.subParser('makehtml.lists')(text, options, globals);
+  text = showdown.subParser('makehtml.codeBlocks')(text, options, globals);
+  text = showdown.subParser('makehtml.tables')(text, options, globals);
+
+  // We already ran _HashHTMLBlocks() before, in Markdown(), but that
+  // was to escape raw HTML in the original Markdown source. This time,
+  // we're escaping the markup we've just created, so that we don't wrap
+  // <p> tags around block-level tags.
+  text = showdown.subParser('makehtml.hashHTMLBlocks')(text, options, globals);
+  text = showdown.subParser('makehtml.paragraphs')(text, options, globals);
+
+  text = globals.converter._dispatch('makehtml.blockGamut.after', text, options, globals);
+
+  return text;
+});

+ 6 - 6
src/subParsers/blockQuotes.js → src/subParsers/makehtml/blockQuotes.js

@@ -1,7 +1,7 @@
-showdown.subParser('blockQuotes', function (text, options, globals) {
+showdown.subParser('makehtml.blockQuotes', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('blockQuotes.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.blockQuotes.before', text, options, globals);
 
   text = text.replace(/((^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) {
     var bq = m1;
@@ -14,8 +14,8 @@ showdown.subParser('blockQuotes', function (text, options, globals) {
     bq = bq.replace(/¨0/g, '');
 
     bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
-    bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
-    bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
+    bq = showdown.subParser('makehtml.githubCodeBlocks')(bq, options, globals);
+    bq = showdown.subParser('makehtml.blockGamut')(bq, options, globals); // recurse
 
     bq = bq.replace(/(^|\n)/g, '$1  ');
     // These leading spaces screw with <pre> content, so we need to fix that:
@@ -27,9 +27,9 @@ showdown.subParser('blockQuotes', function (text, options, globals) {
       return pre;
     });
 
-    return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
+    return showdown.subParser('makehtml.hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
   });
 
-  text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.blockQuotes.after', text, options, globals);
   return text;
 });

+ 7 - 7
src/subParsers/codeBlocks.js → src/subParsers/makehtml/codeBlocks.js

@@ -1,10 +1,10 @@
 /**
  * Process Markdown `<pre><code>` blocks.
  */
-showdown.subParser('codeBlocks', function (text, options, globals) {
+showdown.subParser('makehtml.codeBlocks', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.codeBlocks.before', text, options, globals);
 
   // sentinel workarounds for lack of \A and \Z, safari\khtml bug
   text += '¨0';
@@ -15,9 +15,9 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
         nextChar = m2,
         end = '\n';
 
-    codeblock = showdown.subParser('outdent')(codeblock, options, globals);
-    codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
-    codeblock = showdown.subParser('detab')(codeblock, options, globals);
+    codeblock = showdown.subParser('makehtml.outdent')(codeblock, options, globals);
+    codeblock = showdown.subParser('makehtml.encodeCode')(codeblock, options, globals);
+    codeblock = showdown.subParser('makehtml.detab')(codeblock, options, globals);
     codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
     codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
 
@@ -27,12 +27,12 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
 
     codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
 
-    return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
+    return showdown.subParser('makehtml.hashBlock')(codeblock, options, globals) + nextChar;
   });
 
   // strip sentinel
   text = text.replace(/¨0/, '');
 
-  text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.codeBlocks.after', text, options, globals);
   return text;
 });

+ 5 - 5
src/subParsers/codeSpans.js → src/subParsers/makehtml/codeSpans.js

@@ -23,10 +23,10 @@
  *
  *         ... type <code>`bar`</code> ...
  */
-showdown.subParser('codeSpans', function (text, options, globals) {
+showdown.subParser('makehtml.codeSpans', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('codeSpans.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.codeSpans.before', text, options, globals);
 
   if (typeof(text) === 'undefined') {
     text = '';
@@ -36,13 +36,13 @@ showdown.subParser('codeSpans', function (text, options, globals) {
       var c = m3;
       c = c.replace(/^([ \t]*)/g, '');	// leading whitespace
       c = c.replace(/[ \t]*$/g, '');	// trailing whitespace
-      c = showdown.subParser('encodeCode')(c, options, globals);
+      c = showdown.subParser('makehtml.encodeCode')(c, options, globals);
       c = m1 + '<code>' + c + '</code>';
-      c = showdown.subParser('hashHTMLSpans')(c, options, globals);
+      c = showdown.subParser('makehtml.hashHTMLSpans')(c, options, globals);
       return c;
     }
   );
 
-  text = globals.converter._dispatch('codeSpans.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.codeSpans.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/completeHTMLDocument.js → src/subParsers/makehtml/completeHTMLDocument.js

@@ -1,14 +1,14 @@
 /**
  * Turn Markdown link shortcuts into XHTML <a> tags.
  */
-showdown.subParser('completeHTMLDocument', function (text, options, globals) {
+showdown.subParser('makehtml.completeHTMLDocument', function (text, options, globals) {
   'use strict';
 
   if (!options.completeHTMLDocument) {
     return text;
   }
 
-  text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.completeHTMLDocument.before', text, options, globals);
 
   var doctype = 'html',
       doctypeParsed = '<!DOCTYPE HTML>\n',
@@ -57,6 +57,6 @@ showdown.subParser('completeHTMLDocument', function (text, options, globals) {
 
   text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>';
 
-  text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.completeHTMLDocument.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/detab.js → src/subParsers/makehtml/detab.js

@@ -1,9 +1,9 @@
 /**
  * Convert all tabs to spaces
  */
-showdown.subParser('detab', function (text, options, globals) {
+showdown.subParser('makehtml.detab', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('detab.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.detab.before', text, options, globals);
 
   // expand first n-1 tabs
   text = text.replace(/\t(?=\t)/g, '    '); // g_tab_width
@@ -28,6 +28,6 @@ showdown.subParser('detab', function (text, options, globals) {
   text = text.replace(/¨A/g, '    ');  // g_tab_width
   text = text.replace(/¨B/g, '');
 
-  text = globals.converter._dispatch('detab.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.detab.after', text, options, globals);
   return text;
 });

+ 11 - 0
src/subParsers/makehtml/ellipsis.js

@@ -0,0 +1,11 @@
+showdown.subParser('makehtml.ellipsis', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('makehtml.ellipsis.before', text, options, globals);
+
+  text = text.replace(/\.\.\./g, '…');
+
+  text = globals.converter._dispatch('makehtml.ellipsis.after', text, options, globals);
+
+  return text;
+});

+ 3 - 3
src/subParsers/emoji.js → src/subParsers/makehtml/emoji.js

@@ -2,14 +2,14 @@
  * These are all the transformations that occur *within* block-level
  * tags like paragraphs, headers, and list items.
  */
-showdown.subParser('emoji', function (text, options, globals) {
+showdown.subParser('makehtml.emoji', function (text, options, globals) {
   'use strict';
 
   if (!options.emoji) {
     return text;
   }
 
-  text = globals.converter._dispatch('emoji.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.emoji.before', text, options, globals);
 
   var emojiRgx = /:([\S]+?):/g;
 
@@ -20,7 +20,7 @@ showdown.subParser('emoji', function (text, options, globals) {
     return wm;
   });
 
-  text = globals.converter._dispatch('emoji.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.emoji.after', text, options, globals);
 
   return text;
 });

+ 3 - 3
src/subParsers/encodeAmpsAndAngles.js → src/subParsers/makehtml/encodeAmpsAndAngles.js

@@ -1,9 +1,9 @@
 /**
  * Smart processing for ampersands and angle brackets that need to be encoded.
  */
-showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
+showdown.subParser('makehtml.encodeAmpsAndAngles', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.encodeAmpsAndAngles.before', text, options, globals);
 
   // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
   // http://bumppo.net/projects/amputator/
@@ -18,6 +18,6 @@ showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
   // Encode >
   text = text.replace(/>/g, '&gt;');
 
-  text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.encodeAmpsAndAngles.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/encodeBackslashEscapes.js → src/subParsers/makehtml/encodeBackslashEscapes.js

@@ -9,13 +9,13 @@
  * ...but we're sidestepping its use of the (slow) RegExp constructor
  * as an optimization for Firefox.  This function gets called a LOT.
  */
-showdown.subParser('encodeBackslashEscapes', function (text, options, globals) {
+showdown.subParser('makehtml.encodeBackslashEscapes', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.encodeBackslashEscapes.before', text, options, globals);
 
   text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
   text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback);
 
-  text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.encodeBackslashEscapes.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/encodeCode.js → src/subParsers/makehtml/encodeCode.js

@@ -3,10 +3,10 @@
  * The point is that in code, these characters are literals,
  * and lose their special Markdown meanings.
  */
-showdown.subParser('encodeCode', function (text, options, globals) {
+showdown.subParser('makehtml.encodeCode', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('encodeCode.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.encodeCode.before', text, options, globals);
 
   // Encode all ampersands; HTML entities are not
   // entities within a Markdown code span.
@@ -18,6 +18,6 @@ showdown.subParser('encodeCode', function (text, options, globals) {
   // Now, escape characters that are magic in Markdown:
     .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback);
 
-  text = globals.converter._dispatch('encodeCode.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.encodeCode.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/escapeSpecialCharsWithinTagAttributes.js → src/subParsers/makehtml/escapeSpecialCharsWithinTagAttributes.js

@@ -2,9 +2,9 @@
  * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
  * don't conflict with their use in Markdown for code, italics and strong.
  */
-showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
+showdown.subParser('makehtml.escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
 
   // Build a regex to find HTML tags.
   var tags     = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
@@ -21,6 +21,6 @@ showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, opti
       .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
   });
 
-  text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.escapeSpecialCharsWithinTagAttributes.after', text, options, globals);
   return text;
 });

+ 6 - 6
src/subParsers/githubCodeBlocks.js → src/subParsers/makehtml/githubCodeBlocks.js

@@ -8,7 +8,7 @@
  *     end
  * ```
  */
-showdown.subParser('githubCodeBlocks', function (text, options, globals) {
+showdown.subParser('makehtml.githubCodeBlocks', function (text, options, globals) {
   'use strict';
 
   // early exit if option is not enabled
@@ -16,7 +16,7 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) {
     return text;
   }
 
-  text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.githubCodeBlocks.before', text, options, globals);
 
   text += '¨0';
 
@@ -24,14 +24,14 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) {
     var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
 
     // First parse the github code block
-    codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
-    codeblock = showdown.subParser('detab')(codeblock, options, globals);
+    codeblock = showdown.subParser('makehtml.encodeCode')(codeblock, options, globals);
+    codeblock = showdown.subParser('makehtml.detab')(codeblock, options, globals);
     codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
     codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
 
     codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
 
-    codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
+    codeblock = showdown.subParser('makehtml.hashBlock')(codeblock, options, globals);
 
     // Since GHCodeblocks can be false positives, we need to
     // store the primitive text and the parsed text in a global var,
@@ -42,5 +42,5 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) {
   // attacklab: strip sentinel
   text = text.replace(/¨0/, '');
 
-  return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
+  return globals.converter._dispatch('makehtml.githubCodeBlocks.after', text, options, globals);
 });

+ 8 - 0
src/subParsers/makehtml/hashBlock.js

@@ -0,0 +1,8 @@
+showdown.subParser('makehtml.hashBlock', function (text, options, globals) {
+  'use strict';
+  text = globals.converter._dispatch('makehtml.hashBlock.before', text, options, globals);
+  text = text.replace(/(^\n+|\n+$)/g, '');
+  text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
+  text = globals.converter._dispatch('makehtml.hashBlock.after', text, options, globals);
+  return text;
+});

+ 4 - 4
src/subParsers/hashCodeTags.js → src/subParsers/makehtml/hashCodeTags.js

@@ -1,18 +1,18 @@
 /**
  * Hash and escape <code> elements that should not be parsed as markdown
  */
-showdown.subParser('hashCodeTags', function (text, options, globals) {
+showdown.subParser('makehtml.hashCodeTags', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('hashCodeTags.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashCodeTags.before', text, options, globals);
 
   var repFunc = function (wholeMatch, match, left, right) {
-    var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
+    var codeblock = left + showdown.subParser('makehtml.encodeCode')(match, options, globals) + right;
     return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C';
   };
 
   // Hash naked <code>
   text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim');
 
-  text = globals.converter._dispatch('hashCodeTags.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashCodeTags.after', text, options, globals);
   return text;
 });

+ 1 - 1
src/subParsers/hashElement.js → src/subParsers/makehtml/hashElement.js

@@ -1,4 +1,4 @@
-showdown.subParser('hashElement', function (text, options, globals) {
+showdown.subParser('makehtml.hashElement', function (text, options, globals) {
   'use strict';
 
   return function (wholeMatch, m1) {

+ 5 - 5
src/subParsers/hashHTMLBlocks.js → src/subParsers/makehtml/hashHTMLBlocks.js

@@ -1,6 +1,6 @@
-showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
+showdown.subParser('makehtml.hashHTMLBlocks', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashHTMLBlocks.before', text, options, globals);
 
   var blockTags = [
         'pre',
@@ -82,7 +82,7 @@ showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
   }
   // HR SPECIAL CASE
   text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
-    showdown.subParser('hashElement')(text, options, globals));
+    showdown.subParser('makehtml.hashElement')(text, options, globals));
 
   // Special case for standalone HTML comments
   text = showdown.helper.replaceRecursiveRegExp(text, function (txt) {
@@ -91,8 +91,8 @@ showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
 
   // PHP and ASP-style processor instructions (<?...?> and <%...%>)
   text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
-    showdown.subParser('hashElement')(text, options, globals));
+    showdown.subParser('makehtml.hashElement')(text, options, globals));
 
-  text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashHTMLBlocks.after', text, options, globals);
   return text;
 });

+ 6 - 6
src/subParsers/hashHTMLSpans.js → src/subParsers/makehtml/hashHTMLSpans.js

@@ -1,9 +1,9 @@
 /**
  * Hash span elements that should not be parsed as markdown
  */
-showdown.subParser('hashHTMLSpans', function (text, options, globals) {
+showdown.subParser('makehtml.hashHTMLSpans', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashHTMLSpans.before', text, options, globals);
 
   function hashHTMLSpan (html) {
     return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C';
@@ -31,16 +31,16 @@ showdown.subParser('hashHTMLSpans', function (text, options, globals) {
 
   /*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/
 
-  text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashHTMLSpans.after', text, options, globals);
   return text;
 });
 
 /**
  * Unhash HTML spans
  */
-showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
+showdown.subParser('makehtml.unhashHTMLSpans', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.unhashHTMLSpans.before', text, options, globals);
 
   for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
     var repText = globals.gHtmlSpans[i],
@@ -59,6 +59,6 @@ showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
     text = text.replace('¨C' + i + 'C', repText);
   }
 
-  text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.unhashHTMLSpans.after', text, options, globals);
   return text;
 });

+ 4 - 4
src/subParsers/hashPreCodeTags.js → src/subParsers/makehtml/hashPreCodeTags.js

@@ -1,19 +1,19 @@
 /**
  * Hash and escape <pre><code> elements that should not be parsed as markdown
  */
-showdown.subParser('hashPreCodeTags', function (text, options, globals) {
+showdown.subParser('makehtml.hashPreCodeTags', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashPreCodeTags.before', text, options, globals);
 
   var repFunc = function (wholeMatch, match, left, right) {
     // encode html entities
-    var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
+    var codeblock = left + showdown.subParser('makehtml.encodeCode')(match, options, globals) + right;
     return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
   };
 
   // Hash <pre><code>
   text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim');
 
-  text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.hashPreCodeTags.after', text, options, globals);
   return text;
 });

+ 9 - 9
src/subParsers/headers.js → src/subParsers/makehtml/headers.js

@@ -1,7 +1,7 @@
-showdown.subParser('headers', function (text, options, globals) {
+showdown.subParser('makehtml.headers', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('headers.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.headers.before', text, options, globals);
 
   var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
 
@@ -17,19 +17,19 @@ showdown.subParser('headers', function (text, options, globals) {
 
   text = text.replace(setextRegexH1, function (wholeMatch, m1) {
 
-    var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+    var spanGamut = showdown.subParser('makehtml.spanGamut')(m1, options, globals),
         hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
         hLevel = headerLevelStart,
         hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
-    return showdown.subParser('hashBlock')(hashBlock, options, globals);
+    return showdown.subParser('makehtml.hashBlock')(hashBlock, options, globals);
   });
 
   text = text.replace(setextRegexH2, function (matchFound, m1) {
-    var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+    var spanGamut = showdown.subParser('makehtml.spanGamut')(m1, options, globals),
         hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
         hLevel = headerLevelStart + 1,
         hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
-    return showdown.subParser('hashBlock')(hashBlock, options, globals);
+    return showdown.subParser('makehtml.hashBlock')(hashBlock, options, globals);
   });
 
   // atx-style headers:
@@ -47,12 +47,12 @@ showdown.subParser('headers', function (text, options, globals) {
       hText = m2.replace(/\s?\{([^{]+?)}\s*$/, '');
     }
 
-    var span = showdown.subParser('spanGamut')(hText, options, globals),
+    var span = showdown.subParser('makehtml.spanGamut')(hText, options, globals),
         hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
         hLevel = headerLevelStart - 1 + m1.length,
         header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
 
-    return showdown.subParser('hashBlock')(header, options, globals);
+    return showdown.subParser('makehtml.hashBlock')(header, options, globals);
   });
 
   function headerId (m) {
@@ -121,6 +121,6 @@ showdown.subParser('headers', function (text, options, globals) {
     return title;
   }
 
-  text = globals.converter._dispatch('headers.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.headers.after', text, options, globals);
   return text;
 });

+ 15 - 0
src/subParsers/makehtml/horizontalRule.js

@@ -0,0 +1,15 @@
+/**
+ * Turn Markdown link shortcuts into XHTML <a> tags.
+ */
+showdown.subParser('makehtml.horizontalRule', function (text, options, globals) {
+  'use strict';
+  text = globals.converter._dispatch('makehtml.horizontalRule.before', text, options, globals);
+
+  var key = showdown.subParser('makehtml.hashBlock')('<hr />', options, globals);
+  text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
+  text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
+  text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
+
+  text = globals.converter._dispatch('makehtml.horizontalRule.after', text, options, globals);
+  return text;
+});

+ 3 - 3
src/subParsers/images.js → src/subParsers/makehtml/images.js

@@ -1,10 +1,10 @@
 /**
  * Turn Markdown image shortcuts into <img> tags.
  */
-showdown.subParser('images', function (text, options, globals) {
+showdown.subParser('makehtml.images', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('images.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.images.before', text, options, globals);
 
   var inlineRegExp      = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
       crazyRegExp       = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
@@ -99,6 +99,6 @@ showdown.subParser('images', function (text, options, globals) {
   // handle reference-style shortcuts: ![img text]
   text = text.replace(refShortcutRegExp, writeImageTag);
 
-  text = globals.converter._dispatch('images.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.images.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/italicsAndBold.js → src/subParsers/makehtml/italicsAndBold.js

@@ -1,7 +1,7 @@
-showdown.subParser('italicsAndBold', function (text, options, globals) {
+showdown.subParser('makehtml.italicsAndBold', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.italicsAndBold.before', text, options, globals);
 
   // it's faster to have 3 separate regexes for each case than have just one
   // because of backtracing, in some cases, it could lead to an exponential effect
@@ -65,6 +65,6 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
   }
 
 
-  text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.italicsAndBold.after', text, options, globals);
   return text;
 });

+ 9 - 9
src/subParsers/lists.js → src/subParsers/makehtml/lists.js

@@ -1,7 +1,7 @@
 /**
  * Form HTML ordered (numbered) and unordered (bulleted) lists.
  */
-showdown.subParser('lists', function (text, options, globals) {
+showdown.subParser('makehtml.lists', function (text, options, globals) {
   'use strict';
 
   /**
@@ -53,7 +53,7 @@ showdown.subParser('lists', function (text, options, globals) {
     listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
       checked = (checked && checked.trim() !== '');
 
-      var item = showdown.subParser('outdent')(m4, options, globals),
+      var item = showdown.subParser('makehtml.outdent')(m4, options, globals),
           bulletStyle = '';
 
       // Support for github tasklists
@@ -85,20 +85,20 @@ showdown.subParser('lists', function (text, options, globals) {
       // Has a double return (multi paragraph) or
       // Has sublist
       if (m1 || (item.search(/\n{2,}/) > -1)) {
-        item = showdown.subParser('githubCodeBlocks')(item, options, globals);
-        item = showdown.subParser('blockGamut')(item, options, globals);
+        item = showdown.subParser('makehtml.githubCodeBlocks')(item, options, globals);
+        item = showdown.subParser('makehtml.blockGamut')(item, options, globals);
       } else {
         // Recursion for sub-lists:
-        item = showdown.subParser('lists')(item, options, globals);
+        item = showdown.subParser('makehtml.lists')(item, options, globals);
         item = item.replace(/\n$/, ''); // chomp(item)
-        item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
+        item = showdown.subParser('makehtml.hashHTMLBlocks')(item, options, globals);
 
         // Colapse double linebreaks
         item = item.replace(/\n\n+/g, '\n\n');
         if (isParagraphed) {
-          item = showdown.subParser('paragraphs')(item, options, globals);
+          item = showdown.subParser('makehtml.paragraphs')(item, options, globals);
         } else {
-          item = showdown.subParser('spanGamut')(item, options, globals);
+          item = showdown.subParser('makehtml.spanGamut')(item, options, globals);
         }
       }
 
@@ -198,6 +198,6 @@ showdown.subParser('lists', function (text, options, globals) {
 
   // strip sentinel
   text = text.replace(/¨0/, '');
-  text = globals.converter._dispatch('lists.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.lists.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/metadata.js → src/subParsers/makehtml/metadata.js

@@ -1,14 +1,14 @@
 /**
  * Parse metadata at the top of the document
  */
-showdown.subParser('metadata', function (text, options, globals) {
+showdown.subParser('makehtml.metadata', function (text, options, globals) {
   'use strict';
 
   if (!options.metadata) {
     return text;
   }
 
-  text = globals.converter._dispatch('metadata.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.metadata.before', text, options, globals);
 
   function parseMetadataContents (content) {
     // raw is raw so it's not changed in any way
@@ -44,6 +44,6 @@ showdown.subParser('metadata', function (text, options, globals) {
 
   text = text.replace(/¨M/g, '');
 
-  text = globals.converter._dispatch('metadata.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.metadata.after', text, options, globals);
   return text;
 });

+ 3 - 3
src/subParsers/outdent.js → src/subParsers/makehtml/outdent.js

@@ -1,9 +1,9 @@
 /**
  * Remove one level of line-leading tabs or spaces
  */
-showdown.subParser('outdent', function (text, options, globals) {
+showdown.subParser('makehtml.outdent', function (text, options, globals) {
   'use strict';
-  text = globals.converter._dispatch('outdent.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.outdent.before', text, options, globals);
 
   // attacklab: hack around Konqueror 3.5.4 bug:
   // "----------bug".replace(/^-/g,"") == "bug"
@@ -12,6 +12,6 @@ showdown.subParser('outdent', function (text, options, globals) {
   // attacklab: clean up hack
   text = text.replace(/¨0/g, '');
 
-  text = globals.converter._dispatch('outdent.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.outdent.after', text, options, globals);
   return text;
 });

+ 5 - 5
src/subParsers/paragraphs.js → src/subParsers/makehtml/paragraphs.js

@@ -1,10 +1,10 @@
 /**
  *
  */
-showdown.subParser('paragraphs', function (text, options, globals) {
+showdown.subParser('makehtml.paragraphs', function (text, options, globals) {
   'use strict';
 
-  text = globals.converter._dispatch('paragraphs.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.paragraphs.before', text, options, globals);
   // Strip leading and trailing lines:
   text = text.replace(/^\n+/g, '');
   text = text.replace(/\n+$/g, '');
@@ -22,7 +22,7 @@ showdown.subParser('paragraphs', function (text, options, globals) {
     // test for presence of characters to prevent empty lines being parsed
     // as paragraphs (resulting in undesired extra empty paragraphs)
     } else if (str.search(/\S/) >= 0) {
-      str = showdown.subParser('spanGamut')(str, options, globals);
+      str = showdown.subParser('makehtml.spanGamut')(str, options, globals);
       str = str.replace(/^([ \t]*)/g, '<p>');
       str += '</p>';
       grafsOut.push(str);
@@ -47,7 +47,7 @@ showdown.subParser('paragraphs', function (text, options, globals) {
         // we need to check if ghBlock is a false positive
         if (codeFlag) {
           // use encoded version of all text
-          blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
+          blockText = showdown.subParser('makehtml.encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
         } else {
           blockText = globals.ghCodeBlocks[num].codeblock;
         }
@@ -66,5 +66,5 @@ showdown.subParser('paragraphs', function (text, options, globals) {
   // Strip leading and trailing lines:
   text = text.replace(/^\n+/g, '');
   text = text.replace(/\n+$/g, '');
-  return globals.converter._dispatch('paragraphs.after', text, options, globals);
+  return globals.converter._dispatch('makehtml.paragraphs.after', text, options, globals);
 });

+ 1 - 1
src/subParsers/runExtension.js → src/subParsers/makehtml/runExtension.js

@@ -1,7 +1,7 @@
 /**
  * Run extension
  */
-showdown.subParser('runExtension', function (ext, text, options, globals) {
+showdown.subParser('makehtml.runExtension', function (ext, text, options, globals) {
   'use strict';
 
   if (ext.filter) {

+ 49 - 0
src/subParsers/makehtml/spanGamut.js

@@ -0,0 +1,49 @@
+/**
+ * These are all the transformations that occur *within* block-level
+ * tags like paragraphs, headers, and list items.
+ */
+showdown.subParser('makehtml.spanGamut', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('smakehtml.panGamut.before', text, options, globals);
+  text = showdown.subParser('makehtml.codeSpans')(text, options, globals);
+  text = showdown.subParser('makehtml.escapeSpecialCharsWithinTagAttributes')(text, options, globals);
+  text = showdown.subParser('makehtml.encodeBackslashEscapes')(text, options, globals);
+
+  // Process anchor and image tags. Images must come first,
+  // because ![foo][f] looks like an anchor.
+  text = showdown.subParser('makehtml.images')(text, options, globals);
+  text = showdown.subParser('makehtml.anchors')(text, options, globals);
+
+  // Make links out of things like `<http://example.com/>`
+  // Must come after anchors, because you can use < and >
+  // delimiters in inline links like [this](<url>).
+  text = showdown.subParser('makehtml.autoLinks')(text, options, globals);
+  text = showdown.subParser('makehtml.simplifiedAutoLinks')(text, options, globals);
+  text = showdown.subParser('makehtml.emoji')(text, options, globals);
+  text = showdown.subParser('makehtml.underline')(text, options, globals);
+  text = showdown.subParser('makehtml.italicsAndBold')(text, options, globals);
+  text = showdown.subParser('makehtml.strikethrough')(text, options, globals);
+  text = showdown.subParser('makehtml.ellipsis')(text, options, globals);
+
+  // we need to hash HTML tags inside spans
+  text = showdown.subParser('makehtml.hashHTMLSpans')(text, options, globals);
+
+  // now we encode amps and angles
+  text = showdown.subParser('makehtml.encodeAmpsAndAngles')(text, options, globals);
+
+  // Do hard breaks
+  if (options.simpleLineBreaks) {
+    // GFM style hard breaks
+    // only add line breaks if the text does not contain a block (special case for lists)
+    if (!/\n\n¨K/.test(text)) {
+      text = text.replace(/\n+/g, '<br />\n');
+    }
+  } else {
+    // Vanilla hard breaks
+    text = text.replace(/  +\n/g, '<br />\n');
+  }
+
+  text = globals.converter._dispatch('makehtml.spanGamut.after', text, options, globals);
+  return text;
+});

+ 18 - 0
src/subParsers/makehtml/strikethrough.js

@@ -0,0 +1,18 @@
+showdown.subParser('makehtml.strikethrough', function (text, options, globals) {
+  'use strict';
+
+  function parseInside (txt) {
+    if (options.simplifiedAutoLink) {
+      txt = showdown.subParser('makehtml.simplifiedAutoLinks')(txt, options, globals);
+    }
+    return '<del>' + txt + '</del>';
+  }
+
+  if (options.strikethrough) {
+    text = globals.converter._dispatch('makehtml.strikethrough.before', text, options, globals);
+    text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
+    text = globals.converter._dispatch('makehtml.strikethrough.after', text, options, globals);
+  }
+
+  return text;
+});

+ 2 - 2
src/subParsers/stripLinkDefinitions.js → src/subParsers/makehtml/stripLinkDefinitions.js

@@ -3,7 +3,7 @@
  * hash references.
  * Link defs are in the form: ^[id]: url "optional title"
  */
-showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
+showdown.subParser('makehtml.stripLinkDefinitions', function (text, options, globals) {
   'use strict';
 
   var regex       = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
@@ -18,7 +18,7 @@ showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
       // remove newlines
       globals.gUrls[linkId] = url.replace(/\s/g, '');
     } else {
-      globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals);  // Link IDs are case-insensitive
+      globals.gUrls[linkId] = showdown.subParser('makehtml.encodeAmpsAndAngles')(url, options, globals);  // Link IDs are case-insensitive
     }
 
     if (blankLines) {

+ 6 - 6
src/subParsers/tables.js → src/subParsers/makehtml/tables.js

@@ -1,4 +1,4 @@
-showdown.subParser('tables', function (text, options, globals) {
+showdown.subParser('makehtml.tables', function (text, options, globals) {
   'use strict';
 
   if (!options.tables) {
@@ -28,13 +28,13 @@ showdown.subParser('tables', function (text, options, globals) {
     if (options.tablesHeaderId || options.tableHeaderId) {
       id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
     }
-    header = showdown.subParser('spanGamut')(header, options, globals);
+    header = showdown.subParser('makehtml.spanGamut')(header, options, globals);
 
     return '<th' + id + style + '>' + header + '</th>\n';
   }
 
   function parseCells (cell, style) {
-    var subText = showdown.subParser('spanGamut')(cell, options, globals);
+    var subText = showdown.subParser('makehtml.spanGamut')(cell, options, globals);
     return '<td' + style + '>' + subText + '</td>\n';
   }
 
@@ -70,7 +70,7 @@ showdown.subParser('tables', function (text, options, globals) {
         tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
       }
       // parse code spans first, but we only support one line code spans
-      tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals);
+      tableLines[i] = showdown.subParser('makehtml.codeSpans')(tableLines[i], options, globals);
     }
 
     var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
@@ -125,7 +125,7 @@ showdown.subParser('tables', function (text, options, globals) {
     return buildTable(headers, cells);
   }
 
-  text = globals.converter._dispatch('tables.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.tables.before', text, options, globals);
 
   // find escaped pipe characters
   text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback);
@@ -136,7 +136,7 @@ showdown.subParser('tables', function (text, options, globals) {
   // parse one column tables
   text = text.replace(singeColTblRgx, parseTable);
 
-  text = globals.converter._dispatch('tables.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.tables.after', text, options, globals);
 
   return text;
 });

+ 3 - 3
src/subParsers/underline.js → src/subParsers/makehtml/underline.js

@@ -1,11 +1,11 @@
-showdown.subParser('underline', function (text, options, globals) {
+showdown.subParser('makehtml.underline', function (text, options, globals) {
   'use strict';
 
   if (!options.underline) {
     return text;
   }
 
-  text = globals.converter._dispatch('underline.before', text, options, globals);
+  text = globals.converter._dispatch('makehtml.underline.before', text, options, globals);
 
   if (options.literalMidWordUnderscores) {
     text = text.replace(/\b_?__(\S[\s\S]*)___?\b/g, function (wm, txt) {
@@ -20,7 +20,7 @@ showdown.subParser('underline', function (text, options, globals) {
   // escape remaining underscores to prevent them being parsed by italic and bold
   text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback);
 
-  text = globals.converter._dispatch('underline.after', text, options, globals);
+  text = globals.converter._dispatch('makehtml.underline.after', text, options, globals);
 
   return text;
 });

+ 15 - 0
src/subParsers/makehtml/unescapeSpecialChars.js

@@ -0,0 +1,15 @@
+/**
+ * Swap back in all the special characters we've hidden.
+ */
+showdown.subParser('makehtml.unescapeSpecialChars', function (text, options, globals) {
+  'use strict';
+  text = globals.converter._dispatch('makehtml.unescapeSpecialChars.before', text, options, globals);
+
+  text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) {
+    var charCodeToReplace = parseInt(m1);
+    return String.fromCharCode(charCodeToReplace);
+  });
+
+  text = globals.converter._dispatch('makehtml.unescapeSpecialChars.after', text, options, globals);
+  return text;
+});

+ 0 - 49
src/subParsers/spanGamut.js

@@ -1,49 +0,0 @@
-/**
- * These are all the transformations that occur *within* block-level
- * tags like paragraphs, headers, and list items.
- */
-showdown.subParser('spanGamut', function (text, options, globals) {
-  'use strict';
-
-  text = globals.converter._dispatch('spanGamut.before', text, options, globals);
-  text = showdown.subParser('codeSpans')(text, options, globals);
-  text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
-  text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
-
-  // Process anchor and image tags. Images must come first,
-  // because ![foo][f] looks like an anchor.
-  text = showdown.subParser('images')(text, options, globals);
-  text = showdown.subParser('anchors')(text, options, globals);
-
-  // Make links out of things like `<http://example.com/>`
-  // Must come after anchors, because you can use < and >
-  // delimiters in inline links like [this](<url>).
-  text = showdown.subParser('autoLinks')(text, options, globals);
-  text = showdown.subParser('simplifiedAutoLinks')(text, options, globals);
-  text = showdown.subParser('emoji')(text, options, globals);
-  text = showdown.subParser('underline')(text, options, globals);
-  text = showdown.subParser('italicsAndBold')(text, options, globals);
-  text = showdown.subParser('strikethrough')(text, options, globals);
-  text = showdown.subParser('ellipsis')(text, options, globals);
-
-  // we need to hash HTML tags inside spans
-  text = showdown.subParser('hashHTMLSpans')(text, options, globals);
-
-  // now we encode amps and angles
-  text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
-
-  // Do hard breaks
-  if (options.simpleLineBreaks) {
-    // GFM style hard breaks
-    // only add line breaks if the text does not contain a block (special case for lists)
-    if (!/\n\n¨K/.test(text)) {
-      text = text.replace(/\n+/g, '<br />\n');
-    }
-  } else {
-    // Vanilla hard breaks
-    text = text.replace(/  +\n/g, '<br />\n');
-  }
-
-  text = globals.converter._dispatch('spanGamut.after', text, options, globals);
-  return text;
-});

+ 0 - 18
src/subParsers/strikethrough.js

@@ -1,18 +0,0 @@
-showdown.subParser('strikethrough', function (text, options, globals) {
-  'use strict';
-
-  function parseInside (txt) {
-    if (options.simplifiedAutoLink) {
-      txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
-    }
-    return '<del>' + txt + '</del>';
-  }
-
-  if (options.strikethrough) {
-    text = globals.converter._dispatch('strikethrough.before', text, options, globals);
-    text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
-    text = globals.converter._dispatch('strikethrough.after', text, options, globals);
-  }
-
-  return text;
-});

+ 0 - 15
src/subParsers/unescapeSpecialChars.js

@@ -1,15 +0,0 @@
-/**
- * Swap back in all the special characters we've hidden.
- */
-showdown.subParser('unescapeSpecialChars', function (text, options, globals) {
-  'use strict';
-  text = globals.converter._dispatch('unescapeSpecialChars.before', text, options, globals);
-
-  text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) {
-    var charCodeToReplace = parseInt(m1);
-    return String.fromCharCode(charCodeToReplace);
-  });
-
-  text = globals.converter._dispatch('unescapeSpecialChars.after', text, options, globals);
-  return text;
-});

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff