mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(subParsers/codeSpans): Fix issue with code html tags not being correctly escaped
This commit is contained in:
parent
220b85d722
commit
5f043ca46d
|
@ -26,6 +26,14 @@
|
|||
showdown.subParser('codeSpans', function (text) {
|
||||
'use strict';
|
||||
|
||||
//special case -> literal html code tag
|
||||
text = text.replace(/(<code[^><]*?>)([^]*?)<\/code>/g, function (wholeMatch, tag, c) {
|
||||
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
|
||||
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
|
||||
c = showdown.subParser('encodeCode')(c);
|
||||
return tag + c + '</code>';
|
||||
});
|
||||
|
||||
/*
|
||||
text = text.replace(/
|
||||
(^|[^\\]) // Character before opening ` can't be a backslash
|
||||
|
@ -38,8 +46,8 @@ showdown.subParser('codeSpans', function (text) {
|
|||
(?!`)
|
||||
/gm, function(){...});
|
||||
*/
|
||||
|
||||
text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function (wholeMatch, m1, m2, m3) {
|
||||
text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
|
||||
function (wholeMatch, m1, m2, m3) {
|
||||
var c = m3;
|
||||
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
|
||||
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
|
||||
|
@ -48,5 +56,4 @@ showdown.subParser('codeSpans', function (text) {
|
|||
});
|
||||
|
||||
return text;
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user