Skip to content

Commit 9d1a69c

Browse files
authored
don't add newlines where they don't belong (#4753)
1 parent 3510267 commit 9d1a69c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/jupyter/jupyter-fixups.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function fixupFrontMatter(nb: JupyterNotebook): JupyterNotebook {
114114

115115
// helper to create nb lines (w/ newline after)
116116
const nbLines = (lns: string[]) => {
117-
return lns.map((line) => `${line}\n`);
117+
return lns.map((line) => line.endsWith("\n") ? line : `${line}\n`);
118118
};
119119

120120
// look for the first raw block that has a yaml object
@@ -137,7 +137,7 @@ export function fixupFrontMatter(nb: JupyterNotebook): JupyterNotebook {
137137
for (const cell of nb.cells) {
138138
if (cell.cell_type === "markdown") {
139139
const { lines, headingText } = markdownWithExtractedHeading(
140-
cell.source.join("\n"),
140+
nbLines(cell.source).join(""),
141141
);
142142
if (headingText) {
143143
title = headingText;

0 commit comments

Comments
 (0)