diff --git a/src/highlight.js b/src/highlight.js
index 4c9c0658de..189acd4c62 100644
--- a/src/highlight.js
+++ b/src/highlight.js
@@ -593,6 +593,7 @@ https://highlightjs.org/
} else if (options.tabReplace) {
return p1.replace(/\t/g, options.tabReplace);
}
+ return '';
});
}
diff --git a/test/api/fixmarkup.js b/test/api/fixmarkup.js
new file mode 100644
index 0000000000..61eaaeebc4
--- /dev/null
+++ b/test/api/fixmarkup.js
@@ -0,0 +1,21 @@
+'use strict';
+
+let should = require('should');
+let hljs = require('../../build');
+
+describe('.fixmarkup()', function() {
+ after(function() {
+ hljs.configure({ useBR: false })
+ })
+
+ it('should not add "undefined" to the beginning of the result (#1452)', function() {
+ hljs.configure({ useBR: true })
+ const value = '{ "some": \n "json" }';
+ const result = hljs.fixMarkup(value);
+
+
+ result.should.equal(
+ '{ "some":
"json" }'
+ );
+ });
+});
diff --git a/test/api/index.js b/test/api/index.js
index b8ddce7ce8..1f3ae503b9 100644
--- a/test/api/index.js
+++ b/test/api/index.js
@@ -9,4 +9,5 @@ describe('hljs', function() {
require('./starters');
require('./getLanguage');
require('./highlight');
+ require('./fixmarkup');
});