Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axilleas@axilleas.me>2017-06-29 12:57:19 +0300
committerAchilleas Pipinellis <axilleas@axilleas.me>2017-06-29 12:57:19 +0300
commit19fb2ddadf3e1f79efb790d7e8a43f53fd877f84 (patch)
treec09ef3f40bd5fffc2abd48c8436d57c252c613b4 /lib
parent9ea6d93016622dc7d78f12c4f1b1d082d9086248 (diff)
Resolve "Single quotes in headings provide strange anchor links"
Closes https://gitlab.com/gitlab-com/gitlab-docs/issues/84
Diffstat (limited to 'lib')
-rw-r--r--lib/helpers_.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/helpers_.rb b/lib/helpers_.rb
index e23e00da..e3310e31 100644
--- a/lib/helpers_.rb
+++ b/lib/helpers_.rb
@@ -13,8 +13,10 @@ class HTML < Redcarpet::Render::HTML
def header(text, header_level)
+ # https://gitlab.com/gitlab-com/gitlab-docs/issues/84#note_24957099
+ text = Nokogiri::HTML.parse(text).text
# https://github.com/cookpad/garage/blob/c817733e382c734eedba743e9103cd8a124f24eb/lib/garage/docs/anchor_building.rb#L24
- anchor = text.gsub(/\s+/, '-').gsub(/<\/?[^>]*>/, '').downcase
+ anchor = text.gsub(/\s+/, '-').downcase
# https://github.com/rails/rails/blob/e491b2c06329afb3c989261a2865d2a93c8b84b8/activesupport/lib/active_support/inflector/transliterate.rb#L86
anchor.gsub!(/[^a-z0-9\-_]+/i, '-')
anchor.squeeze!('-') # replace multiple dashes with one