dont double escape certain entities/character references, fix encoding test
This commit is contained in:
parent
9ab262b2cd
commit
b702e91a10
@ -332,7 +332,7 @@ inline.lexer = function(str) {
|
||||
if (cap = inline.code.exec(str)) {
|
||||
str = str.substring(cap[0].length);
|
||||
out += '<code>'
|
||||
+ escape(cap[2] || cap[1])
|
||||
+ escape(cap[2] || cap[1], true)
|
||||
+ '</code>';
|
||||
continue;
|
||||
}
|
||||
@ -413,7 +413,7 @@ var tok = function() {
|
||||
}
|
||||
case 'code': {
|
||||
return '<pre><code>'
|
||||
+ escape(token.text)
|
||||
+ escape(token.text, true)
|
||||
+ '</code></pre>';
|
||||
}
|
||||
case 'blockquote_start': {
|
||||
@ -508,9 +508,11 @@ var parse = function(src) {
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
var escape = function(html) {
|
||||
var escape = function(html, dbl) {
|
||||
return html
|
||||
.replace(/&/g, '&')
|
||||
.replace(!dbl
|
||||
? /&(?!#?\w+;)/g
|
||||
: /&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
|
@ -51,16 +51,11 @@ fs.readdirSync(dir).forEach(function(file) {
|
||||
fs.writeFileSync(file, text);
|
||||
});
|
||||
|
||||
// markdown avoids double encoding half of the time
|
||||
// and does it the other half. this behavior will be
|
||||
// implemented eventually, but for now, this needs to
|
||||
// be changed, because i want to see if the other tests
|
||||
// included in this file pass.
|
||||
// markdown is weird with encoding
|
||||
(function() {
|
||||
var file = dir + '/amps_and_angles_encoding.html';
|
||||
var html = fs.readFileSync(file, 'utf8')
|
||||
.replace('6 > 5.', '6 > 5.')
|
||||
.replace('AT&T is another', 'AT&amp;T is another');
|
||||
|
||||
fs.writeFileSync(file, html);
|
||||
})();
|
||||
|
@ -1,6 +1,6 @@
|
||||
<p>AT&T has an ampersand in their name.</p>
|
||||
|
||||
<p>AT&amp;T is another way to write it.</p>
|
||||
<p>AT&T is another way to write it.</p>
|
||||
|
||||
<p>This & that.</p>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user