diff --git a/lib/plugin/html-auto-escape.js b/lib/plugin/html-auto-escape.js new file mode 100644 index 0000000..f6b1d81 --- /dev/null +++ b/lib/plugin/html-auto-escape.js @@ -0,0 +1,35 @@ +// This plugin automatically escapes certain HTML tags in html_block tokens +// because that's what GitHub does. For example, given the markdown input +// +//
Put your rules in a `
+ + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/test/markdown.js b/test/markdown.js index c279d01..ad8348b 100644 --- a/test/markdown.js +++ b/test/markdown.js @@ -2,6 +2,7 @@ var assert = require('assert') var marky = require('..') +var sanitize = require('../lib/sanitize') var fixtures = require('./fixtures') var cheerio = require('cheerio') @@ -149,6 +150,57 @@ describe('markdown processing', function () { assert($('a[href="or%20is%20it"]').length) }) }) + + describe('auto-escaping HTML', function () { + var $doc + var html + before(function () { + $doc = cheerio.load(marky(fixtures['html-auto-escape'])) + html = $doc.html() + }) + + it('auto-escapes