Skip to content

Commit f3722be

Browse files
committed
Convert [] in heading to -squarebrackets in id
This essentially fixes an id collision when the guide has both method name and method name with square brackets in the heading. Example: # Working with validation errors ## `errors` ## `errors[]` Before: #working-with-validation-errors #working-with-validation-errors-errors #working-with-validation-errors-errors <= duplicate After: #working-with-validation-errors #working-with-validation-errors-errors #working-with-validation-errors-errors-squarebrackets
1 parent 6a88a10 commit f3722be

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

guides/rails_guides/markdown.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def dom_id_text(text)
5555

5656
text.downcase.gsub(/\?/, "-questionmark")
5757
.gsub(/!/, "-bang")
58+
.gsub(/\[\]/, "-squarebrackets")
5859
.gsub(/[#{escaped_chars}]+/, " ").strip
5960
.gsub(/\s+/, "-")
6061
end

0 commit comments

Comments
 (0)