showdown/src/subParsers/encodeAmpsAndAngles.js
Estevão Soares dos Santos 8b000b134a chore(all): code style change
2015-01-19 11:37:21 +00:00

19 lines
493 B
JavaScript

/**
* Created by Estevao on 11-01-2015.
*/
/**
* Smart processing for ampersands and angle brackets that need to be encoded.
*/
showdown.subParser('encodeAmpsAndAngles', function (text) {
'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, '&');
// Encode naked <'s
text = text.replace(/<(?![a-z\/?\$!])/gi, '&lt;');
return text;
});