-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support rendering partial markdown and improve performance #73
base: promplate-demo
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
审核指南 by Sourcery此拉取请求实现了重大更改,以改进 Markdown 渲染和代码块功能。主要更改包括从 时序图sequenceDiagram
participant C as Component
participant SM as SolidMarkdown
participant RP as RemarkPlugins
participant RH as RehypePlugins
participant CB as CodeBlock
C->>SM: Render markdown
SM->>RP: Process with remark plugins
SM->>RH: Process with rehype plugins
SM->>CB: Render code blocks
CB-->>SM: Return rendered code
SM-->>C: Return rendered markdown
文件级更改
提示和命令与 Sourcery 互动
自定义您的体验访问您的仪表板以:
获取帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request implements significant changes to improve markdown rendering and code block functionality. The main changes include switching from Sequence DiagramsequenceDiagram
participant C as Component
participant SM as SolidMarkdown
participant RP as RemarkPlugins
participant RH as RehypePlugins
participant CB as CodeBlock
C->>SM: Render markdown
SM->>RP: Process with remark plugins
SM->>RH: Process with rehype plugins
SM->>CB: Render code blocks
CB-->>SM: Return rendered code
SM-->>C: Return rendered markdown
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Deploy Preview for promplate-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @CNSeniorious000 - 我已经审查了你的更改,看起来很棒!
这是我在审查期间查看的内容
- 🟡 一般问题:发现1个问题
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用反馈来改进你的审查。
Original comment in English
Hey @CNSeniorious000 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Still,
|
c266328
to
d54381f
Compare
Created a PR to the upstream: andi23rosca/solid-markdown#36 |
d54381f
to
cba7def
Compare
cba7def
to
1fc3bc4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/components/controls/ModelSelector.svelte (1)
19-20
: 建议统一标题格式和添加描述性图标为保持与其他模型条目的一致性,建议:
- 添加描述性的 emoji 图标(如 ⚡ 或 🔄)
- 调整标题格式以包含更多描述性信息
建议按照如下方式修改:
- <ModelItem id="azure:gpt-4o" name="gpt-4o" title="GPT 4o (Azure)" /> - <ModelItem id="azure:gpt-4o-mini" name="gpt-4o-mini" title="GPT 4o mini (Azure)" /> + <ModelItem id="azure:gpt-4o" name="gpt-4o" title="⚡ Azure 提供的 GPT 4o" /> + <ModelItem id="azure:gpt-4o-mini" name="gpt-4o-mini" title="⚡ Azure 提供的 GPT 4o mini" />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/controls/ModelSelector.svelte
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint (windows)
🔇 Additional comments (1)
src/components/controls/ModelSelector.svelte (1)
18-20
: 请确认 Azure 模型的可用性分类这些 Azure 模型被放置在"低可用性模型"分类下。请确认:
- 这些模型确实存在较高的延迟
- 是否有计划改善其可用性
a948f72
to
614e121
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/MessageItem.tsx (2)
42-55
: 代码结构清晰,建议添加错误处理SolidMarkdown 的实现结构清晰,使用 reconcile 策略有助于优化性能。建议添加错误处理机制,以防止渲染失败影响用户体验。
建议添加以下功能:
- 错误边界处理
- 加载状态提示
<SolidMarkdown renderingStrategy="reconcile" remarkPlugins={[remarkGfm, remarkBreaks, remarkMath]} rehypePlugins={[rehypeKatex]} class="relative max-w-full overflow-hidden break-words prose <sm:text-3.6 message" + fallback={<div class="text-red-500">渲染失败,请重试</div>} components={{ code: CodeBlock, pre({ children }) { return <pre class="group overflow-hidden">{children}</pre> }, }} > {heuristicPatch(typeof message === 'function' ? message() : message)} </SolidMarkdown>
28-35
: 建议优化 heuristicPatch 函数的实现heuristicPatch 函数的实现可以更加优化,建议:
- 添加输入验证
- 使用更清晰的变量命名
- 添加函数说明注释
+/** + * 修复不完整的代码块标记 + * @param markdown 输入的 markdown 文本 + * @returns 修复后的 markdown 文本 + */ function heuristicPatch(markdown: string) { + if (typeof markdown !== 'string') return '' + const pattern = /(^|\n)```\S*$/ const matches = markdown.match(/```/g) + const hasOddBackticks = matches && matches.length % 2 === 1 - return (matches && matches.length % 2 === 1 && pattern.test(markdown)) + return (hasOddBackticks && pattern.test(markdown)) ? markdown.replace(pattern, '\n```') : markdown }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
package.json
(1 hunks)src/components/MessageItem.tsx
(2 hunks)uno.config.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- uno.config.ts
- package.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint (windows)
🔇 Additional comments (1)
src/components/MessageItem.tsx (1)
1-4
: 优化插件配置以提高性能当前导入了多个 remark 和 rehype 插件(remarkGfm、remarkMath、rehypeKatex、remarkBreaks)。建议评估每个插件的必要性,因为插件数量会直接影响渲染性能。
请考虑:
- 是否所有内容都需要数学公式渲染(remarkMath、rehypeKatex)?
- 是否可以按需加载这些插件?
What is the performance impact of using multiple remark and rehype plugins together?
14195f0
to
1f6ea62
Compare
Use
solid-markdown
to parse and render markdown without frequently updating DOMSourcery 的总结
用
solid-markdown
替换现有的 markdown 渲染方法,以支持部分 markdown 渲染,并通过最小化 DOM 更新来提高性能。重构代码以使用带有remark
和rehype
插件的unified
,并更新 API 模型版本。新功能:
solid-markdown
库渲染部分 markdown 的支持,增强 markdown 渲染的灵活性。增强:
solid-markdown
进行 markdown 解析和渲染,减少频繁的 DOM 更新以提高性能。remark
和rehype
插件的unified
,以提高可扩展性和可维护性。杂务:
Original summary in English
Summary by Sourcery
Replace the existing markdown rendering approach with
solid-markdown
to support partial markdown rendering and improve performance by minimizing DOM updates. Refactor the code to useunified
withremark
andrehype
plugins, and update the API model version.New Features:
solid-markdown
library, enhancing the flexibility of markdown rendering.Enhancements:
solid-markdown
for markdown parsing and rendering.unified
withremark
andrehype
plugins for better extensibility and maintainability.Chores:
Summary by CodeRabbit
新功能
样式优化