Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown links in a method's description are not properly rendered or scrubbed in the method-summary list of a Class/Module #1550

Open
postmodern opened this issue Aug 19, 2024 · 1 comment

Comments

@postmodern
Copy link
Contributor

I noticed this when reviewing the YARD API documentation using yard 0.9.36. Markdown named links (ex: [foo][1] ... [1]: ...) are not correctly rendered or scrubbed in the method-summary list for a Class/Method.

        #
        # [PowerShell unescapes][1] the characters in the data.
        #
        # [1]: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_special_characters?view=powershell-7.2
        #
        # ...
        #
        def self.unescape(data)

As you can see, the [PowerShell unescapes][1] text is preserved in the method-list summary text at the top of the Class/Module.

yard_screenshot

Steps to reproduce

lib/test.rb:

module Test
  #
  # [Named link][1] here.
  #
  # [1]: https://example.com/
  #
  # @return [nil]
  #
  def self.test
  end
end

Gemfile:

source 'https://rubygems.org'
gem 'yard', '0.9.36'
gem 'redcarpet'
$ bundle exec yardoc --markup markdown
$ open doc/index.html

Actual Output

$ yardoc --markup markdown --debug
[debug]: Parsing ["{lib,app}/**/*.rb", "ext/**/*.{c,cc,cxx,cpp,rb}"] with `ruby` parser
[debug]: Parsing lib/test.rb
[debug]: Serializing to .yardoc/objects/root.dat
[debug]: Re-generating object ...
[debug]: Re-generating object Test...
[debug]: Generating asset js/jquery.js
[debug]: Serializing to doc/js/jquery.js
[debug]: Generating asset js/app.js
[debug]: Serializing to doc/js/app.js
[debug]: Generating asset js/full_list.js
[debug]: Serializing to doc/js/full_list.js
[debug]: Generating asset css/style.css
[debug]: Serializing to doc/css/style.css
[debug]: Generating asset css/common.css
[debug]: Serializing to doc/css/common.css
[debug]: Generating asset css/full_list.css
[debug]: Serializing to doc/css/full_list.css
[debug]: Generating asset class_list.html
[debug]: Serializing to doc/class_list.html
[debug]: Generating asset method_list.html
[debug]: Serializing to doc/method_list.html
[debug]: Generating asset file_list.html
[debug]: Serializing to doc/file_list.html
[debug]: Generating asset frames.html
[debug]: Serializing to doc/frames.html
[debug]: Serializing to doc/index.html
[debug]: Serializing to doc/_index.html
[debug]: Serializing to doc/top-level-namespace.html
[debug]: Serializing to doc/Test.html
Files:           1
Modules:         1 (    1 undocumented)
Classes:         0 (    0 undocumented)
Constants:       0 (    0 undocumented)
Attributes:      0 (    0 undocumented)
Methods:         1 (    0 undocumented)
 50.00% documented

yard_test_screenshot

Expected Output

Either render the method description with the markdown link,or render the method description as plain-text without the link.

Environment details:

  • Ruby version (ruby -v): ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-linux]
  • YARD version (yard -v): yard 0.9.36
  • Relevant software dependency/versions:
    • redcarpet 3.6.0
@postmodern
Copy link
Contributor Author

Wait, I get it... It's because YARD is taking the first line of the method description and rendering it. Since the [1]: ... is on the third line, the named YARD link is not able to render. Using a regular [Link name](https://...) link works. Feel free to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant