Skip to content

Commit

Permalink
feat(events): add events to all subparsers
Browse files Browse the repository at this point in the history
This commit adds events to all subparsers (that were previously not being watched).
  • Loading branch information
tivie committed Jan 29, 2017
1 parent fd01474 commit 7d63a3e
Show file tree
Hide file tree
Showing 25 changed files with 126 additions and 77 deletions.
97 changes: 60 additions & 37 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,13 @@ showdown.Converter = function (converterOptions) {
// detab
text = showdown.subParser('detab')(text, options, globals);

// stripBlankLines
text = showdown.subParser('stripBlankLines')(text, options, globals);
/**
* Strip any lines consisting only of spaces and tabs.
* This makes subsequent regexs easier to write, because we can
* match consecutive blank lines with /\n+/ instead of something
* contorted like /[ \t]*\n+/
*/
text = text.replace(/^[ \t]+$/mg, '');

//run languageExtensions
showdown.helper.forEach(langExtensions, function (ext) {
Expand Down
2 changes: 1 addition & 1 deletion src/subParsers/autoLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ showdown.subParser('autoLinks', function (text, options, globals) {
function replaceMail(wholeMatch, b, mail) {
var href = 'mailto:';
b = b || '';
mail = showdown.subParser('unescapeSpecialChars')(mail);
mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
if (options.encodeEmails) {
mail = showdown.helper.encodeEmailAddress(mail);
href = showdown.helper.encodeEmailAddress(href + mail);
Expand Down
6 changes: 3 additions & 3 deletions src/subParsers/codeBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
nextChar = m2,
end = '\n';

codeblock = showdown.subParser('outdent')(codeblock);
codeblock = showdown.subParser('encodeCode')(codeblock);
codeblock = showdown.subParser('detab')(codeblock);
codeblock = showdown.subParser('outdent')(codeblock, options, globals);
codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
codeblock = showdown.subParser('detab')(codeblock, options, globals);
codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines

Expand Down
2 changes: 1 addition & 1 deletion src/subParsers/codeSpans.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ 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);
c = showdown.subParser('encodeCode')(c, options, globals);
return m1 + '<code>' + c + '</code>';
}
);
Expand Down
5 changes: 3 additions & 2 deletions src/subParsers/detab.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* Convert all tabs to spaces
*/
showdown.subParser('detab', function (text) {
showdown.subParser('detab', function (text, options, globals) {
'use strict';
text = globals.converter._dispatch('detab.before', text, options, globals);

// expand first n-1 tabs
text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
Expand All @@ -27,6 +28,6 @@ showdown.subParser('detab', function (text) {
text = text.replace(/¨A/g, ' '); // g_tab_width
text = text.replace(/¨B/g, '');

text = globals.converter._dispatch('detab.after', text, options, globals);
return text;

});
Loading

0 comments on commit 7d63a3e

Please sign in to comment.