diff --git a/packages/api-explorer/__tests__/lib/__snapshots__/markdown.test.js.snap b/packages/api-explorer/__tests__/lib/__snapshots__/markdown.test.js.snap index c48d58a81..e1a227fc7 100644 --- a/packages/api-explorer/__tests__/lib/__snapshots__/markdown.test.js.snap +++ b/packages/api-explorer/__tests__/lib/__snapshots__/markdown.test.js.snap @@ -25,7 +25,7 @@ exports[`code samples 1`] = ` `; exports[`emojis 1`] = ` -"
+"
:unknown-emoji:
Test
')).toBe('Test
\n'); expect(markdown('Test
', { stripHtml: false })).toBe('Test
\n'); diff --git a/packages/api-explorer/src/lib/markdown/index.js b/packages/api-explorer/src/lib/markdown/index.js index e78671e34..3c32b1dc8 100644 --- a/packages/api-explorer/src/lib/markdown/index.js +++ b/packages/api-explorer/src/lib/markdown/index.js @@ -15,7 +15,7 @@ sanitizeSchema.attributes['readme-variable'] = ['variable']; sanitizeSchema.attributes.i = ['className']; // This is for `emoji` class name -sanitizeSchema.attributes.img = ['className']; +sanitizeSchema.attributes.img.push('className'); // This is for code blocks class name sanitizeSchema.attributes.code = ['className']; @@ -113,6 +113,8 @@ module.exports = function markdown(text, opts = {}) { }; } + if (!text) return null; + return remark() .use(variableParser) .use(!opts.correctnewlines ? breaks : function () {})