mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
19 lines
507 B
JavaScript
19 lines
507 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, '<');
|
||
|
|
||
|
return text;
|
||
|
});
|