diff --git a/lib/jsdoc/tutorial.js b/lib/jsdoc/tutorial.js index a20b9c70..15859c40 100644 --- a/lib/jsdoc/tutorial.js +++ b/lib/jsdoc/tutorial.js @@ -90,10 +90,7 @@ exports.Tutorial.prototype.parse = function() { // markdown case exports.TYPES.MARKDOWN: var mdParse = markdown.getParser(); - return mdParse(this.content) - .replace(/&/g, '&') // because markdown escapes these - .replace(/</g, '<') - .replace(/>/g, '>'); + return mdParse(this.content); // uhm... should we react somehow? // if not then this case can be merged with TYPES.HTML diff --git a/test/specs/jsdoc/tutorial.js b/test/specs/jsdoc/tutorial.js index 0b62851c..740800ad 100644 --- a/test/specs/jsdoc/tutorial.js +++ b/test/specs/jsdoc/tutorial.js @@ -1,4 +1,4 @@ -/*global afterEach, describe, expect, it */ +/*global afterEach, beforeEach, describe, expect, it */ describe('jsdoc/tutorial', function() { var tutorial = require('jsdoc/tutorial'); @@ -10,6 +10,9 @@ describe('jsdoc/tutorial', function() { tutorial.TYPES.MARKDOWN); var par2 = new tutorial.Tutorial('parent2', '

This is the second parent tutorial

', tutorial.TYPES.HTML); + var markdownEntities = new tutorial.Tutorial('markdown-entities', + '
This Markdown tutorial contains HTML entities: & < >
', + tutorial.TYPES.MARKDOWN); it('module should exist', function() { expect(tutorial).toBeDefined(); @@ -210,6 +213,10 @@ describe('jsdoc/tutorial', function() { global.env.conf.markdown = config; } + beforeEach(function() { + setMarkdownConfig({parser: 'marked'}); + }); + afterEach(function() { global.env.conf.markdown = markdownConfig; }); @@ -219,8 +226,12 @@ describe('jsdoc/tutorial', function() { }); it('Tutorials with MARKDOWN type go through the markdown parser, respecting configuration options', function() { - setMarkdownConfig({parser: 'marked'}); - expect(par.parse()).toBe("

This is the parent tutorial's content & stuff A_B X_Y

"); + expect(par.parse()).toBe("

This is the parent tutorial's content & stuff A_B X_Y

"); + }); + + it('Tutorials with MARKDOWN type preserve &/</> entities', function() { + expect(markdownEntities.parse()) + .toBe('
This Markdown tutorial contains HTML entities: & < >
'); }); it('Tutorials with unrecognised type are returned as-is', function() {