Skip to content

Commit 2dfb12f

Browse files
authored
fix: with CRLF line breaks, an extra empty line was rendered with // highlight-end at end of code blocks
See: facebook#11036
1 parent c0f3755 commit 2dfb12f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export function parseLines(
241241
*/
242242
code: string;
243243
} {
244-
let code = content.replace(/\n$/, '');
244+
let code = content.replace(/\r?\n$/, '');
245245
const {language, magicComments, metastring} = options;
246246
// Highlighted lines specified in props: don't parse the content
247247
if (metastring && metastringLinesRangeRegex.test(metastring)) {
@@ -266,7 +266,7 @@ export function parseLines(
266266
magicComments,
267267
);
268268
// Go through line by line
269-
const lines = code.split('\n');
269+
const lines = code.split(/\r?\n/);
270270
const blocks = Object.fromEntries(
271271
magicComments.map((d) => [d.className, {start: 0, range: ''}]),
272272
);

0 commit comments

Comments
 (0)