Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/renderer/components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ReactMarkdown from 'react-markdown';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { vs, vs2015 } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import rehypeKatex from 'rehype-katex';
import rehypeRaw from 'rehype-raw';
import remarkBreaks from 'remark-breaks';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
Expand Down Expand Up @@ -505,9 +506,11 @@ interface MarkdownViewProps {
codeStyle?: React.CSSProperties;
className?: string;
onRef?: (el?: HTMLDivElement | null) => void;
/** Enable raw HTML rendering in markdown content. Use with caution — only for trusted sources. */
allowHtml?: boolean;
}

const MarkdownView: React.FC<MarkdownViewProps> = ({ hiddenCodeCopyButton, codeStyle, className, onRef, children: childrenProp }) => {
const MarkdownView: React.FC<MarkdownViewProps> = ({ hiddenCodeCopyButton, codeStyle, className, onRef, allowHtml, children: childrenProp }) => {
const { t } = useTranslation();

const normalizedChildren = useMemo(() => {
Expand All @@ -533,7 +536,7 @@ const MarkdownView: React.FC<MarkdownViewProps> = ({ hiddenCodeCopyButton, codeS
<div ref={onRef} className='markdown-shadow-body'>
<ReactMarkdown
remarkPlugins={[remarkGfm, remarkMath, remarkBreaks]}
rehypePlugins={[rehypeKatex]}
rehypePlugins={allowHtml ? [rehypeRaw, rehypeKatex] : [rehypeKatex]}
components={{
span: ({ node: _node, className, children, ...props }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/UpdateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const UpdateModal: React.FC = () => {
{updateInfo?.name && <div className='text-14px font-500 text-t-primary mb-12px'>{updateInfo.name}</div>}
{updateInfo?.body ? (
<div className='text-13px text-t-secondary leading-relaxed'>
<MarkdownView>{updateInfo.body}</MarkdownView>
<MarkdownView allowHtml>{updateInfo.body}</MarkdownView>
</div>
) : (
<div className='text-13px text-t-tertiary italic'>{t('update.noReleaseNotes')}</div>
Expand Down
Loading