Skip to content

Commit

Permalink
Fix markdown code block styling (#198351)
Browse files Browse the repository at this point in the history
Fixes #198183

Remove extra background and also removes the extra divs inside of the code blocks as these were causing issues with styling (extra padding)
  • Loading branch information
mjbvz authored Nov 15, 2023
1 parent 65b8f67 commit 8943ea4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions extensions/markdown-language-features/media/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ pre.hljs code > div {
}

pre code {
display: inline-block;
color: var(--vscode-editor-foreground);
tab-size: 4;
background: none;
}

/** Theming */
Expand Down
5 changes: 2 additions & 3 deletions extensions/markdown-language-features/src/markdownEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,14 @@ async function getMarkdownOptions(md: () => MarkdownIt): Promise<MarkdownIt.Opti
lang = normalizeHighlightLang(lang);
if (lang && hljs.getLanguage(lang)) {
try {
const highlighted = hljs.highlight(str, {
return hljs.highlight(str, {
language: lang,
ignoreIllegals: true,
}).value;
return `<div>${highlighted}</div>`;
}
catch (error) { }
}
return `<code><div>${md().utils.escapeHtml(str)}</div></code>`;
return md().utils.escapeHtml(str);
}
};
}
Expand Down

0 comments on commit 8943ea4

Please sign in to comment.