Skip to content

Commit a473594

Browse files
committed
프리티어 해결
1 parent 8a821cf commit a473594

3 files changed

Lines changed: 27 additions & 14 deletions

File tree

src/scripts/components/card-component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ class CardComponent extends HTMLElement {
2424
this.innerHTML = `
2525
<div class="card">
2626
<a href="${href}" class="card-link">
27-
${imgSrc
28-
? `<div class="card-icon">
27+
${
28+
imgSrc
29+
? `<div class="card-icon">
2930
<img class="card-img" src="${imgSrc}" alt="${title}" />
3031
</div>`
31-
: ''}
32+
: ''
33+
}
3234
<div class="card-content">
3335
<p class="card-description">
3436
<strong class="card-title">${title}</strong><br />

src/scripts/load_md.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ marked.setOptions({
88

99
// card-component를 블록 태그 및 셀프 클로징 태그로 처리하는 커스텀 토크나이저 추가
1010
// 템플릿 리터럴에서 역참조(\1) 사용 불가하므로 정규식 리터럴로 하드코딩
11-
const blockTagRegex = /^<(card-component)([\s\S]*?)(?:>([\s\S]*?)<\/card-component>|\s*\/)>/i;
11+
const blockTagRegex =
12+
/^<(card-component)([\s\S]*?)(?:>([\s\S]*?)<\/card-component>|\s*\/)>/i;
1213

1314
const customBlockTokenizer = {
1415
name: 'custom-block-tag',
@@ -50,11 +51,17 @@ export async function renderMarkdownWithComponents(
5051
} else if (token.trim()) {
5152
// 나머지는 기존 방식대로 웹 컴포넌트 분리 후 마크다운 파싱
5253
const innerTokens = token
53-
.split(/(<card-component[\s\S]*?<\/card-component>|<card-component[\s\S]*?\/>|<button-component[\s\S]*?<\/button-component>|<button-component[\s\S]*?\/>)/gi)
54+
.split(
55+
/(<card-component[\s\S]*?<\/card-component>|<card-component[\s\S]*?\/>|<button-component[\s\S]*?<\/button-component>|<button-component[\s\S]*?\/>)/gi
56+
)
5457
.filter(Boolean);
5558
for (const innerToken of innerTokens) {
56-
if (/^<\/?(card-component|button-component)[^>]*?>.*?<\/(card-component|button-component)>$/.test(innerToken) ||
57-
/^<(card-component|button-component)[^>]*?\/>$/.test(innerToken)) {
59+
if (
60+
/^<\/?(card-component|button-component)[^>]*?>.*?<\/(card-component|button-component)>$/.test(
61+
innerToken
62+
) ||
63+
/^<(card-component|button-component)[^>]*?\/>$/.test(innerToken)
64+
) {
5865
contentElement.innerHTML += innerToken;
5966
} else if (innerToken.trim()) {
6067
const html = await marked.parse(innerToken);

src/styles/style.css

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,32 @@
2121
thead {
2222
@apply bg-gray-200;
2323
}
24-
2524
}
2625

2726
/* 카드 컴포넌트 스타일 */
2827
@layer components {
2928
.card {
30-
@apply min-w-0 bg-white rounded-md border border-gray-200 px-4 py-3 mb-4 transition duration-200 hover:border-gray-300 hover:shadow h-full flex flex-col;
29+
@apply mb-4 flex h-full min-w-0 flex-col rounded-md border border-gray-200 bg-white px-4 py-3 transition duration-200 hover:border-gray-300 hover:shadow;
3130
}
32-
31+
3332
.card-link {
3433
@apply flex items-start gap-4 no-underline;
3534
}
3635

3736
.card-icon {
38-
@apply flex-shrink-0 mt-1;
37+
@apply mt-1 flex-shrink-0;
3938
}
4039

4140
.card-img {
42-
@apply w-6 h-6;
41+
@apply h-6 w-6;
4342
}
4443

4544
.card-content {
4645
@apply flex-1;
4746
}
4847

4948
.card-description {
50-
@apply text-sm text-gray-500 leading-snug;
49+
@apply text-sm leading-snug text-gray-500;
5150
}
5251

5352
.card-title {
@@ -64,7 +63,12 @@ body {
6463
padding: 0;
6564
}
6665

67-
h1, h2, h3, h4, h5, h6 {
66+
h1,
67+
h2,
68+
h3,
69+
h4,
70+
h5,
71+
h6 {
6872
font-weight: 700;
6973
margin-top: 1.5em;
7074
margin-bottom: 0.5em;

0 commit comments

Comments
 (0)