Skip to content

Commit 0bc95f3

Browse files
committed
Fix bug in code handling where content wasn’t trimmed
1 parent ba6a207 commit 0bc95f3

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/handlers/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = code;
55
var is = require('hast-util-is-element');
66
var has = require('hast-util-has-property');
77
var toString = require('hast-util-to-string');
8+
var trim = require('trim-trailing-lines');
89

910
var prefix = 'language-';
1011

@@ -40,5 +41,5 @@ function code(h, node) {
4041
}
4142
}
4243

43-
return h(node, 'code', {lang: lang || null}, toString(node));
44+
return h(node, 'code', {lang: lang || null}, trim(toString(node)));
4445
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"hast-util-is-element": "^1.0.0",
2828
"hast-util-to-string": "^1.0.0",
2929
"rehype-minify-whitespace": "^2.0.0",
30+
"trim-trailing-lines": "^1.1.0",
3031
"unist-util-is": "^2.1.0",
3132
"unist-util-visit": "^1.1.1",
3233
"xtend": "^4.0.1"

0 commit comments

Comments
 (0)