Skip to content

Spaces in image alt texts are not supported #1870

Open

Description

@sebastianludwig

The documentation references the following example

![Alt text](path/to/image.png)

but

formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
RDoc::Markdown.parse("![Alt text](path/to/image.png)").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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions