Merge upstream v0.4.0 into Gitea fork
This commit is contained in:
@@ -38,7 +38,7 @@ import {
|
||||
type PluginConfig,
|
||||
} from "streamdown";
|
||||
import { mdComponents } from "@/components/md-blocks";
|
||||
import { transformMathDelimiters } from "@/src/core";
|
||||
import { repairMathForDisplay, transformMathDelimiters } from "@/src/core";
|
||||
|
||||
export type MessageProps = HTMLAttributes<HTMLDivElement> & {
|
||||
from: LhViewMessage["role"];
|
||||
@@ -362,6 +362,12 @@ export const streamdownPlugins = {
|
||||
math: createMathPlugin({ singleDollarTextMath: true }),
|
||||
} as unknown as PluginConfig;
|
||||
|
||||
// Remend's incomplete-HTML heuristic mistakes `<b` in `$a<b$` for a
|
||||
// partial tag and deletes the remaining source before math can tokenize.
|
||||
// Preserve that text (unfinished prose HTML may show literally); Streamdown's
|
||||
// separate sanitization/hardening and all other Markdown repairs stay enabled.
|
||||
export const streamdownRemend = { htmlTags: false };
|
||||
|
||||
export const MessageResponse = memo(
|
||||
({ className, children, ...props }: MessageResponseProps) => {
|
||||
const { t } = useI18n();
|
||||
@@ -385,6 +391,7 @@ export const MessageResponse = memo(
|
||||
translations={translations}
|
||||
components={mdComponents}
|
||||
plugins={streamdownPlugins}
|
||||
remend={streamdownRemend}
|
||||
{...props}
|
||||
>
|
||||
{content}
|
||||
@@ -398,6 +405,16 @@ export const MessageResponse = memo(
|
||||
|
||||
MessageResponse.displayName = "MessageResponse";
|
||||
|
||||
/** Recovery is a tool-text presentation concern, not a shape/answer-data
|
||||
* transform. Ordinary assistant/user prose keeps MessageResponse unchanged. */
|
||||
export function ToolContentResponse({ children, ...props }: MessageResponseProps) {
|
||||
return (
|
||||
<MessageResponse {...props}>
|
||||
{typeof children === "string" ? repairMathForDisplay(children) : children}
|
||||
</MessageResponse>
|
||||
);
|
||||
}
|
||||
|
||||
export type MessageToolbarProps = ComponentProps<"div">;
|
||||
|
||||
export const MessageToolbar = ({
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import { Streamdown } from "streamdown";
|
||||
|
||||
import { transformMathDelimiters } from "@/src/core";
|
||||
import { streamdownPlugins } from "./message";
|
||||
import { streamdownPlugins, streamdownRemend } from "./message";
|
||||
import { mdComponents } from "@/components/md-blocks";
|
||||
import { Shimmer } from "./shimmer";
|
||||
|
||||
@@ -212,7 +212,7 @@ export const ReasoningContent = memo(
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<Streamdown components={mdComponents} plugins={streamdownPlugins}>
|
||||
<Streamdown components={mdComponents} plugins={streamdownPlugins} remend={streamdownRemend}>
|
||||
{transformMathDelimiters(children)}
|
||||
</Streamdown>
|
||||
</CollapsibleContent>
|
||||
|
||||
Reference in New Issue
Block a user