Skip to content

refactor(core): extract inline token rendering logic#697

Merged
dingyi222666 merged 2 commits intov1-devfrom
fix/markdown-renderer
Jan 27, 2026
Merged

refactor(core): extract inline token rendering logic#697
dingyi222666 merged 2 commits intov1-devfrom
fix/markdown-renderer

Conversation

@dingyi222666
Copy link
Member

Summary

This PR refactors the markdown token rendering logic by extracting inline token rendering into a separate renderInlineToken function. This improves code organization and reduces duplication in the main renderToken function.

Other Changes

  • Extracted inline token handling (code, codespan, image, blockquote, text, html) into renderInlineToken function
  • Consolidated token type checks for better maintainability
  • No functional changes to rendering behavior

Extract the inline token rendering logic (code, codespan, image, blockquote, text, html) into a separate `renderInlineToken` function to improve code organization and reduce duplication in the `renderToken` function. This refactoring consolidates inline token handling logic while maintaining the same functionality.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

packages/core/src/utils/koishi.ts 中,引入新的内部辅助函数 renderInlineToken 来统一处理内联令牌(代码、代码跨度、图像、块引用、文本、HTML)的渲染,使 renderToken 委派相关逻辑,从而减少代码重复并集中化内联令牌处理路径。

Changes

Cohort / File(s) 变更摘要
内联令牌渲染重构
packages/core/src/utils/koishi.ts
提取内联令牌渲染逻辑至新的 renderInlineToken 辅助函数;修改 renderToken 的控制流,优先委派内联令牌到新函数处理;更新链接令牌处理并优化回退逻辑

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 代码拆分成片片,
内联令牌归一处,
renderToken不再繁琐,
辅助函数轻轻梳,
重复消去无踪迹,✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/markdown-renderer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dingyi222666 dingyi222666 merged commit 57d4656 into v1-dev Jan 27, 2026
4 of 5 checks passed
@dingyi222666 dingyi222666 deleted the fix/markdown-renderer branch January 27, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant