diff --git a/lib/handlers/inline-code.js b/lib/handlers/inline-code.js index 986de52..914016b 100644 --- a/lib/handlers/inline-code.js +++ b/lib/handlers/inline-code.js @@ -2,9 +2,9 @@ module.exports = inlineCode -var collapse = require('collapse-white-space') var u = require('unist-builder') function inlineCode(h, node) { - return h(node, 'code', [u('text', collapse(node.value))]) + var value = node.value.replace(/\r?\n|\r/g, ' ') + return h(node, 'code', [u('text', value)]) } diff --git a/package.json b/package.json index f081e1b..f217326 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "dependencies": { "@types/mdast": "^3.0.0", "@types/unist": "^2.0.3", - "collapse-white-space": "^1.0.0", "detab": "^2.0.0", "mdast-util-definitions": "^3.0.0", "mdurl": "^1.0.0", diff --git a/test/inline-code.js b/test/inline-code.js index 34694b5..96aa2c5 100644 --- a/test/inline-code.js +++ b/test/inline-code.js @@ -11,5 +11,17 @@ test('InlineCode', function (t) { 'should transform `inlineCode` to a `code` element' ) + t.deepEqual( + to(u('inlineCode', 'a\tb')), + u('element', {tagName: 'code', properties: {}}, [u('text', 'a\tb')]), + 'should support tabs in inline code' + ) + + t.deepEqual( + to(u('inlineCode', 'a\nb')), + u('element', {tagName: 'code', properties: {}}, [u('text', 'a b')]), + 'should change eols to spaces in inline code' + ) + t.end() })