mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
7d63a3e635
This commit adds events to all subparsers (that were previously not being watched).
18 lines
649 B
JavaScript
18 lines
649 B
JavaScript
/**
|
|
* Smart processing for ampersands and angle brackets that need to be encoded.
|
|
*/
|
|
showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
|
|
'use strict';
|
|
text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals);
|
|
|
|
// Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
|
|
// http://bumppo.net/projects/amputator/
|
|
text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&');
|
|
|
|
// Encode naked <'s
|
|
text = text.replace(/<(?![a-z\/?\$!])/gi, '<');
|
|
|
|
text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals);
|
|
return text;
|
|
});
|