Skip to content

Commit 8fb3e48

Browse files
committed
feat: reduce code block line height to 1.4
1 parent 2a2533e commit 8fb3e48

2 files changed

Lines changed: 3534 additions & 3002 deletions

File tree

src/lib/dc/render-dc-html.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function tokenStyle(token: DcToken, foreground: string): string {
3838
color: sanitizeColor(token.color, foreground),
3939
"font-style": fontStyle > 0 && (fontStyle & 1) === 1 ? "italic" : undefined,
4040
"font-weight": fontStyle > 0 && (fontStyle & 2) === 2 ? 700 : undefined,
41-
"text-decoration": fontStyle > 0 && (fontStyle & 4) === 4 ? "underline" : undefined,
41+
"text-decoration":
42+
fontStyle > 0 && (fontStyle & 4) === 4 ? "underline" : undefined,
4243
});
4344
}
4445

@@ -51,7 +52,11 @@ function renderToken(token: DcToken, foreground: string): string {
5152
return `<span style="${tokenStyle(token, foreground)}">${content}</span>`;
5253
}
5354

54-
function renderLineNumber(index: number, foreground: string, width: string): string {
55+
function renderLineNumber(
56+
index: number,
57+
foreground: string,
58+
width: string,
59+
): string {
5560
const style = joinStyle({
5661
color: foreground,
5762
opacity: "0.45",
@@ -82,7 +87,7 @@ export function renderDcHtml(input: DcRenderInput): string {
8287
color: foreground,
8388
"font-family": codeFontFamily,
8489
"font-size": input.fontSize ?? "14px",
85-
"line-height": "1.58",
90+
"line-height": "1.4",
8691
margin: filename ? 0 : "0 0 16px",
8792
padding: input.showBackground ? "14px 16px" : 0,
8893
"white-space": "pre-wrap",
@@ -109,7 +114,9 @@ export function renderDcHtml(input: DcRenderInput): string {
109114
const prefix = input.showLineNumbers
110115
? renderLineNumber(index, lineForeground, lineNumberWidth)
111116
: "";
112-
const body = line.map((token) => renderToken(token, lineForeground)).join("");
117+
const body = line
118+
.map((token) => renderToken(token, lineForeground))
119+
.join("");
113120
const content = `${prefix}${body || "&nbsp;"}`;
114121

115122
if (!decoration) {

0 commit comments

Comments
 (0)