fix(render): replace rune cast with IndexByte and add autolink unit tests#146
Open
shayne-snap wants to merge 1 commit into
Open
fix(render): replace rune cast with IndexByte and add autolink unit tests#146shayne-snap wants to merge 1 commit into
shayne-snap wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
修复代码审查中发现的两个问题:
1. 使用
strings.IndexByte替代rune(input[i])模式internal/tui/render/markdown.go—escapeMarkdownLiteral函数中将strings.ContainsRune(markdownSpecialChars, rune(input[i]))改为strings.IndexByte(markdownSpecialChars, input[i]) >= 0,消除误导性的rune(input[i])模式(对 ASCII 字符串逐字节操作)。2. 新增 autolink 解析独立单元测试
新增
internal/tui/render/markdown_autolink_test.go,为三个核心函数添加表格驱动测试(共 33 个用例):TestIsMarkdownAutolinkTarget— 协议检测(http/https/mailto)、大小写不敏感、无效输入TestEscapeMarkdownLiteral— 所有 markdown 特殊字符转义TestParseMarkdownAutolink— 两种转义模式、空/false 边界、HTML 标签排除、多个 autolink、blockquote 内、后接标点测试
所有 37 个
render包测试通过。