Skip to content

Commit 74a8eb8

Browse files
committed
fix: preserve DC callout label typography
1 parent f4c5f6a commit 74a8eb8

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/lib/dc/export-document.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,11 @@ function safeBodyFontSize(options: DcExportOptions): string {
408408
return safeSize(options.bodyFontSize, defaultBodyFontSize);
409409
}
410410

411+
function proseLabelFont(options: DcExportOptions, lineHeight?: number): string {
412+
const family = safeProseFontFamily(options.bodyFontFamily).split(",")[0] ?? "Pretendard";
413+
return lineHeight ? `700 12px/${lineHeight} ${family}` : `700 12px ${family}`;
414+
}
415+
411416
function safeCodeFontSize(options: DcExportOptions): string {
412417
return safeSize(options.codeFontSize, defaultCodeFontSize);
413418
}
@@ -1002,9 +1007,7 @@ async function renderCallout(
10021007
display: "block",
10031008
margin: "0 0 6px",
10041009
color: palette.text,
1005-
"font-family": safeProseFontFamily(options.bodyFontFamily),
1006-
"font-size": "12px",
1007-
"font-weight": 700,
1010+
font: proseLabelFont(options),
10081011
"letter-spacing": "0",
10091012
});
10101013
const body = await Promise.all(

tests/unit/export-document.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
import { parseMarkdownToDocument } from "../../src/lib/editor/markdown-import";
1111

1212
const expectedDefaultDcProseFontFamily = safeDcProseFontFamily(defaultProseFontFamily);
13+
const expectedDefaultDcProseLabelFontFamily =
14+
expectedDefaultDcProseFontFamily.split(",")[0] ?? "Pretendard";
1315

1416
const exportOptions = {
1517
theme: "github-dark",
@@ -976,7 +978,11 @@ describe("exportDocumentToDcHtml", () => {
976978
expect(html).toContain("메모 <중요>");
977979
expect(html).toContain("cin/cout 설정을 앞에 둔다.");
978980
expect(html).toMatch(
979-
/<span style="display:block;margin:0 0 6px;color:#[0-9a-f]{6};font-size:12px;font-weight:700;letter-spacing:0"> &lt;&gt;<\/span>/,
981+
new RegExp(
982+
`<span style="display:block;margin:0 0 6px;color:#[0-9a-f]{6};font:700 12px ${escapeRegExp(
983+
expectedDefaultDcProseLabelFontFamily,
984+
)};letter-spacing:0">메모 &lt;중요&gt;</span>`,
985+
),
980986
);
981987
expect(html).not.toContain(">TIP</span>");
982988
expect(html).not.toContain(">핵심 요약</td>");

0 commit comments

Comments
 (0)