Skip to content

Commit e0726a6

Browse files
Estevão Soares dos SantosEstevão Soares dos Santos
authored andcommitted
feature(evt_listeners): make globals var accessible to listeners
1 parent 452c428 commit e0726a6

20 files changed

Lines changed: 71 additions & 69 deletions

dist/showdown.js

Lines changed: 34 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/converter.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,13 @@ showdown.Converter = function (converterOptions) {
195195
* @param {string} evtName Event name
196196
* @param {string} text Text
197197
* @param {{}} options Converter Options
198+
* @param {{}} globals
198199
* @returns {string}
199200
*/
200-
this._dispatch = function dispatch (evtName, text, options) {
201+
this._dispatch = function dispatch (evtName, text, options, globals) {
201202
if (listeners.hasOwnProperty(evtName)) {
202203
for (var ei = 0; ei < listeners[evtName].length; ++ei) {
203-
var nText = listeners[evtName][ei](evtName, text, this, options);
204+
var nText = listeners[evtName][ei](evtName, text, this, options, globals);
204205
if (nText && typeof nText !== 'undefined') {
205206
text = nText;
206207
}

src/subParsers/anchors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
showdown.subParser('anchors', function (text, options, globals) {
55
'use strict';
66

7-
text = globals.converter._dispatch('anchors.before', text, options);
7+
text = globals.converter._dispatch('anchors.before', text, options, globals);
88

99
var writeAnchorTag = function (wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
1010
if (showdown.helper.isUndefined(m7)) {
@@ -128,6 +128,6 @@ showdown.subParser('anchors', function (text, options, globals) {
128128
*/
129129
text = text.replace(/(\[([^\[\]]+)])()()()()()/g, writeAnchorTag);
130130

131-
text = globals.converter._dispatch('anchors.after', text, options);
131+
text = globals.converter._dispatch('anchors.after', text, options, globals);
132132
return text;
133133
});

src/subParsers/autoLinks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
showdown.subParser('autoLinks', function (text, options, globals) {
22
'use strict';
33

4-
text = globals.converter._dispatch('autoLinks.before', text, options);
4+
text = globals.converter._dispatch('autoLinks.before', text, options, globals);
55

66
var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi,
77
delimUrlRegex = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi,
@@ -23,7 +23,7 @@ showdown.subParser('autoLinks', function (text, options, globals) {
2323
return showdown.subParser('encodeEmailAddress')(unescapedStr);
2424
}
2525

26-
text = globals.converter._dispatch('autoLinks.after', text, options);
26+
text = globals.converter._dispatch('autoLinks.after', text, options, globals);
2727

2828
return text;
2929
});

src/subParsers/blockGamut.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
showdown.subParser('blockGamut', function (text, options, globals) {
66
'use strict';
77

8-
text = globals.converter._dispatch('blockGamut.before', text, options);
8+
text = globals.converter._dispatch('blockGamut.before', text, options, globals);
99

1010
// we parse blockquotes first so that we can have headings and hrs
1111
// inside blockquotes
@@ -29,7 +29,7 @@ showdown.subParser('blockGamut', function (text, options, globals) {
2929
text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
3030
text = showdown.subParser('paragraphs')(text, options, globals);
3131

32-
text = globals.converter._dispatch('blockGamut.after', text, options);
32+
text = globals.converter._dispatch('blockGamut.after', text, options, globals);
3333

3434
return text;
3535
});

src/subParsers/blockQuotes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
showdown.subParser('blockQuotes', function (text, options, globals) {
22
'use strict';
33

4-
text = globals.converter._dispatch('blockQuotes.before', text, options);
4+
text = globals.converter._dispatch('blockQuotes.before', text, options, globals);
55
/*
66
text = text.replace(/
77
( // Wrap whole match in $1
@@ -42,6 +42,6 @@ showdown.subParser('blockQuotes', function (text, options, globals) {
4242
return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
4343
});
4444

45-
text = globals.converter._dispatch('blockQuotes.after', text, options);
45+
text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
4646
return text;
4747
});

src/subParsers/codeBlocks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
showdown.subParser('codeBlocks', function (text, options, globals) {
55
'use strict';
66

7-
text = globals.converter._dispatch('codeBlocks.before', text, options);
7+
text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
88
/*
99
text = text.replace(text,
1010
/(?:\n\n|^)
@@ -45,6 +45,6 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
4545
// attacklab: strip sentinel
4646
text = text.replace(/~0/, '');
4747

48-
text = globals.converter._dispatch('codeBlocks.after', text, options);
48+
text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
4949
return text;
5050
});

0 commit comments

Comments
 (0)