Closed
Description
This is sort of a minor aesthetic issue, but generally I feel like any heading text being processed for a TOC header should follow the kind of conversion that ActiveSupport::Inflector#parameterize
does since it's going to end up in a URL:
parameterize "## 1. Commit your code in your feature branch."
=> "1-commit-your-code-in-your-feature-branch"
However this is how Redcarpet currently handles the same string:
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML_TOC, with_toc_data: true)
=> #<Redcarpet::Markdown:0x007fb013172d28 @renderer=#<Redcarpet::Render::HTML_TOC:0x007fb013172d50>>
markdown.render "## 1. Commit your code in your feature branch."
=> "<ul>\n<li>\n<a href=\"#1.-commit-your-code-in-your-feature-branch.\">1. Commit your code in your feature branch.</a>\n</li>\n</ul>\n"
Seems like a simple regex update inside of header_anchor would do the trick. It currently uses: <\\/?[^>]*>
This is the regex that parameterize
uses: /[^a-z0-9\-_]+/i
C isn't my strong suit, but I can try to provide a PR for this if it seems sane.