From 63f84e6c643da25aea9f37cae26b84174d0352a2 Mon Sep 17 00:00:00 2001 From: Feng Wang Date: Mon, 19 Jan 2026 11:30:51 +0800 Subject: [PATCH 1/3] Fix code block double border bug. --- src/components/custom/markdown-renderer.tsx | 24 +++++---------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/components/custom/markdown-renderer.tsx b/src/components/custom/markdown-renderer.tsx index 5939b20..f6831d2 100644 --- a/src/components/custom/markdown-renderer.tsx +++ b/src/components/custom/markdown-renderer.tsx @@ -44,16 +44,12 @@ function extractText(node: React.ReactNode): string { .join(""); } -function CodeBlock({ - inline, - className, +function CodeBlockPre({ children, ...props -}: DetailedHTMLProps, HTMLElement> & { inline?: boolean }) { +}: DetailedHTMLProps, HTMLPreElement>) { const [copied, setCopied] = useState(false); const timeoutRef = useRef(null); - const isInline = inline || !className || !className.includes("language-"); - const rest = props; const codeText = useMemo(() => extractText(children).replace(/\n$/, ""), [children]); useEffect(() => { @@ -64,14 +60,6 @@ function CodeBlock({ }; }, []); - if (isInline) { - return ( - - {children} - - ); - } - const handleCopy = async () => { try { await copyToClipboard(codeText); @@ -86,7 +74,7 @@ function CodeBlock({ }; return ( -
+
-
-        {children}
-      
+
{children}
); } @@ -119,7 +105,7 @@ export default function MarkdownRenderer({ content }: { content: string }) { components={{ ul: (props) =>
    , ol: (props) =>
      , - code: CodeBlock, + pre: CodeBlockPre, }} > {NormalizeMathTags(content)} From 6b5fa685596bab4f6b6ca9f92b8556435bfb0ffb Mon Sep 17 00:00:00 2001 From: Feng Wang Date: Mon, 19 Jan 2026 12:33:56 +0800 Subject: [PATCH 2/3] Fix unspecified code block rendering --- src/components/custom/markdown-renderer.tsx | 26 ++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/components/custom/markdown-renderer.tsx b/src/components/custom/markdown-renderer.tsx index f6831d2..5d0fd55 100644 --- a/src/components/custom/markdown-renderer.tsx +++ b/src/components/custom/markdown-renderer.tsx @@ -44,7 +44,17 @@ function extractText(node: React.ReactNode): string { .join(""); } +function ensureLanguageClass(className?: string) { + if (!className) { + return "language-plaintext"; + } + return className.split(" ").some((cls) => cls.startsWith("language-")) + ? className + : `${className} language-plaintext`; +} + function CodeBlockPre({ + className, children, ...props }: DetailedHTMLProps, HTMLPreElement>) { @@ -73,6 +83,18 @@ function CodeBlockPre({ } }; + const preClassName = ensureLanguageClass(className); + const mappedChildren = React.Children.map(children, (child) => { + if (!React.isValidElement<{ className?: string }>(child)) { + return child; + } + const typedChild = child as React.ReactElement<{ className?: string }>; + return React.cloneElement(typedChild, { + className: ensureLanguageClass(typedChild.props.className), + }); + }); + const normalizedChildren = mappedChildren ?? children; + return (
      -
      {children}
      +
      +        {normalizedChildren}
      +      
      ); } From f429e51b5d5356d900d73ad36ebbde8e49e85de1 Mon Sep 17 00:00:00 2001 From: Feng Wang Date: Mon, 19 Jan 2026 12:35:50 +0800 Subject: [PATCH 3/3] update version and change log --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5209af..4221903 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# 0.1.6 + +## What's new + +## Fixes + +* Fix code block double border issue +* Fix unspecified / unsupported code block styling issue + +## Changes + # 0.1.5 ## What's new diff --git a/package.json b/package.json index d221242..697e8b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tinywebui-webapp", - "version": "0.1.5", + "version": "0.1.6", "private": true, "type": "module", "scripts": {