Spaces in image alt texts are not supported
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- markdown, ruby
调研方向
该问题位于 lib/rdoc/markup/formatter.rb 中的行内链接处理:add_regexp_handling_RDOCLINK 使用的模式会在空白处停止;另外也位于 lib/rdoc/markup/to_html.rb 中图片分支对 URL 与替代文本的拆分逻辑。先复现 issue 中的 Ruby 代码片段,查看 img 输出中替代文本被截断的情况。当  生成值为 "Alt text" 的 alt 属性,并且有测试覆盖该情况时,即为完成。
由索引模型根据 Issue 内容生成。
描述
The documentation references the following example

but
formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
RDoc::Markdown.parse("").accept(formatter)
produces "\n<p><img src=\"path/to/image.png\" alt=\"Alt\"> text</p>\n" - notice the "text" is not part of the alt attribute.
I think the problem is that markdown.rb correctly supports spaces in the internal representation as "rdoc-image:#{a[:link]}:#{a[:label]}" but formatter.rb specifically excludes spaces in
def add_regexp_handling_RDOCLINK
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
end
So given rdoc-image:image.svg:Alt Text only rdoc-image:image.svg:Alt is matched and Text becomes ordinary paragraph text.
Maybe using a regex similar to the one in to_html.rb url, alt = $'.split(/:(?!\/)/, 2) would be a solution?
- 主要语言
- Ruby
- 星标
- 928
- 派生
- 471
- 平均合并
- 2 天 4 分钟
- 30 天内合并 PR
- 13
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/rdoc 的其他 Issue
-
RDoc 8.0.0 gem omits `doc/rdoc/example.rb`, which is referenced by the packaged markup documentation可能已有人在做 @OskarEichler 于 65 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
markdown html excerpt includes link parts可能已有人在做 @anyingiit 于 11 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 66/100
维护者通常 1 天内回复
-
Regexp generated from unescaped input in #expand_class可能已有人在做 @jaynetics 于 23 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 25/100
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 68/100
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 82/100
zold-io/zold-ruby-sdk#85 ·
-
难度 1/5 1-3 小时 新手友好度 62/100
-
难度 1/5 1 小时以内 新手友好度 88/100