Skip to content

Commit 769a175

Browse files
authored
Merge pull request #98 from DEEIX-AI/fix_blod_style
fix: enhance strong font weight in markdown rendering
2 parents 57225db + 8e60b6f commit 769a175

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

frontend/app/globals.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
--font-heiti: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
5252
--font-chat: var(--font-sans);
5353
--font-chat-weight: 400;
54+
--font-chat-strong-weight: 700;
5455
--ui-font-scale: 1;
5556
--chat-font-scale: 1;
5657
--radius: 0.5rem;
@@ -115,6 +116,7 @@
115116
--font-heiti: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
116117
--font-chat: var(--font-sans);
117118
--font-chat-weight: 400;
119+
--font-chat-strong-weight: 700;
118120
--radius: 0.5rem;
119121
--shadow-x: 0;
120122
--shadow-y: 1px;
@@ -1064,14 +1066,17 @@
10641066

10651067
:root[data-chat-font-weight="medium"] {
10661068
--font-chat-weight: 500;
1069+
--font-chat-strong-weight: 700;
10671070
}
10681071

10691072
:root[data-chat-font-weight="semibold"] {
10701073
--font-chat-weight: 600;
1074+
--font-chat-strong-weight: 800;
10711075
}
10721076

10731077
:root[data-chat-font-weight="bold"] {
10741078
--font-chat-weight: 700;
1079+
--font-chat-strong-weight: 900;
10751080
}
10761081

10771082
:root[data-font-size="small"] {
@@ -1205,6 +1210,10 @@
12051210
font-weight: var(--font-chat-weight);
12061211
}
12071212

1213+
.chat-font-content[data-chat-markdown-scope] :where(strong, strong *, b, b *):not(pre *):not(code):not(code *) {
1214+
font-weight: var(--font-chat-strong-weight);
1215+
}
1216+
12081217
.chat-font-content .katex,
12091218
.chat-font-content .katex
12101219
:where(

frontend/features/chat/components/markdown/streamdown-components.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ type MarkdownParagraphProps = React.HTMLAttributes<HTMLParagraphElement> & {
7373
node?: unknown;
7474
};
7575

76+
type MarkdownStrongProps = React.HTMLAttributes<HTMLElement> & {
77+
children?: React.ReactNode;
78+
node?: unknown;
79+
};
80+
7681
type MarkdownHeadingProps = React.HTMLAttributes<HTMLHeadingElement> & {
7782
children?: React.ReactNode;
7883
};
@@ -945,6 +950,21 @@ export function MarkdownParagraph({ children, className, node: _node, style, ...
945950
);
946951
}
947952

953+
export function MarkdownStrong({ children, className, node: _node, style, ...props }: MarkdownStrongProps) {
954+
return (
955+
<strong
956+
{...props}
957+
className={cn("font-bold text-foreground", className)}
958+
style={{
959+
...sanitizeHTMLStyle(style),
960+
fontWeight: "var(--font-chat-strong-weight)",
961+
}}
962+
>
963+
{children}
964+
</strong>
965+
);
966+
}
967+
948968
export function MarkdownHTMLDiv({ children, className, node: _node, style }: MarkdownHTMLBlockProps) {
949969
return (
950970
<div className={cn("min-w-0 max-w-full", className)} style={sanitizeHTMLStyle(style)}>

frontend/features/chat/components/markdown/streamdown-render.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
MarkdownHTMLSpan,
3232
MarkdownHTMLSummary,
3333
MarkdownArtifactActionsContext,
34+
MarkdownStrong,
3435
ThinkingHeading,
3536
type MarkdownArtifactActions,
3637
type MarkdownImageActions,
@@ -188,6 +189,7 @@ const DEFAULT_STREAMDOWN_COMPONENTS = {
188189
a: MarkdownLink,
189190
article: MarkdownHTMLArticle,
190191
aside: MarkdownHTMLAside,
192+
b: MarkdownStrong,
191193
details: MarkdownHTMLDetails,
192194
div: MarkdownHTMLDiv,
193195
img: MarkdownImage,
@@ -196,6 +198,7 @@ const DEFAULT_STREAMDOWN_COMPONENTS = {
196198
pre: CollapsibleCodePre,
197199
section: MarkdownHTMLSection,
198200
span: MarkdownHTMLSpan,
201+
strong: MarkdownStrong,
199202
summary: MarkdownHTMLSummary,
200203
} as const;
201204

0 commit comments

Comments
 (0)