2015-01-16 05:21:33 +08:00
|
|
|
/**
|
|
|
|
* Smart processing for ampersands and angle brackets that need to be encoded.
|
|
|
|
*/
|
|
|
|
showdown.subParser('encodeAmpsAndAngles', function (text) {
|
2015-01-19 19:37:21 +08:00
|
|
|
'use strict';
|
|
|
|
// 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, '&');
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
// Encode naked <'s
|
|
|
|
text = text.replace(/<(?![a-z\/?\$!])/gi, '<');
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
return text;
|
2015-01-16 05:21:33 +08:00
|
|
|
});
|