✨ feat(vscode): 注释里的仓库路径链接能点开并跳到符号
This commit is contained in:
1 parent
5528a405cc
commit
c4113748e1
13 files changed
+662
-18
No files matched your search
@@ -33,13 +33,21 @@ describe('renderMarkdown', () => {
|
||||
expect(renderMarkdown('改 sample.py 和 README.md')).toBe('<p>改 sample.py 和 README.md</p>\n')
|
||||
})
|
||||
|
||||
it('链接只认 http / https / mailto,别的照原文显示;图片不渲染', () => {
|
||||
it('危险链接和跑出仓库的路径照原文显示;图片不渲染', () => {
|
||||
expect(renderMarkdown('[点](javascript:alert(1))')).not.toContain('<a')
|
||||
expect(renderMarkdown('[命令](command:workbench.action.reloadWindow)')).not.toContain('<a')
|
||||
expect(renderMarkdown('[相对](./x.md)')).not.toContain('<a')
|
||||
expect(renderMarkdown('[上级](../secret)')).not.toContain('<a')
|
||||
expect(renderMarkdown('[行号](file.py#123)')).not.toContain('<a')
|
||||
expect(renderMarkdown('')).not.toContain('<img')
|
||||
})
|
||||
|
||||
it('仓库路径链接能点,带类名或类名.成员也一样', () => {
|
||||
expect(renderMarkdown('[智能体定义](vendor/agents)')).toBe('<p><a href="vendor/agents">智能体定义</a></p>\n')
|
||||
expect(renderMarkdown('[智能体表](backend/src/luffy_agent/agent/models.py#Agent)')).toBe('<p><a href="backend/src/luffy_agent/agent/models.py#Agent">智能体表</a></p>\n')
|
||||
expect(renderMarkdown('[owner 字段](backend/src/luffy_agent/agent/models.py#Agent.owner_id)')).toBe('<p><a href="backend/src/luffy_agent/agent/models.py#Agent.owner_id">owner 字段</a></p>\n')
|
||||
})
|
||||
|
||||
it('链接的标题走悬停提示(data-tooltip),不写原生 title', () => {
|
||||
expect(renderMarkdown('[文档](https://example.com "接口说明")')).toBe('<p><a href="https://example.com" data-tooltip="接口说明">文档</a></p>\n')
|
||||
expect(renderMarkdown('[文档](https://example.com "")')).toBe('<p><a href="https://example.com">文档</a></p>\n')
|
||||
|
||||
Reference in new issue
Block a user