Simon Willison 用 GPT-5.5 写了这个 Web 组件,能自动从 GitHub 链接抓取指定行的代码显示在网页上,带行号,做文档或博客嵌入代码很方便。
Simon Willison 使用 GPT-5.5 创建了实验性 Web 组件 github-code,仅通过一个提示词构建。该组件接受类似 https://github.com/simonw/sqlite-ast/blob/437c759... 的 URL,自动转换为 https://raw.githubusercontent.com/... 路径,然后用 fetch() 获取并显示指定行范围(如 #L9-L18),带行号但不支持语法高亮。它可直接嵌入网页展示代码片段。
github-code Web Component
Tool: github-code Web Component An experimental Web Component built using GPT-5.5 and the following prompt : let's build a Web Component for embedding code from GitHub <github-code href="https://github.com/simonw/sqlite-ast/blob/437c759129154f05296324a7f82aa1246340dd14/sqlite_ast/parser.py#L9-L18"></github-code> It takes URLs like that, converts them to https://raw.githubusercontent.com/simonw/sqlite-ast/437c759129154f05296324a7f82aa1246340dd14/sqlite_ast/parser.py, then uses fetch() to fetch them and displays the specified range of lines - with line numbers, no syntax highlighting though Show me a preview web browser so I can see your work Here's what it looks like embedded on this page: Tags: github , web-components , gpt
- arXiv cs.AI07-08 17:34原文