Skip to content

Commit d719b6b

Browse files
committed
Update code block styles
1 parent b8539c8 commit d719b6b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/vs/workbench/contrib/positronNotebook/browser/markdownRenderer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ function markedHighlight(options: marked.MarkedOptions & {
108108
code({ text, lang, escaped }: marked.Tokens.Code) {
109109
const classAttr = lang ? ` class="language-${escape(lang)}"` : '';
110110
text = text.replace(/\n$/, '');
111-
return `<pre><code${classAttr}>${escaped ? text : escape(text)}\n</code></pre>`;
111+
// Note: We intentionally omit the trailing \n that marked-highlight includes.
112+
// The \n is preserved by <pre>'s default white-space:pre behavior
113+
// this causes visible whitespace at the bottom of code blocks in Positron notebooks.
114+
return `<pre><code${classAttr}>${escaped ? text : escape(text)}</code></pre>`;
112115
},
113116
},
114117
};

src/vs/workbench/contrib/positronNotebook/browser/notebookCells/Markdown.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,18 @@
142142
border-radius: 4px;
143143
}
144144

145+
/** code block styling */
146+
pre {
147+
background-color: var(--vscode-textCodeBlock-background);
148+
padding: 16px;
149+
border-radius: 4px;
150+
}
151+
145152
pre code {
146153
line-height: 1.357em;
147154
white-space: pre-wrap;
148155
padding: 0;
156+
background-color: transparent; /* override inline code style */
149157
}
150158

151159
li p {

0 commit comments

Comments
 (0)